GitSharp.Core.DirectoryCache.DirCacheEntry.write C# (CSharp) Method

write() public method

public write ( Stream os ) : void
os Stream
return void
        public void write(Stream os)
        {
            int pathLen = _path.Length;
            os.Write(_info, _infoOffset, INFO_LEN);
            os.Write(_path, 0, pathLen);

            // Index records are padded out to the next 8 byte alignment
            // for historical reasons related to how C Git Read the files.
            //
            int actLen = INFO_LEN + pathLen;
            int expLen = (actLen + 8) & ~7;
            if (actLen != expLen)
            {
                os.Write(NullPad, 0, expLen - actLen);
            }
        }

Usage Example

Example #1
0
        private void WriteTo(Stream os)
        {
            MessageDigest foot = Constants.newMessageDigest();
            var           dos  = new DigestOutputStream(os, foot);

            // Write the header.
            //
            var tmp = new byte[128];

            Array.Copy(SigDirc, 0, tmp, 0, SigDirc.Length);
            NB.encodeInt32(tmp, 4, /* version */ 2);
            NB.encodeInt32(tmp, 8, _entryCnt);
            dos.Write(tmp, 0, 12);

            // Write the individual file entries.
            //
            if (_lastModified <= 0)
            {
                // Write a new index, as no entries require smudging.
                //
                for (int i = 0; i < _entryCnt; i++)
                {
                    _sortedEntries[i].write(dos);
                }
            }
            else
            {
                int smudge_s  = (int)(_lastModified / 1000);
                int smudge_ns = ((int)(_lastModified % 1000)) * 1000000;
                for (int i = 0; i < _entryCnt; i++)
                {
                    DirCacheEntry e = _sortedEntries[i];
                    if (e.mightBeRacilyClean(smudge_s, smudge_ns))
                    {
                        e.smudgeRacilyClean();
                    }
                    e.write(dos);
                }
            }

            if (_cacheTree != null)
            {
                var bb = new LocalFileBuffer();
                _cacheTree.write(tmp, bb);
                bb.close();

                NB.encodeInt32(tmp, 0, ExtTree);
                NB.encodeInt32(tmp, 4, (int)bb.Length);
                dos.Write(tmp, 0, 8);
                bb.writeTo(dos, null);
            }
            var hash = foot.Digest();

            os.Write(hash, 0, hash.Length);
            os.Close();
        }
All Usage Examples Of GitSharp.Core.DirectoryCache.DirCacheEntry::write