Inheritance: VolumeItem
Beispiel #1
0
        public VolumeFile OpenOrCreateFile(VolumePath path, bool ksmDefault = false)
        {
            VolumeFile file = Open(path, ksmDefault) as VolumeFile;

            if (file == null)
            {
                file = CreateFile(path);
            }

            return(file);
        }
Beispiel #2
0
        public bool IsRoomFor(string name, FileContent fileContent)
        {
            VolumeFile existingFile = Open(name);

            int usedByThisFile = 0;

            if (existingFile != null)
            {
                usedByThisFile = existingFile.ReadAll().Size;
            }

            return(INFINITE_CAPACITY == FreeSpace || FreeSpace + usedByThisFile >= fileContent.Size);
        }
Beispiel #3
0
        public override bool RenameFile(string name, string newName)
        {
            VolumeFile file = Open(name);

            if (file != null)
            {
                // Add the original file content under the new name
                files.Add(newName, files[file.Name]);
                // Then remove the old file content under the old name
                files.Remove(file.Name);
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public bool IsRoomFor(VolumePath path, FileContent fileContent)
        {
            VolumeItem existing = Open(path);

            if (existing is VolumeDirectory)
            {
                throw new KOSPersistenceException("'" + path + "' is a directory");
            }

            VolumeFile existingFile = existing as VolumeFile;

            int usedByThisFile = 0;

            if (existingFile != null)
            {
                usedByThisFile = existingFile.ReadAll().Size;
            }

            return(INFINITE_CAPACITY == FreeSpace || FreeSpace + usedByThisFile >= fileContent.Size);
        }
Beispiel #5
0
 public VolumeFile SaveFile(VolumeFile volumeFile)
 {
     return(SaveFile(volumeFile.Path, volumeFile.ReadAll()));
 }
Beispiel #6
0
        //public abstract bool AppendToFile(string name, string textToAppend);

        //public abstract bool AppendToFile(string name, byte[] bytesToAppend);

        public VolumeFile Save(VolumeFile volumeFile)
        {
            return(Save(volumeFile.Name, volumeFile.ReadAll()));
        }
Beispiel #7
0
 private int FileInfoComparer(VolumeFile a, VolumeFile b)
 {
     return(string.CompareOrdinal(a.Name, b.Name));
 }
Beispiel #8
0
 protected bool CopyFileToDirectory(VolumeFile volumeFile, VolumeDirectory volumeDirectory,
                                    bool verifyFreeSpace)
 {
     return(volumeDirectory.Volume.SaveFile(volumeDirectory.Path.Combine(volumeFile.Name), volumeFile.ReadAll(),
                                            verifyFreeSpace) != null);
 }
Beispiel #9
0
 protected bool CopyFile(VolumeFile volumeFile, GlobalPath destinationPath, Volume targetVolume,
                         bool verifyFreeSpace)
 {
     return(targetVolume.SaveFile(destinationPath, volumeFile.ReadAll(), verifyFreeSpace) != null);
 }