Example #1
0
        // CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
        public ResultCode CreateFile(ServiceCtx context)
        {
            string name = ReadUtf8String(context);

            CreateFileOptions createOption = (CreateFileOptions)context.RequestData.ReadInt32();

            context.RequestData.BaseStream.Position += 4;

            long size = context.RequestData.ReadInt64();

            return((ResultCode)_fileSystem.CreateFile(name, size, createOption).Value);
        }
Example #2
0
        // CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
        public long CreateFile(ServiceCtx context)
        {
            string name = ReadUtf8String(context);

            CreateFileOptions createOption = (CreateFileOptions)context.RequestData.ReadInt32();

            context.RequestData.BaseStream.Position += 4;

            long size = context.RequestData.ReadInt64();

            if (name == null)
            {
                return(MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist));
            }

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

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

            try
            {
                _provider.CreateFile(name, size, createOption);
            }
            catch (DirectoryNotFoundException)
            {
                return(MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist));
            }
            catch (UnauthorizedAccessException)
            {
                Logger.PrintError(LogClass.ServiceFs, $"Unable to access {name}");

                throw;
            }

            return(0);
        }
Example #3
0
        // CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
        public long CreateFile(ServiceCtx context)
        {
            string name = ReadUtf8String(context);

            CreateFileOptions createOption = (CreateFileOptions)context.RequestData.ReadInt32();

            context.RequestData.BaseStream.Position += 4;

            long size = context.RequestData.ReadInt64();

            try
            {
                _fileSystem.CreateFile(name, size, createOption);
            }
            catch (HorizonResultException ex)
            {
                return(ex.ResultValue.Value);
            }

            return(0);
        }