public static async Task <FileObject> CreateFileAsync(GitFileSystem fileSystem, FileParameters fileParams, CancellationToken cancel = default) { if (fileParams.Access.Bit(FileAccess.Write)) { throw new FileException(fileParams.Path, "The git filesystem is read-only."); } if (fileParams.Mode != FileMode.Open) { throw new FileException(fileParams.Path, "The git filesystem is read-only."); } cancel.ThrowIfCancellationRequested(); Blob blob = fileSystem.Commit.GetFile(fileParams.Path); Stream stream = blob.GetContentStream(); IRandomAccess <byte> randomAccess = new SeekableStreamBasedRandomAccess(stream, true); try { GitFileObject f = new GitFileObject(fileSystem, fileParams, randomAccess); await Task.CompletedTask; return(f); } catch { randomAccess._DisposeSafe(); stream._DisposeSafe(); throw; } }
protected override Task <FileObject> CreateFileImplAsync(FileParameters option, CancellationToken cancel = default) => GitFileObject.CreateFileAsync(this, option, cancel);