/// <exception cref="System.IO.IOException"></exception> /// <exception cref="NGit.Errors.MissingObjectException"></exception> private void EnsureLoaded() { if (!IsLoaded()) { ObjectLoader ldr = db.Open(GetId(), Constants.OBJ_TREE); ReadTree(ldr.GetCachedBytes()); } }
/// <summary>Check out content of the specified index entry</summary> /// <param name="wd">workdir</param> /// <param name="e">index entry</param> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> public virtual void CheckoutEntry(FilePath wd, GitIndex.Entry e) { ObjectLoader ol = db.Open(e.sha1, Constants.OBJ_BLOB); FilePath file = new FilePath(wd, e.GetName()); file.Delete(); FileUtils.Mkdirs(file.GetParentFile(), true); FileOutputStream dst = new FileOutputStream(file); try { ol.CopyTo(dst); } finally { dst.Close(); } if (Config_filemode() && File_hasExecute()) { if (FileMode.EXECUTABLE_FILE.Equals(e.mode)) { if (!File_canExecute(file)) { File_setExecute(file, true); } } else { if (File_canExecute(file)) { File_setExecute(file, false); } } } e.mtime = file.LastModified() * 1000000L; e.ctime = e.mtime; }
public _DeltaStream_223(ObjectLoader @base, WindowCursor wc, InputStream baseArg1 ) : base(baseArg1) { this.@base = @base; this.wc = wc; this.baseSize = NGit.Storage.File.LargePackedDeltaObject.SIZE_UNKNOWN; }
/// <exception cref="System.IO.IOException"></exception> private void Copy(TemporaryBuffer.Heap tinyPack, ObjectLoader ldr) { byte[] buf = new byte[64]; byte[] content = ldr.GetCachedBytes(); int dataLength = content.Length; int nextLength = (int)(((uint)dataLength) >> 4); int size = 0; buf[size++] = unchecked((byte)((nextLength > 0 ? unchecked((int)(0x80)) : unchecked( (int)(0x00))) | (ldr.GetType() << 4) | (dataLength & unchecked((int)(0x0F))))); dataLength = nextLength; while (dataLength > 0) { nextLength = (int)(((uint)nextLength) >> 7); buf[size++] = unchecked((byte)((nextLength > 0 ? unchecked((int)(0x80)) : unchecked( (int)(0x00))) | (dataLength & unchecked((int)(0x7F))))); dataLength = nextLength; } tinyPack.Write(buf, 0, size); Deflate(tinyPack, content); }
/// <exception cref="NGit.Errors.MissingObjectException"></exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception> /// <exception cref="System.IO.IOException"></exception> private static byte[] Read(ObjectReader or, AnyObjectId blobId) { ObjectLoader loader = or.Open(blobId, Constants.OBJ_BLOB); return(loader.GetCachedBytes(int.MaxValue)); }
/// <summary>Create the stream from an existing loader's cached bytes.</summary> /// <remarks>Create the stream from an existing loader's cached bytes.</remarks> /// <param name="loader">the loader.</param> public SmallStream(ObjectLoader loader) : this(loader.GetType(), loader.GetCachedBytes ()) { }
/// <exception cref="NGit.Errors.MissingObjectException"></exception> /// <exception cref="System.IO.IOException"></exception> /// <exception cref="NGit.Diff.SimilarityIndex.TableFullException"></exception> internal virtual void Hash(ObjectLoader obj) { if (obj.IsLarge()) { ObjectStream @in = obj.OpenStream(); try { SetFileSize(@in.GetSize()); Hash(@in, fileSize); } finally { @in.Close(); } } else { byte[] raw = obj.GetCachedBytes(); SetFileSize(raw.Length); Hash(raw, 0, raw.Length); } }