public VolumeFile OpenOrCreateFile(VolumePath path, bool ksmDefault = false) { VolumeFile file = Open(path, ksmDefault) as VolumeFile; if (file == null) { file = CreateFile(path); } return(file); }
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); }
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); }
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); }
public VolumeFile SaveFile(VolumeFile volumeFile) { return(SaveFile(volumeFile.Path, volumeFile.ReadAll())); }
//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())); }
private int FileInfoComparer(VolumeFile a, VolumeFile b) { return(string.CompareOrdinal(a.Name, b.Name)); }
protected bool CopyFileToDirectory(VolumeFile volumeFile, VolumeDirectory volumeDirectory, bool verifyFreeSpace) { return(volumeDirectory.Volume.SaveFile(volumeDirectory.Path.Combine(volumeFile.Name), volumeFile.ReadAll(), verifyFreeSpace) != null); }
protected bool CopyFile(VolumeFile volumeFile, GlobalPath destinationPath, Volume targetVolume, bool verifyFreeSpace) { return(targetVolume.SaveFile(destinationPath, volumeFile.ReadAll(), verifyFreeSpace) != null); }