Пример #1
0
        // RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
        public ResultCode RenameFile(ServiceCtx context)
        {
            string oldName = ReadUtf8String(context, 0);
            string newName = ReadUtf8String(context, 1);

            return((ResultCode)_fileSystem.RenameFile(oldName, newName).Value);
        }
Пример #2
0
        // RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
        public ResultCode RenameFile(ServiceCtx context)
        {
            U8Span oldName = ReadUtf8Span(context, 0);
            U8Span newName = ReadUtf8Span(context, 1);

            return((ResultCode)_fileSystem.RenameFile(oldName, newName).Value);
        }
Пример #3
0
        // RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
        public long RenameFile(ServiceCtx context)
        {
            string oldName = ReadUtf8String(context, 0);
            string newName = ReadUtf8String(context, 1);

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

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

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

            try
            {
                _provider.RenameFile(oldName, newName);
            }
            catch (FileNotFoundException)
            {
                return(MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist));
            }
            catch (UnauthorizedAccessException)
            {
                Logger.PrintError(LogClass.ServiceFs, $"Unable to access {oldName} or {newName}");

                throw;
            }

            return(0);
        }
Пример #4
0
        // RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
        public long RenameFile(ServiceCtx context)
        {
            string oldName = ReadUtf8String(context, 0);
            string newName = ReadUtf8String(context, 1);

            try
            {
                _fileSystem.RenameFile(oldName, newName);
            }
            catch (HorizonResultException ex)
            {
                return(ex.ResultValue.Value);
            }

            return(0);
        }