예제 #1
0
        private bool IsConcatenationFile(DirectoryEntry entry)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return(ConcatenationFileSystem.HasConcatenationFileAttribute(entry.Attributes));
            }
            else
            {
                string name     = Util.GetUtf8StringNullTerminated(entry.Name);
                string fullPath = PathTools.Combine(Path, name);

                return(ParentFileSystem.IsConcatenationFile(fullPath));
            }
        }
예제 #2
0
        public Result Read(out long entriesRead, Span <DirectoryEntry> entryBuffer)
        {
            entriesRead = 0;
            var entry = new DirectoryEntry();
            Span <DirectoryEntry> entrySpan = SpanHelpers.AsSpan(ref entry);

            int i;

            for (i = 0; i < entryBuffer.Length; i++)
            {
                Result rc = ParentDirectory.Read(out long baseEntriesRead, entrySpan);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                if (baseEntriesRead == 0)
                {
                    break;
                }

                // Check if the current open mode says we should return the entry
                bool isConcatFile = IsConcatenationFile(entry);
                if (!CanReturnEntry(entry, isConcatFile))
                {
                    continue;
                }

                if (isConcatFile)
                {
                    entry.Type = DirectoryEntryType.File;

                    if (!Mode.HasFlag(OpenDirectoryMode.NoFileSize))
                    {
                        string entryName     = Util.GetUtf8StringNullTerminated(entry.Name);
                        string entryFullPath = PathTools.Combine(Path, entryName);

                        entry.Size = ParentFileSystem.GetConcatenationFileSize(entryFullPath);
                    }
                }

                entry.Attributes = NxFileAttributes.None;

                entryBuffer[i] = entry;
            }

            entriesRead = i;
            return(Result.Success);
        }
예제 #3
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
        }
예제 #4
0
        public int GetEntryCount()
        {
            int count = 0;

            foreach (DirectoryEntry entry in ParentDirectory.Read())
            {
                bool isSplit = ParentFileSystem.IsSplitFile(entry.FullPath);

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

            return(count);
        }
예제 #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);
            }
        }
예제 #6
0
        public IEnumerable <DirectoryEntry> Read()
        {
            foreach (DirectoryEntry entry in ParentDirectory.Read())
            {
                bool isSplit = ParentFileSystem.IsSplitFile(entry.FullPath);

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

                if (!isSplit)
                {
                    yield return(entry);
                }
                else
                {
                    long size = ParentFileSystem.GetConcatenationFileSize(entry.FullPath);
                    yield return(new DirectoryEntry(entry.Name, entry.FullPath, DirectoryEntryType.File, size));
                }
            }
        }