kOS.Safe.Persistence.Volume.IsRoomFor C# (CSharp) Method

IsRoomFor() public method

public IsRoomFor ( VolumePath path, FileContent fileContent ) : bool
path VolumePath
fileContent FileContent
return bool
        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;
        }