private ServerFileData ParseUnixDirLine(string line) { ServerFileData sfd = new ServerFileData(); try { string[] parsed = new string[8]; int index = 0; int position; // Parse out the elements position = line.IndexOf(' '); while (index < parsed.Length) { parsed[index] = line.Substring(0, position); line = line.Substring(position); line = line.Trim(); index++; position = line.IndexOf(' '); } sfd.fileName = line; sfd.permission = parsed[0]; sfd.owner = parsed[2]; sfd.group = parsed[3]; sfd.size = Convert.ToInt32(parsed[4]); sfd.date = parsed[5] + ' ' + parsed[6] + ' ' + parsed[7]; sfd.isDirectory = sfd.permission[0] == 'd'; } catch { sfd = null; } return(sfd); }
private void ParseUnixDirList(string sDir) { const string CRLF = "\r\n"; try { m_filecount = 0; int i = 0; sDir = sDir.Replace(CRLF, "\r"); string[] sFile = sDir.Split(new Char[] { '\r' }); ServerFileData sfd = null; int autodetect = 0; foreach (string fileLine in sFile) { if (autodetect == 0) { sfd = ParseDosDirLine(fileLine); if (sfd == null) { sfd = ParseUnixDirLine(fileLine); autodetect = 2; } else { autodetect = 1; } } else if (autodetect == 1) { sfd = ParseDosDirLine(fileLine); } else if (autodetect == 2) { sfd = ParseUnixDirLine(fileLine); } if (sfd != null) { m_files[i] = sfd; i++; m_filecount = i; } } } catch (Exception e) { } }
private ServerFileData ParseDosDirLine(string line) { ServerFileData sfd = new ServerFileData(); try { string[] parsed = new string[3]; int index = 0; int position = 0; // Parse out the elements position = line.IndexOf(' '); while (index < parsed.Length) { parsed[index] = line.Substring(0, position); line = line.Substring(position); line = line.Trim(); index++; position = line.IndexOf(' '); } sfd.fileName = line; if (parsed[2] != "<DIR>") { sfd.size = Convert.ToInt32(parsed[2]); } sfd.date = parsed[0] + ' ' + parsed[1]; sfd.isDirectory = parsed[2] == "<DIR>"; } catch { sfd = null; } return(sfd); }
private ServerFileData ParseUnixDirLine(string line) { ServerFileData sfd = new ServerFileData(); try { string[] parsed = new string [8]; int index = 0; int position; // Parse out the elements position = line.IndexOf(' '); while (index<parsed.Length) { parsed[index] = line.Substring(0, position); line = line.Substring(position); line = line.Trim(); index++; position = line.IndexOf(' '); } sfd.fileName = line; sfd.permission = parsed[0]; sfd.owner = parsed[2]; sfd.group = parsed[3]; sfd.size = Convert.ToInt32(parsed[4]); sfd.date = parsed[5]+ ' ' + parsed[6] + ' ' + parsed[7]; sfd.isDirectory = sfd.permission[0] == 'd'; } catch { sfd = null; } return sfd; }
private ServerFileData ParseDosDirLine(string line) { ServerFileData sfd = new ServerFileData(); try { string[] parsed = new string[3]; int index = 0; int position = 0; // Parse out the elements position = line.IndexOf(' '); while (index<parsed.Length) { parsed[index] = line.Substring(0, position); line = line.Substring(position); line = line.Trim(); index++; position = line.IndexOf(' '); } sfd.fileName = line; if (parsed[2] != "<DIR>") sfd.size = Convert.ToInt32(parsed[2]); sfd.date = parsed[0]+ ' ' + parsed[1]; sfd.isDirectory = parsed[2] == "<DIR>"; } catch { sfd = null; } return sfd; }