Ejemplo n.º 1
0
        public FileSystemAccessor(FileSystemClient fsClient, U8Span name, IMultiCommitTarget multiCommitTarget,
                                  IFileSystem fileSystem, ICommonMountNameGenerator mountNameGenerator,
                                  ISaveDataAttributeGetter saveAttributeGetter)
        {
            FsClient = fsClient;

            _fileSystem      = fileSystem;
            _openFiles       = new LinkedList <FileAccessor>();
            _openDirectories = new LinkedList <DirectoryAccessor>();
            _openListLock.Initialize();
            _mountNameGenerator      = mountNameGenerator;
            _saveDataAttributeGetter = saveAttributeGetter;
            _multiCommitTarget       = multiCommitTarget;

            if (name.IsEmpty())
            {
                Abort.DoAbort(ResultFs.InvalidMountName.Log());
            }

            if (StringUtils.GetLength(name, PathTool.MountNameLengthMax + 1) > PathTool.MountNameLengthMax)
            {
                Abort.DoAbort(ResultFs.InvalidMountName.Log());
            }

            StringUtils.Copy(_mountName.Name.Slice(0, PathTool.MountNameLengthMax), name);
            _mountName.Name[PathTool.MountNameLengthMax] = 0;
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (_lastResult.IsSuccess() && _writeState == WriteState.NeedsFlush)
            {
                Abort.DoAbort(ResultFs.NeedFlush.Log(), "File needs flush before closing.");
            }

            _parentFileSystem?.NotifyCloseFile(this);
            _file?.Dispose();

            _file = null;
        }
Ejemplo n.º 3
0
        internal static void AbortIfNeeded(this FileSystemClientImpl fs, Result result,
                                           [CallerMemberName] string functionName = "")
        {
            if (!IsAbortNeeded(fs, result))
            {
                return;
            }

            fs.LogResultErrorMessage(result, functionName);

            if (!result.IsSuccess())
            {
                Abort.DoAbort(result);
            }
        }
Ejemplo n.º 4
0
        public void Unmount(U8Span name)
        {
            using ScopedLock <SdkMutexType> lk = ScopedLock.Lock(ref _mutex);

            LinkedListNode <FileSystemAccessor> currentNode;

            for (currentNode = _fileSystemList.First; currentNode is not null; currentNode = currentNode.Next)
            {
                if (Matches(currentNode.Value, name))
                {
                    break;
                }
            }

            if (currentNode is null)
            {
                Abort.DoAbort(ResultFs.NotMounted.Log(), $"{name.ToString()} is not mounted.");
            }

            _fileSystemList.Remove(currentNode);
            currentNode.Value.Dispose();
        }