Пример #1
0
        public IFileSystem(LibHac.Fs.IFileSystem provider)
        {
            _commands = new Dictionary <int, ServiceProcessRequest>
            {
                { 0, CreateFile },
                { 1, DeleteFile },
                { 2, CreateDirectory },
                { 3, DeleteDirectory },
                { 4, DeleteDirectoryRecursively },
                { 5, RenameFile },
                { 6, RenameDirectory },
                { 7, GetEntryType },
                { 8, OpenFile },
                { 9, OpenDirectory },
                { 10, Commit },
                { 11, GetFreeSpaceSize },
                { 12, GetTotalSpaceSize },
                { 13, CleanDirectoryRecursively },
                { 14, GetFileTimeStampRaw }
            };

            _openPaths = new HashSet <string>();

            _provider = provider;
        }
Пример #2
0
        private void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)
        {
            foreach (DirectoryEntry ticketEntry in nsp.EnumerateEntries("*.tik"))
            {
                Ticket ticket = new Ticket(nsp.OpenFile(ticketEntry.FullPath, OpenMode.Read).AsStream());

                if (!keySet.TitleKeys.ContainsKey(ticket.RightsId))
                {
                    keySet.TitleKeys.Add(ticket.RightsId, ticket.GetTitleKey(keySet));
                }
            }
        }
Пример #3
0
        public static void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)
        {
            foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
            {
                Result result = nsp.OpenFile(out LibHac.Fs.IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);

                if (result.IsSuccess())
                {
                    Ticket ticket = new Ticket(ticketFile.AsStream());

                    keySet.ExternalKeySet.Add(new RightsId(ticket.RightsId), new AccessKey(ticket.GetTitleKey(keySet)));
                }
            }
        }
Пример #4
0
        private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
        {
            Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);

            if (!nca.SectionExists(NcaSectionType.Data))
            {
                return(MakeError(ErrorModule.Fs, FsErr.PartitionNotFound));
            }

            LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);

            MakeObject(context, new IFileSystem(fileSystem));

            return(0);
        }
Пример #5
0
        private ResultCode OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
        {
            try
            {
                Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);

                if (!nca.SectionExists(NcaSectionType.Data))
                {
                    return(ResultCode.PartitionNotFound);
                }

                LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);

                MakeObject(context, new IFileSystem(fileSystem));
            }
            catch (HorizonResultException ex)
            {
                return((ResultCode)ex.ResultValue.Value);
            }

            return(ResultCode.Success);
        }
Пример #6
0
        public static ResultCode LoadSaveDataFileSystem(ServiceCtx context, bool readOnly, out IFileSystem loadedFileSystem)
        {
            loadedFileSystem = null;

            SaveSpaceId  saveSpaceId  = (SaveSpaceId)context.RequestData.ReadInt64();
            ulong        titleId      = context.RequestData.ReadUInt64();
            UInt128      userId       = context.RequestData.ReadStruct <UInt128>();
            long         saveId       = context.RequestData.ReadInt64();
            SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte();
            SaveInfo     saveInfo     = new SaveInfo(titleId, saveId, saveDataType, saveSpaceId, userId);
            string       savePath     = context.Device.FileSystem.GetSavePath(context, saveInfo);

            try
            {
                LocalFileSystem fileSystem = new LocalFileSystem(savePath);

                Result result = DirectorySaveDataFileSystem.CreateNew(out DirectorySaveDataFileSystem dirFileSystem, fileSystem);
                if (result.IsFailure())
                {
                    return((ResultCode)result.Value);
                }

                LibHac.Fs.IFileSystem saveFileSystem = dirFileSystem;

                if (readOnly)
                {
                    saveFileSystem = new ReadOnlyFileSystem(saveFileSystem);
                }

                loadedFileSystem = new IFileSystem(saveFileSystem);
            }
            catch (HorizonResultException ex)
            {
                return((ResultCode)ex.ResultValue.Value);
            }

            return(ResultCode.Success);
        }
Пример #7
0
 public IFileSystem(LibHac.Fs.IFileSystem provider)
 {
     _fileSystem = provider;
 }
Пример #8
0
 public IFileSystem(LibHac.Fs.IFileSystem backing) => Backing = backing;