Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
 protected GitFileObject(GitFileSystem fileSystem, FileParameters fileParams, IRandomAccess <byte> baseRandomAccess) : base(fileSystem, fileParams, baseRandomAccess)
 {
 }