📄 serverfiledata.cs
字号:
using System;
namespace SourceFtp.Ftp
{
public class ServerFileData
{
public bool isDirectory;
public string fileName;
public int size;
public string type;
public string date;
public string permission;
public string owner;
public string group;
public ServerFileData()
{
}
public static ServerFileData ParseLine(string p_Line)
{
ServerFileData l_Data = null;
l_Data = ParseUnixDirLine(p_Line);
if (l_Data==null)
l_Data = ParseDosDirLine(p_Line);
return l_Data;
}
private static 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 static 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;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -