public static FromString ( string pathString ) : |
||
pathString | string | |
return |
public VolumeItem(Volume volume, VolumePath parentPath, String name) { Volume = volume; Path = VolumePath.FromString(name, parentPath); InitializeSuffixes(); }
public override VolumeItem Open(VolumePath path, bool ksmDefault = false) { try { var fileSystemInfo = Search(path, ksmDefault); if (fileSystemInfo == null) { return(null); } else if (fileSystemInfo is FileInfo) { VolumePath filePath = VolumePath.FromString(fileSystemInfo.FullName.Substring(ArchiveFolder.Length).Replace(Path.DirectorySeparatorChar, VolumePath.PathSeparator)); return(new ArchiveFile(this, fileSystemInfo as FileInfo, filePath)); } else { // we can use 'path' here, default extensions are not added to directories return(new ArchiveDirectory(this, path)); } } catch (Exception e) { throw new KOSPersistenceException("Could not open path: " + path, e); } }
public override IDictionary <string, VolumeItem> List() { string[] files = Directory.GetFiles(archivePath); var filterHid = files.Where(f => (File.GetAttributes(f) & FileAttributes.Hidden) != 0); var filterSys = files.Where(f => (File.GetAttributes(f) & FileAttributes.System) != 0); var visFiles = files.Except(filterSys).Except(filterHid).ToArray(); string[] directories = Directory.GetDirectories(archivePath); Array.Sort(directories); Array.Sort(visFiles); var result = new Dictionary <string, VolumeItem>(); foreach (string directory in directories) { string directoryName = System.IO.Path.GetFileName(directory); result.Add(directoryName, new ArchiveDirectory(archive, VolumePath.FromString(directoryName, Path))); } foreach (string file in visFiles) { string fileName = System.IO.Path.GetFileName(file); result.Add(fileName, new ArchiveFile(archive, new FileInfo(file), VolumePath.FromString(fileName, Path))); } return(result); }
/// <summary> /// Creates a GlobalPath from string. /// </summary> /// <returns>Path string, must have the following format: volumeId:[/]segment1[/furthersegments]*</returns> /// <param name="pathString">Path string.</param> public static new GlobalPath FromString(string pathString) { string volumeName = null; Match match = volumeIdentifierRegex.Match(pathString); if (match.Success) { volumeName = match.Groups["id"].Captures[0].Value; pathString = match.Groups["rest"].Captures[0].Value; } else { throw new KOSInvalidPathException("GlobalPath should contain a volumeId", pathString); } VolumePath path = VolumePath.FromString(pathString); return(new GlobalPath(volumeName, path)); }
// Handles global, absolute and relative paths private GlobalPath GlobalPathFromString(string pathString) { if (GlobalPath.HasVolumeId(pathString)) { return(GlobalPath.FromString(pathString)); } else { if (GlobalPath.IsAbsolute(pathString)) { return(GlobalPath.FromVolumePath(VolumePath.FromString(pathString), GetVolumeRawIdentifier(CurrentVolume))); } else { return(GlobalPath.FromStringAndBase(pathString, GlobalPath.FromVolumePath(CurrentDirectory.Path, GetVolumeRawIdentifier(CurrentVolume)))); } } }
public bool Delete(string pathString, bool ksmDefault = false) { return(Delete(VolumePath.FromString(pathString), ksmDefault)); }
public bool Exists(string pathString, bool ksmDefault = false) { return(Exists(VolumePath.FromString(pathString), ksmDefault)); }
public VolumeFile CreateFile(string pathString) { return(CreateFile(VolumePath.FromString(pathString))); }
public VolumeDirectory CreateDirectory(string pathString) { return(CreateDirectory(VolumePath.FromString(pathString))); }
public Structure OpenSafe(string pathString, bool ksmDefault = false) { VolumeItem item = Open(VolumePath.FromString(pathString), ksmDefault); return(item != null ? (Structure)item : BooleanValue.False); }
public VolumeItem Open(string pathString, bool ksmDefault = false) { return(Open(VolumePath.FromString(pathString), ksmDefault)); }
public HarddiskDirectory CreateDirectory(string name) { return(CreateDirectory(name, new HarddiskDirectory(Volume as Harddisk, VolumePath.FromString(name, Path)))); }