예제 #1
0
        // OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
        public long OpenDirectory(ServiceCtx context)
        {
            OpenDirectoryMode mode = (OpenDirectoryMode)context.RequestData.ReadInt32();

            string name = ReadUtf8String(context);

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

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

            IDirectory dirInterface;

            try
            {
                LibHac.Fs.IDirectory dir = _provider.OpenDirectory(name, mode);

                dirInterface = new IDirectory(dir);
            }
            catch (UnauthorizedAccessException)
            {
                Logger.PrintError(LogClass.ServiceFs, $"Unable to access {name}");

                throw;
            }

            dirInterface.Disposed += RemoveDirectoryInUse;

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

            MakeObject(context, dirInterface);

            return(0);
        }
예제 #2
0
        // OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
        public long OpenDirectory(ServiceCtx context)
        {
            OpenDirectoryMode mode = (OpenDirectoryMode)context.RequestData.ReadInt32();

            string name = ReadUtf8String(context);

            try
            {
                LibHac.Fs.IDirectory dir = _fileSystem.OpenDirectory(name, mode);

                IDirectory dirInterface = new IDirectory(dir);

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

            return(0);
        }
예제 #3
0
 public IDirectory(LibHac.Fs.IDirectory directory)
 {
     _baseDirectory = directory;
 }