/// <summary> /// A callback function that takes a non-shadow path to a folder, /// and returns all files found in a non-shadow path format. /// </summary> /// <param name="localFolderPath">The non-shadow path of the folder to list</param> /// <returns>A list of non-shadow paths</returns> protected override string[] ListFiles(string localFolderPath) { string[] files = null; var spath = ConvertToSnapshotPath(localFolderPath); // First try without long UNC prefixed try { files = SystemIO.IO_WIN.GetFiles(spath); } catch (DirectoryNotFoundException) //TODO: Do we really need this?? { spath = SystemIOWindows.PrefixWithUNC(spath); files = SystemIO.IO_WIN.GetFiles(spath); } // convert back to non-shadow, i.e., non-vss version var root = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath)); var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root)); volumePath = SystemIOWindows.PrefixWithUNC(volumePath); for (var i = 0; i < files.Length; i++) { files[i] = root + SystemIOWindows.PrefixWithUNC(files[i]).Substring(volumePath.Length); } return(files); }
/// <summary> /// A callback function that takes a non-shadow path to a folder, /// and returns all files found in a non-shadow path format. /// </summary> /// <param name="localFolderPath">The non-shadow path of the folder to list</param> /// <returns>A list of non-shadow paths</returns> protected override string[] ListFiles(string localFolderPath) { var root = Utility.Utility.AppendDirSeparator(AlphaFS.Path.GetPathRoot(localFolderPath)); var volumePath = Utility.Utility.AppendDirSeparator(ConvertToSnapshotPath(root)); string[] tmp = null; var spath = ConvertToSnapshotPath(localFolderPath); if (SystemIOWindows.IsPathTooLong(spath)) { try { tmp = AlphaFS.Directory.GetFiles(spath); } catch (PathTooLongException) { } catch (DirectoryNotFoundException) { } } else { try { tmp = Directory.GetFiles(spath); } catch (PathTooLongException) { } } if (tmp == null) { spath = SystemIOWindows.PrefixWithUNC(spath); tmp = AlphaFS.Directory.GetFiles(spath); } volumePath = SystemIOWindows.PrefixWithUNC(volumePath); for (var i = 0; i < tmp.Length; i++) { tmp[i] = root + SystemIOWindows.PrefixWithUNC(tmp[i]).Substring(volumePath.Length); } return(tmp); }
/// <summary> /// A callback function that takes a non-shadow path to a folder, /// and returns all folders found in a non-shadow path format. /// </summary> /// <param name="localFolderPath">The non-shadow path of the folder to list</param> /// <returns>A list of non-shadow paths</returns> protected override string[] ListFolders(string localFolderPath) { string[] tmp = null; var spath = ConvertToSnapshotPath(localFolderPath); try { tmp = SystemIO.IO_WIN.GetDirectories(spath); } catch (DirectoryNotFoundException) //TODO: Do we really need this?? { spath = SystemIOWindows.PrefixWithUNC(spath); tmp = SystemIO.IO_WIN.GetDirectories(spath); } var root = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath)); var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root)); volumePath = SystemIOWindows.PrefixWithUNC(volumePath); for (var i = 0; i < tmp.Length; i++) { tmp[i] = root + SystemIOWindows.PrefixWithUNC(tmp[i]).Substring(volumePath.Length); } return(tmp); }
/// <summary> /// Returns the symlink target if the entry is a symlink, and null otherwise /// </summary> /// <param name="file">The file or folder to examine</param> /// <returns>The symlink target</returns> public override string GetSymlinkTarget(string file) { try { return(File.GetLinkTargetInfo(SystemIOWindows.PrefixWithUNC(file)).PrintName); } catch (NotAReparsePointException) { } catch (UnrecognizedReparsePointException) { } return(null); }
/// <summary> /// Opens a file for reading /// </summary> /// <param name="file">The full path to the file in non-snapshot format</param> /// <returns>An open filestream that can be read</returns> public override System.IO.Stream OpenRead(string file) { if (!SystemIOWindows.IsPathTooLong(file)) { try { return(base.OpenRead(file)); } catch (System.IO.PathTooLongException) { } } return(File.OpenRead(SystemIOWindows.PrefixWithUNC(file))); }
/// <summary> /// Gets the last write time of a given file in UTC /// </summary> /// <param name="file">The full path to the file in non-snapshot format</param> /// <returns>The last write time of the file</returns> public override DateTime GetLastWriteTimeUtc(string file) { if (!SystemIOWindows.IsPathTooLong(file)) { try { return(base.GetLastWriteTimeUtc(file)); } catch (System.IO.PathTooLongException) { } } return(File.GetLastWriteTimeUtc(SystemIOWindows.PrefixWithUNC(file))); }
/// <summary> /// Lists all folders in the given folder /// </summary> /// <returns>All folders found in the folder</returns> /// <param name='localFolderPath'>The folder to examinate</param> protected override string[] ListFolders(string localFolderPath) { string[] tmp = SystemIO.IO_WIN.GetDirectories(SystemIOWindows.PrefixWithUNC(localFolderPath)); string[] res = new string[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { res[i] = SystemIOWindows.StripUNCPrefix(tmp[i]); } return(res); }
/// <summary> /// Gets the creation of a given file in UTC /// </summary> /// <param name="localPath">The full path to the file in non-shadow format</param> /// <returns>The last write time of the file</returns> public override DateTime GetCreationTimeUtc(string localPath) { var spath = ConvertToSnapshotPath(localPath); if (!SystemIOWindows.IsPathTooLong(spath)) { try { return(File.GetCreationTimeUtc(spath)); } catch (PathTooLongException) { } } return(AlphaFS.File.GetCreationTimeUtc(SystemIOWindows.PrefixWithUNC(spath))); }
/// <summary> /// Lists all folders in the given folder /// </summary> /// <returns>All folders found in the folder</returns> /// <param name='folder'>The folder to examinate</param> protected override string[] ListFolders(string folder) { if (!SystemIOWindows.IsPathTooLong(folder)) { try { return(base.ListFolders(folder)); } catch (System.IO.PathTooLongException) { } } string[] tmp = Directory.GetDirectories(SystemIOWindows.PrefixWithUNC(folder)); string[] res = new string[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { res[i] = SystemIOWindows.StripUNCPrefix(tmp[i]); } return(res); }
/// <summary> /// A callback function that takes a non-shadow path to a folder, /// and returns all files found in a non-shadow path format. /// </summary> /// <param name="localFolderPath">The non-shadow path of the folder to list</param> /// <returns>A list of non-shadow paths</returns> protected override string[] ListFiles(string localFolderPath) { string[] files = null; var spath = ConvertToSnapshotPath(localFolderPath); files = SystemIO.IO_WIN.GetFiles(spath); // convert back to non-shadow, i.e., non-vss version var root = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath)); var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root)); volumePath = SystemIOWindows.PrefixWithUNC(volumePath); for (var i = 0; i < files.Length; i++) { files[i] = root + SystemIOWindows.PrefixWithUNC(files[i]).Substring(volumePath.Length); } return(files); }
/// <summary> /// Gets the creation of a given file in UTC /// </summary> /// <param name="localPath">The full path to the file in non-shadow format</param> /// <returns>The last write time of the file</returns> public override DateTime GetCreationTimeUtc(string localPath) { var spath = ConvertToSnapshotPath(localPath); return(SystemIO.IO_WIN.GetCreationTimeUtc(SystemIOWindows.PrefixWithUNC(spath))); }
/// <summary> /// Returns the symlink target if the entry is a symlink, and null otherwise /// </summary> /// <param name="file">The file or folder to examine</param> /// <returns>The symlink target</returns> public override string GetSymlinkTarget(string file) { return(File.GetLinkTargetInfo(SystemIOWindows.PrefixWithUNC(file)).PrintName); }