Exemplo n.º 1
0
 public ConcatenationDirectory(ConcatenationFileSystem fs, IDirectory parentDirectory, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     ParentDirectory  = parentDirectory;
     Mode             = mode;
     FullPath         = parentDirectory.FullPath;
 }
Exemplo n.º 2
0
        private bool IsConcatenationFile(DirectoryEntry entry)
        {
#if CROSS_PLATFORM
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return(ConcatenationFileSystem.HasConcatenationFileAttribute(entry.Attributes));
            }
            else
            {
                return(ParentFileSystem.IsConcatenationFile(entry.FullPath));
            }
#else
            return(ConcatenationFileSystem.HasConcatenationFileAttribute(entry.Attributes));
#endif
        }
Exemplo n.º 3
0
        public int GetEntryCount()
        {
            int count = 0;

            foreach (DirectoryEntry entry in ParentDirectory.Read())
            {
                bool isSplit = ConcatenationFileSystem.HasConcatenationFileAttribute(entry.Attributes);

                if (CanReturnEntry(entry, isSplit))
                {
                    count++;
                }
            }

            return(count);
        }
Exemplo n.º 4
0
        public override void SetSize(long size)
        {
            long currentSize = GetSize();

            if (currentSize == size)
            {
                return;
            }

            int currentSubFileCount = QuerySubFileCount(currentSize, SubFileSize);
            int newSubFileCount     = QuerySubFileCount(size, SubFileSize);

            if (size > currentSize)
            {
                IFile currentLastSubFile = Sources[currentSubFileCount - 1];
                long  newSubFileSize     = QuerySubFileSize(currentSubFileCount - 1, size, SubFileSize);

                currentLastSubFile.SetSize(newSubFileSize);

                for (int i = currentSubFileCount; i < newSubFileCount; i++)
                {
                    string newSubFilePath = ConcatenationFileSystem.GetSubFilePath(FilePath, i);
                    newSubFileSize = QuerySubFileSize(i, size, SubFileSize);

                    BaseFileSystem.CreateFile(newSubFilePath, newSubFileSize, CreateFileOptions.None);
                    Sources.Add(BaseFileSystem.OpenFile(newSubFilePath, Mode));
                }
            }
            else
            {
                for (int i = currentSubFileCount - 1; i > newSubFileCount - 1; i--)
                {
                    Sources[i].Dispose();
                    Sources.RemoveAt(i);

                    string subFilePath = ConcatenationFileSystem.GetSubFilePath(FilePath, i);
                    BaseFileSystem.DeleteFile(subFilePath);
                }

                long newLastFileSize = QuerySubFileSize(newSubFileCount - 1, size, SubFileSize);
                Sources[newSubFileCount - 1].SetSize(newLastFileSize);
            }
        }
Exemplo n.º 5
0
        public IEnumerable <DirectoryEntry> Read()
        {
            foreach (DirectoryEntry entry in ParentDirectory.Read())
            {
                bool isSplit = ConcatenationFileSystem.HasConcatenationFileAttribute(entry.Attributes);

                if (!CanReturnEntry(entry, isSplit))
                {
                    continue;
                }

                if (isSplit)
                {
                    entry.Type       = DirectoryEntryType.File;
                    entry.Size       = ParentFileSystem.GetConcatenationFileSize(entry.FullPath);
                    entry.Attributes = NxFileAttributes.None;
                }

                yield return(entry);
            }
        }