Ejemplo n.º 1
0
        public byte[] FilesSimple(string appName, string path, ushort instance)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.Files(appName, path, instance));
        }
Ejemplo n.º 2
0
 public byte[] FilesSimple(string appName, string path, ushort instance)
 {
     CheckLoginStatus();
     var hlpr = new AppsHelper(proxyUser, credMgr);
     return hlpr.Files(appName, path, instance);
 }
Ejemplo n.º 3
0
        public VcapFilesResult Files(string appName, string path, ushort instance)
        {
            CheckLoginStatus();

            VcapFilesResult rv;

            var hlpr = new AppsHelper(proxyUser, credMgr);
            byte[] content = hlpr.Files(appName, path, instance);
            if (null == content)
            {
                rv = new VcapFilesResult(false);
            }
            else if (content.Length == 0)
            {
                rv = new VcapFilesResult(content);
            }
            else
            {
                int i = 0;
                for (i = 0; i < content.Length; ++i)
                {
                    if (content[i] == '\n')
                    {
                        break;
                    }
                }
                string firstLine = Encoding.ASCII.GetString(content, 0, i);
                if (file_re.IsMatch(firstLine) || dir_re.IsMatch(firstLine))
                {
                    // Probably looking at a listing, not a file
                    string contentAscii = Encoding.ASCII.GetString(content);
                    string[] contentAry = contentAscii.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    rv = new VcapFilesResult();
                    foreach (string item in contentAry)
                    {
                        Match fileMatch = file_re.Match(item);
                        if (null != fileMatch && fileMatch.Success)
                        {
                            string fileName = fileMatch.Groups[1].Value; // NB: 0 is the entire matched string
                            string fileSize = fileMatch.Groups[2].Value;
                            rv.AddFile(fileName, fileSize);
                            continue;
                        }

                        Match dirMatch = dir_re.Match(item);
                        if (null != dirMatch && dirMatch.Success)
                        {
                            string dirName = dirMatch.Groups[1].Value;
                            rv.AddDirectory(dirName);
                            continue;
                        }

                        throw new InvalidOperationException("Match failed.");
                    }
                }
                else
                {
                    rv = new VcapFilesResult(content);
                }
            }

            return rv;
        }
Ejemplo n.º 4
0
        public VcapFilesResult Files(string appName, string path, ushort instance)
        {
            VcapFilesResult rv;

            var helper = new AppsHelper(proxyUser, credMgr);

            byte[] content = helper.Files(appName, path, instance);
            if (null == content)
            {
                rv = new VcapFilesResult(false);
            }
            else if (content.Length == 0)
            {
                rv = new VcapFilesResult(content);
            }
            else
            {
                int i = 0;
                for (i = 0; i < content.Length; ++i)
                {
                    if (content[i] == '\n')
                    {
                        break;
                    }
                }
                string firstLine = Encoding.ASCII.GetString(content, 0, i);
                if (file_re.IsMatch(firstLine) || dir_re.IsMatch(firstLine))
                {
                    // Probably looking at a listing, not a file
                    string   contentAscii = Encoding.ASCII.GetString(content);
                    string[] contentAry   = contentAscii.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    rv = new VcapFilesResult();
                    foreach (string item in contentAry)
                    {
                        Match fileMatch = file_re.Match(item);
                        if (null != fileMatch && fileMatch.Success)
                        {
                            string fileName = fileMatch.Groups[1].Value; // NB: 0 is the entire matched string
                            string fileSize = fileMatch.Groups[2].Value;
                            rv.AddFile(fileName, fileSize);
                            continue;
                        }

                        Match dirMatch = dir_re.Match(item);
                        if (null != dirMatch && dirMatch.Success)
                        {
                            string dirName = dirMatch.Groups[1].Value;
                            rv.AddDirectory(dirName);
                            continue;
                        }

                        throw new InvalidOperationException("Match failed.");
                    }
                }
                else
                {
                    rv = new VcapFilesResult(content);
                }
            }

            return(rv);
        }
Ejemplo n.º 5
0
        public byte[] FilesSimple(string appName, string path, ushort instance)
        {
            var helper = new AppsHelper(proxyUser, credMgr);

            return(helper.Files(appName, path, instance));
        }
Ejemplo n.º 6
0
 public byte[] FilesSimple(string appName, string path, ushort instance)
 {
     var helper = new AppsHelper(proxyUser, credMgr);
     return helper.Files(appName, path, instance);
 }