GetParent() public method

public GetParent ( ) : VolumePath
return VolumePath
示例#1
0
        public override VolumeFile CreateFile(VolumePath path)
        {
            if (path.Depth == 0)
            {
                throw new KOSPersistenceException("Can't create a file over root directory");
            }

            string archivePath = GetArchivePath(path);

            if (File.Exists(archivePath))
            {
                throw new KOSPersistenceException("Already exists: " + path);
            }

            try
            {
                Directory.CreateDirectory(GetArchivePath(path.GetParent()));
            }
            catch (IOException)
            {
                throw new KOSPersistenceException("Parent directory for path does not exist: " + path.ToString());
            }

            try
            {
                File.Create(archivePath).Dispose();
            }
            catch (UnauthorizedAccessException)
            {
                throw new KOSPersistenceException("Could not create file: " + path);
            }

            return(Open(path) as VolumeFile);
        }
示例#2
0
        private HarddiskDirectory ParentDirectoryForPath(VolumePath path, bool create = false)
        {
            HarddiskDirectory directory = RootHarddiskDirectory;

            if (path.Depth > 0)
            {
                return(RootHarddiskDirectory.GetSubdirectory(path.GetParent(), create));
            }
            else
            {
                throw new Exception("This directory does not have a parent");
            }
        }
示例#3
0
文件: Harddisk.cs 项目: KSP-KOS/KOS
 private HarddiskDirectory ParentDirectoryForPath(VolumePath path, bool create = false)
 {
     HarddiskDirectory directory = RootHarddiskDirectory;
     if (path.Depth > 0)
     {
         return RootHarddiskDirectory.GetSubdirectory(path.GetParent(), create);
     }
     else
     {
         throw new Exception("This directory does not have a parent");
     }
 }
示例#4
0
文件: Archive.cs 项目: KSP-KOS/KOS
        public override VolumeFile CreateFile(VolumePath path)
        {
            if (path.Depth == 0)
            {
                throw new KOSPersistenceException("Can't create a file over root directory");
            }

            string archivePath = GetArchivePath(path);

            if (File.Exists(archivePath))
            {
                throw new KOSPersistenceException("Already exists: " + path);
            }

            try
            {
                Directory.CreateDirectory(GetArchivePath(path.GetParent()));
            }
            catch (IOException)
            {
                throw new KOSPersistenceException("Parent directory for path does not exist: " + path.ToString());
            }

            try
            {
                File.Create(archivePath).Dispose();
            }
            catch (UnauthorizedAccessException)
            {
                throw new KOSPersistenceException("Could not create file: " + path);
            }

            return Open(path) as VolumeFile;
        }