Inheritance: VolumeItem
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #5
0
 public VolumeFile SaveFile(VolumeFile volumeFile)
 {
     return(SaveFile(volumeFile.Path, volumeFile.ReadAll()));
 }
Example #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()));
        }
Example #7
0
 private int FileInfoComparer(VolumeFile a, VolumeFile b)
 {
     return(string.CompareOrdinal(a.Name, b.Name));
 }
Example #8
0
 protected bool CopyFileToDirectory(VolumeFile volumeFile, VolumeDirectory volumeDirectory,
                                    bool verifyFreeSpace)
 {
     return(volumeDirectory.Volume.SaveFile(volumeDirectory.Path.Combine(volumeFile.Name), volumeFile.ReadAll(),
                                            verifyFreeSpace) != null);
 }
Example #9
0
 protected bool CopyFile(VolumeFile volumeFile, GlobalPath destinationPath, Volume targetVolume,
                         bool verifyFreeSpace)
 {
     return(targetVolume.SaveFile(destinationPath, volumeFile.ReadAll(), verifyFreeSpace) != null);
 }