public static string GetParentPath( string text) { return(string.IsNullOrEmpty(text) ? text : ZlpPathHelper.GetFullPath(ZlpPathHelper.Combine(text, @".."))); }
public ZlpDirectoryInfo CreateSubdirectory(string name) { var path = ZlpPathHelper.Combine(FullName, name); ZlpIOHelper.CreateDirectory(path); return(new ZlpDirectoryInfo(path)); }
public ZlpFileOrDirectoryInfo Combine( string path) { return (new ZlpFileOrDirectoryInfo( ZlpPathHelper.Combine( EffectiveDirectory.FullName, path))); }
public ZlpFileOrDirectoryInfo Combine( ZlpFileOrDirectoryInfo info) { return (new ZlpFileOrDirectoryInfo( ZlpPathHelper.Combine( EffectiveDirectory.FullName, info.FullName))); }
public ZlpFileOrDirectoryInfo Combine( ZlpDirectoryInfo info) { return (new ZlpFileOrDirectoryInfo( ZlpPathHelper.Combine( EffectiveDirectory.FullName, // According to Reflector, "ToString()" returns the // "OriginalPath". This is what we need here. info.ToString()))); }
public static ZlpDirectoryInfo CombineDirectory(this ZlpDirectoryInfo one, ZlpDirectoryInfo two) { if (one == null) { return(two); } else if (two == null) { return(one); } else { return(new ZlpDirectoryInfo(ZlpPathHelper.Combine(one.FullName, two.FullName))); } }
public static ZlpFileInfo[] GetFiles(string directoryPath, string pattern, SearchOption searchOption) { directoryPath = CheckAddLongPathPrefix(directoryPath); var results = new List <ZlpFileInfo>(); PInvokeHelper.WIN32_FIND_DATA findData; var findHandle = PInvokeHelper.FindFirstFile(directoryPath.TrimEnd('\\') + "\\" + pattern, out findData); if (findHandle != PInvokeHelper.INVALID_HANDLE_VALUE) { try { bool found; do { var currentFileName = findData.cFileName; // if this is a file, find its contents if (((int)findData.dwFileAttributes & PInvokeHelper.FILE_ATTRIBUTE_DIRECTORY) == 0) { results.Add(new ZlpFileInfo(ZlpPathHelper.Combine(directoryPath, currentFileName))); } // find next found = PInvokeHelper.FindNextFile(findHandle, out findData); } while (found); } finally { // close the find handle PInvokeHelper.FindClose(findHandle); } } if (searchOption == SearchOption.AllDirectories) { foreach (var dir in GetDirectories(directoryPath)) { results.AddRange(GetFiles(dir.FullName, pattern, searchOption)); } } return(results.ToArray()); }
public static ZlpFileInfo CombineFile(/*this*/ string one, string two) { if (one == null && two == null) { return(null); } else if (two == null) { return(null); } else if (one == null) { return(new ZlpFileInfo(two)); } else { return(new ZlpFileInfo(ZlpPathHelper.Combine(one, two))); } }
public static ZlpFileInfo CombineFile(this ZlpDirectoryInfo one, string two) { if (one == null && two == null) { return(null); } else if (two == null) { return(null); } else if (one == null) { return(new ZlpFileInfo(two)); } else { return(new ZlpFileInfo(ZlpPathHelper.Combine(one.FullName, two))); } }
public static ZlpDirectoryInfo[] GetDirectories(string directoryPath, string pattern) { directoryPath = CheckAddLongPathPrefix(directoryPath); var results = new List <ZlpDirectoryInfo>(); PInvokeHelper.WIN32_FIND_DATA findData; var findHandle = PInvokeHelper.FindFirstFile(directoryPath.TrimEnd('\\') + @"\" + pattern, out findData); if (findHandle != PInvokeHelper.INVALID_HANDLE_VALUE) { try { bool found; do { var currentFileName = findData.cFileName; // if this is a directory, find its contents if (((int)findData.dwFileAttributes & PInvokeHelper.FILE_ATTRIBUTE_DIRECTORY) != 0) { if (currentFileName != @"." && currentFileName != @"..") { results.Add(new ZlpDirectoryInfo(ZlpPathHelper.Combine(directoryPath, currentFileName))); } } // find next found = PInvokeHelper.FindNextFile(findHandle, out findData); } while (found); } finally { // close the find handle PInvokeHelper.FindClose(findHandle); } } return(results.ToArray()); }