Ejemplo n.º 1
0
        public void CreateFile(string path, long size, CreateFileOptions options)
        {
            path = PathTools.Normalize(path);

            if (size == 0)
            {
                var emptyFileEntry = new SaveFileInfo {
                    StartBlock = int.MinValue, Length = size
                };
                FileTable.AddFile(path, ref emptyFileEntry);

                return;
            }

            int blockCount = (int)Util.DivideByRoundUp(size, AllocationTable.Header.BlockSize);
            int startBlock = AllocationTable.Allocate(blockCount);

            if (startBlock == -1)
            {
                throw new IOException("Not enough available space to create file.");
            }

            var fileEntry = new SaveFileInfo {
                StartBlock = startBlock, Length = size
            };

            FileTable.AddFile(path, ref fileEntry);
        }