FromString() public static method

public static FromString ( string pathString ) : VolumePath
pathString string
return VolumePath
Exemplo n.º 1
0
        public VolumeItem(Volume volume, VolumePath parentPath, String name)
        {
            Volume = volume;
            Path   = VolumePath.FromString(name, parentPath);

            InitializeSuffixes();
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
 // 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))));
         }
     }
 }
Exemplo n.º 6
0
 public bool Delete(string pathString, bool ksmDefault = false)
 {
     return(Delete(VolumePath.FromString(pathString), ksmDefault));
 }
Exemplo n.º 7
0
 public bool Exists(string pathString, bool ksmDefault = false)
 {
     return(Exists(VolumePath.FromString(pathString), ksmDefault));
 }
Exemplo n.º 8
0
 public VolumeFile CreateFile(string pathString)
 {
     return(CreateFile(VolumePath.FromString(pathString)));
 }
Exemplo n.º 9
0
 public VolumeDirectory CreateDirectory(string pathString)
 {
     return(CreateDirectory(VolumePath.FromString(pathString)));
 }
Exemplo n.º 10
0
        public Structure OpenSafe(string pathString, bool ksmDefault = false)
        {
            VolumeItem item = Open(VolumePath.FromString(pathString), ksmDefault);

            return(item != null ? (Structure)item : BooleanValue.False);
        }
Exemplo n.º 11
0
 public VolumeItem Open(string pathString, bool ksmDefault = false)
 {
     return(Open(VolumePath.FromString(pathString), ksmDefault));
 }
Exemplo n.º 12
0
 public HarddiskDirectory CreateDirectory(string name)
 {
     return(CreateDirectory(name, new HarddiskDirectory(Volume as Harddisk, VolumePath.FromString(name, Path))));
 }