• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PackFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PackFile的典型用法代码示例。如果您正苦于以下问题:C# PackFile类的具体用法?C# PackFile怎么用?C# PackFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PackFile类属于命名空间,在下文中一共展示了PackFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: test000_FirstPack

        public void test000_FirstPack()
        {
            FileInfo packFile = getPack("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
            Stream @is = packFile.Open(System.IO.FileMode.Open, FileAccess.Read);
            try
            {
                FileInfo tmppack = new FileInfo(Path.Combine(trash.ToString(), "tmp_pack1"));
                FileInfo idxFile = new FileInfo(Path.Combine(trash.ToString(), "tmp_pack1.idx"));
                FileInfo tmpPackFile = new FileInfo(Path.Combine(trash.ToString(), "tmp_pack1.pack"));

                tmppack.Create().Close();
                idxFile.Create().Close();
                tmpPackFile.Create().Close();

                IndexPack pack = new IndexPack(db, @is, tmppack);
                pack.index(new TextProgressMonitor());
                PackFile file = new PackFile(idxFile, tmpPackFile);

                Assert.IsTrue(file.HasObject(ObjectId.FromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035")));
                Assert.IsTrue(file.HasObject(ObjectId.FromString("c59759f143fb1fe21c197981df75a7ee00290799")));
            }
            finally
            {
                @is.Close();
            }
        }
开发者ID:gilran,项目名称:GitSharp,代码行数:32,代码来源:IndexPackTests.cs


示例2: NewWhole

		internal static LocalObjectRepresentation NewWhole(PackFile f, long p, long length
			)
		{
			LocalObjectRepresentation r = new _LocalObjectRepresentation_53();
			r.pack = f;
			r.offset = p;
			r.length = length;
			return r;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:9,代码来源:LocalObjectRepresentation.cs


示例3: PackInputStream

		/// <exception cref="System.IO.IOException"></exception>
		internal PackInputStream(PackFile pack, long pos, WindowCursor wc)
		{
			this.pack = pack;
			this.pos = pos;
			this.wc = wc;
			// Pin the first window, to ensure the pack is open and valid.
			//
			wc.Pin(pack, pos);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:PackInputStream.cs


示例4: LargePackedWholeObject

		internal LargePackedWholeObject(int type, long size, long objectOffset, int headerLength
			, PackFile pack, FileObjectDatabase db)
		{
			this.type = type;
			this.size = size;
			this.objectOffset = objectOffset;
			this.headerLength = headerLength;
			this.pack = pack;
			this.db = db;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:LargePackedWholeObject.cs


示例5: NewDelta

		internal static LocalObjectRepresentation NewDelta(PackFile f, long p, long n, ObjectId
			 @base)
		{
			LocalObjectRepresentation r = new LocalObjectRepresentation.Delta();
			r.pack = f;
			r.offset = p;
			r.length = n;
			r.baseId = @base;
			return r;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:LocalObjectRepresentation.cs


示例6: test003_lookupCompressedObject

 public void test003_lookupCompressedObject()
 {
     ObjectId id = ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327");
     var pr = new PackFile(TestIdx, TestPack);
     PackedObjectLoader or = pr.Get(new WindowCursor(), id);
     Assert.IsNotNull(or);
     Assert.AreEqual(Constants.OBJ_TREE, or.Type);
     Assert.AreEqual(35, or.Size);
     Assert.AreEqual(7738, or.DataOffset);
     pr.Close();
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:11,代码来源:PackReaderTests.cs


示例7: LargePackedDeltaObject

		internal LargePackedDeltaObject(long objectOffset, long baseOffset, int headerLength
			, PackFile pack, FileObjectDatabase db)
		{
			this.type = Constants.OBJ_BAD;
			this.size = SIZE_UNKNOWN;
			this.objectOffset = objectOffset;
			this.baseOffset = baseOffset;
			this.headerLength = headerLength;
			this.pack = pack;
			this.db = db;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:11,代码来源:LargePackedDeltaObject.cs


示例8: Test003_lookupCompressedObject

		public virtual void Test003_lookupCompressedObject()
		{
			PackFile pr;
			ObjectId id;
			ObjectLoader or;
			id = ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327");
			pr = new PackFile(TEST_IDX, TEST_PACK);
			or = pr.Get(new WindowCursor(null), id);
			NUnit.Framework.Assert.IsNotNull(or);
			NUnit.Framework.Assert.AreEqual(Constants.OBJ_TREE, or.GetType());
			NUnit.Framework.Assert.AreEqual(35, or.GetSize());
			pr.Close();
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:13,代码来源:T0004_PackReaderTest.cs


示例9: get

 public static Entry get(PackFile pack, long position)
 {
     Slot e = Cache[Hash(position)];
     if (e.provider == pack && e.position == position)
     {
         Entry buf = e.data.get();
         if (buf != null)
         {
             MoveToHead(e);
             return buf;
         }
     }
     return null;
 }
开发者ID:drothmaler,项目名称:GitSharp,代码行数:14,代码来源:UnpackedObjectCache.cs


示例10: Copy

 /// <summary>
 /// Copy bytes from the window to a caller supplied buffer.
 /// </summary>
 /// <param name="pack">The file the desired window is stored within.</param>
 /// <param name="position">Position within the file to read from.</param>
 /// <param name="dstbuf">Destination buffer to copy into.</param>
 /// <param name="dstoff">Offset within <paramref name="dstbuf"/> to start copying into.</param>
 /// <param name="cnt">
 /// The number of bytes to copy. This value may exceed the number of
 /// bytes remaining in the window starting at offset <paramref name="position"/>.
 /// </param>
 /// <returns>
 /// number of bytes actually copied; this may be less than
 /// <paramref name="cnt"/> if <paramref name="cnt"/> exceeded the number of
 /// bytes available.
 /// </returns>
 /// <remarks>
 /// This cursor does not match the provider or id and the proper 
 /// window could not be acquired through the provider's cache.
 /// </remarks>
 public int Copy(PackFile pack, long position, byte[] dstbuf, int dstoff, int cnt)
 {
     long length = pack.Length;
     int need = cnt;
     while (need > 0 && position < length)
     {
         Pin(pack, position);
         int r = _byteWindow.copy(position, dstbuf, dstoff, need);
         position += r;
         dstoff += r;
         need -= r;
     }
     return cnt - need;
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:34,代码来源:WindowCursor.cs


示例11: test003_lookupCompressedObject

        public void test003_lookupCompressedObject()
        {
            PackFile pr;
            ObjectId id;
            PackedObjectLoader or;

            id = ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327");
            pr = new PackFile(TEST_IDX, TEST_PACK);
            or = pr.Get(new WindowCursor(), id);
            Assert.IsNotNull(or);
            Assert.AreEqual(Constants.OBJ_TREE, or.getType());
            Assert.AreEqual(35, or.getSize());
            Assert.AreEqual(7738, or.getDataOffset());
            pr.Close();
        }
开发者ID:stephensong,项目名称:GitSharp,代码行数:15,代码来源:PackReaderTests.cs


示例12: insertPack

 private void insertPack(PackFile pf)
 {
     PackFile[] o, n;
     do
     {
         o = packs();
         n = new PackFile[1 + o.Length];
         n[0] = pf;
         Array.Copy(o, 0, n, 1, o.Length);
     } while (!packList.compareAndSet(o, n));
 }
开发者ID:ArildF,项目名称:GitSharp,代码行数:11,代码来源:ObjectDirectory.cs


示例13: reuseMap

        private static Dictionary<string, PackFile> reuseMap(PackFile[] old)
        {
            Dictionary<string, PackFile> forReuse = new Dictionary<string, PackFile>();
            foreach (PackFile p in old)
            {
                if (p.IsInvalid)
                {
                    // The pack instance is corrupted, and cannot be safely used
                    // again. Do not include it in our reuse map.
                    //
                    p.Close();
                    continue;
                }

                PackFile prior = forReuse[p.File.Name] = p;
                if (prior != null)
                {
                    // This should never occur. It should be impossible for us
                    // to have two pack files with the same name, as all of them
                    // came out of the same directory. If it does, we promised to
                    // close any PackFiles we did not reuse, so close the one we
                    // just evicted out of the reuse map.
                    //
                    prior.Close();
                }
            }
            return forReuse;
        }
开发者ID:ArildF,项目名称:GitSharp,代码行数:28,代码来源:ObjectDirectory.cs


示例14: inList

 private static bool inList(PackFile[] list, PackFile pack)
 {
     foreach (PackFile p in list)
     {
         if (p == pack)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:ArildF,项目名称:GitSharp,代码行数:11,代码来源:ObjectDirectory.cs


示例15: DeltaOfsPackedObjectLoader

 public DeltaOfsPackedObjectLoader(PackFile pr, long dataOffset, long objectOffset, int deltaSz, long @base)
     : base(pr, dataOffset, objectOffset, deltaSz)
 {
     _deltaBase = @base;
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:5,代码来源:DeltaOfsPackedObjectLoader.cs


示例16: LongWrapper

            private volatile LongWrapper _lastRead = new LongWrapper();

            #endregion Fields

            #region Constructors

            public PackList(long lastRead, long lastModified, PackFile[] packs)
开发者ID:stschake,项目名称:GitSharp,代码行数:7,代码来源:ObjectDirectory.cs


示例17: AlternateRepositoryDatabase

                Repository db = RepositoryCache.open(RepositoryCache.FileKey.exact(parent));
                return new AlternateRepositoryDatabase(db);
            }
            return new ObjectDirectory(objdir, null);
        }

        private void RemovePack(PackFile deadPack)
        {
            PackList o, n;
            do
            {
                o = _packList.get();
                PackFile[] oldList = o.packs;
                int j = indexOf(oldList, deadPack);
                if (j < 0)
                    break;
                var newList = new PackFile[oldList.Length - 1];
开发者ID:stschake,项目名称:GitSharp,代码行数:17,代码来源:ObjectDirectory.cs


示例18: WholePackedObjectLoader

 public WholePackedObjectLoader(PackFile pr, long dataOffset, long objectOffset, int type, int size)
     : base(pr, dataOffset, objectOffset)
 {
     Type = type;
     Size = size;
 }
开发者ID:linquize,项目名称:GitSharp,代码行数:6,代码来源:WholePackedObjectLoader.cs


示例19: scanPacksImpl

        private PackFile[] scanPacksImpl(PackFile[] old)
        {
            Dictionary<string, PackFile> forReuse = reuseMap(old);
            string[] idxList = listPackIdx();
            List<PackFile> list = new List<PackFile>(idxList.Length);
            foreach (string indexName in idxList)
            {
                string @base = indexName.Slice(0, indexName.Length - 4);
                string packName = @base + ".pack";

                PackFile oldPack = null;
                forReuse.TryGetValue(packName, out oldPack);
                forReuse.Remove(packName);
                if (oldPack != null)
                {
                    list.Add(oldPack);
                    continue;
                }

                var packFile = new FileInfo(packDirectory.FullName + "/" + packName);
                if (!packFile.Exists)
                {
                    // Sometimes C Git's HTTP fetch transport leaves a
                    // .idx file behind and does not download the .pack.
                    // We have to skip over such useless indexes.
                    //
                    continue;
                }

                var idxFile = new FileInfo(packDirectory + "/" + indexName);
                list.Add(new PackFile(idxFile, packFile));
            }

            foreach (PackFile p in forReuse.Values)
            {
                p.Close();
            }

            if (list.Count == 0)
            {
                return NO_PACKS;
            }
            PackFile[] r = list.ToArray();
            Array.Sort(r, PackFile.SORT);
            return r;
        }
开发者ID:ArildF,项目名称:GitSharp,代码行数:46,代码来源:ObjectDirectory.cs


示例20: removePack

        private void removePack(PackFile deadPack)
        {
            PackFile[] o, n;
            do
            {
                o = packList.get();
                if (o == null || !inList(o, deadPack))
                {
                    break;

                }
                else if (o.Length == 1)
                {
                    n = NO_PACKS;

                }
                else
                {
                    n = new PackFile[o.Length - 1];
                    int j = 0;
                    foreach (PackFile p in o)
                    {
                        if (p != deadPack)
                        {
                            n[j++] = p;
                        }
                    }
                }
            } while (!packList.compareAndSet(o, n));
            deadPack.Close();
        }
开发者ID:ArildF,项目名称:GitSharp,代码行数:31,代码来源:ObjectDirectory.cs



注:本文中的PackFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PackType类代码示例发布时间:2022-05-24
下一篇:
C# PackExpansionType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap