Example #1
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));
                }
            }
        }
Example #2
0
        // OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
        public long OpenFile(ServiceCtx context)
        {
            OpenMode mode = (OpenMode)context.RequestData.ReadInt32();

            string name = ReadUtf8String(context);

            if (!_provider.FileExists(name))
            {
                return(MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist));
            }

            if (IsPathAlreadyInUse(name))
            {
                return(MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse));
            }

            IFile fileInterface;

            try
            {
                LibHac.Fs.IFile file = _provider.OpenFile(name, mode);

                fileInterface = new IFile(file, name);
            }
            catch (UnauthorizedAccessException)
            {
                Logger.PrintError(LogClass.ServiceFs, $"Unable to access {name}");

                throw;
            }

            fileInterface.Disposed += RemoveFileInUse;

            lock (_openPaths)
            {
                _openPaths.Add(fileInterface.Path);
            }

            MakeObject(context, fileInterface);

            return(0);
        }
Example #3
0
        // OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
        public long OpenFile(ServiceCtx context)
        {
            OpenMode mode = (OpenMode)context.RequestData.ReadInt32();

            string name = ReadUtf8String(context);

            try
            {
                LibHac.Fs.IFile file = _fileSystem.OpenFile(name, mode);

                IFile fileInterface = new IFile(file);

                MakeObject(context, fileInterface);
            }
            catch (HorizonResultException ex)
            {
                return(ex.ResultValue.Value);
            }

            return(0);
        }