public byte[] FilesSimple(string appName, string path, ushort instance) { var helper = new AppsHelper(_proxyUser, _credMgr); return helper.Files(appName, path, instance); }
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 (FileRe.IsMatch(firstLine) || DirRe.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 = FileRe.Match(item); if (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 = DirRe.Match(item); if (dirMatch.Success) { string dirName = dirMatch.Groups[1].Value; rv.AddDirectory(dirName); continue; } throw new InvalidOperationException("Match failed."); } } else { rv = new VcapFilesResult(content); } } return(rv); }
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; for (i = 0; i < content.Length; ++i) { if (content[i] == '\n') { break; } } string firstLine = Encoding.ASCII.GetString(content, 0, i); if (FileRe.IsMatch(firstLine) || DirRe.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 = FileRe.Match(item); if (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 = DirRe.Match(item); if (dirMatch.Success) { string dirName = dirMatch.Groups[1].Value; rv.AddDirectory(dirName); continue; } throw new InvalidOperationException("Match failed."); } } else { rv = new VcapFilesResult(content); } } return rv; }
public byte[] FilesSimple(string appName, string path, ushort instance) { var helper = new AppsHelper(proxyUser, credMgr); return(helper.Files(appName, path, instance)); }