public IFile(LibHac.Fs.IFile baseFile, string path) { _commands = new Dictionary <int, ServiceProcessRequest> { { 0, Read }, { 1, Write }, { 2, Flush }, { 3, SetSize }, { 4, GetSize } }; _baseFile = baseFile; Path = LibHac.Fs.PathTools.Normalize(path); }
// 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); }
// 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); }
public IFile(LibHac.Fs.IFile baseFile) { _baseFile = baseFile; }
public IFile(LibHac.Fs.IFile backing) => Backing = backing;