示例#1
0
        private static void SeekToBeginOfBlobName(FileLocation location, Stream stream)
        {
            var idx = 1;

            while (true)
            {
                stream.Seek(location.DataStartOffset - idx, SeekOrigin.Begin);
                var b = stream.ReadByte();
                if (b == 0 && idx == 1)
                {
                    idx += 8;
                    continue;
                }
                if (b == 0 || b == 1)
                {
                    break;
                }
                idx++;
            }
        }
示例#2
0
        // must hold lock
        internal long Commit(bool perfect)
        {
            if (lastFileCommitted)
            {
                return(ms.Length);
            }

            ms.Seek(startOfBlobHeader, SeekOrigin.Begin);
            var length     = (int)ms.Length;
            var blobLength = length - startOfBlobData;

            ms.WriteByte((byte)(blobLength >> 0));
            ms.WriteByte((byte)(blobLength >> 8));
            ms.WriteByte((byte)(blobLength >> 16));
            ms.WriteByte((byte)(blobLength >> 24));
            ms.Seek(2, SeekOrigin.Current);
            ms.WriteByte(perfect ? (byte)1 : (byte)0);
            ms.Seek(length, SeekOrigin.Begin);
            if (perfect)
            {
                lastCommittedLength = length;
                var location = new FileLocation()
                {
                    BlobName        = currentFileName,
                    PackageFileName = this.fileName,
                    DataStartOffset = (int)startOfBlobData,
                    Package         = this,
                    Length          = length - (int)startOfBlobData,
                    Date            = currentFileTime
                };
                directory.locations[currentFileName] = location;
                directory.locationsToAdd.Add(location);
            }
            lastFileCommitted = true;
            return(length);
        }
示例#3
0
 // must hold lock
 internal long Commit(bool perfect)
 {
     ms.Seek(startOfBlobHeader, SeekOrigin.Begin);
     var length = (int)ms.Length;
     var blobLength = length - startOfBlobData;
     ms.WriteByte((byte)(blobLength >> 0));
     ms.WriteByte((byte)(blobLength >> 8));
     ms.WriteByte((byte)(blobLength >> 16));
     ms.WriteByte((byte)(blobLength >> 24));
     ms.Seek(2, SeekOrigin.Current);
     ms.WriteByte(perfect ? (byte)1 : (byte)0);
     ms.Seek(length, SeekOrigin.Begin);
     if (perfect)
     {
         lastCommittedLength = length;
         var location = new FileLocation()
         {
             BlobName = currentFileName,
             PackageFileName = this.fileName,
             DataStartOffset = (int)startOfBlobData,
             Package = this,
             Length = length - (int)startOfBlobData
         };
         directory.locations[currentFileName] = location;
         directory.locationsToAdd.Add(location);
     }
     return length;
 }
示例#4
0
 private static void SeekToBeginOfBlobName(FileLocation location, Stream stream)
 {
     var idx = 1;
     while (true)
     {
         stream.Seek(location.DataStartOffset - idx, SeekOrigin.Begin);
         var b = stream.ReadByte();
         if (b == 0 || b == 1) break;
         idx++;
     }
 }