private Status ExcuteByPattern(Component target, string pattern) { if (pattern == "*") //删除目录下所有文件 { for (int i = 0; i < target.childs.Count; i++) { Component child = target.childs[i]; if (child.IsDirectory()) { continue; } child.Remove(); } } else if (pattern.StartsWith("*.")) //删除指定后缀名的文件 { string matchStr = pattern.Substring(2); if (nameRegex.IsMatch(matchStr)) { return(Status.Error_Path_Format); } for (int i = 0; i < target.childs.Count; i++) { Component child = target.childs[i]; if (child.IsDirectory()) { continue; } if (child.GetName().EndsWith(matchStr)) { child.Remove(); i--; } } } else //删除单个文件 { if (nameRegex.IsMatch(pattern)) { return(Status.Error_Path_Format); } VsFile file = target.GetFile(pattern); if (file != null) { file.Remove(); } } return(Status.Succeed); }
public override void Excute() { if (_path == "") { _target = VsDiskMoniter.Instance.Cursor; } else { MString fileName; Status status = CheckPath(ref _path, out _target, out fileName, false); if (status != Status.Succeed) { Logger.Log(status); return; } else if (fileName != "*") { var file = _target.GetFile(fileName); if (file == null) { Logger.Log(Status.Error_Path_Not_Found); return; } _target = file; } } if (_target != null) { if (_target.IsDirectory()) { ShowDirectoryInfos(_target); } else { Console.WriteLine(" " + _target.parent.GetPath() + " 的目录\n"); Console.WriteLine(_target.GetChangeTime() + (_target as VsFile).GetFileSizeString() + _target.GetName()); } } }
public void ShowFile(Component file) { Console.WriteLine(file.GetChangeTime() + (file as VsFile).GetFileSizeString() + file.GetName()); }