Ejemplo n.º 1
0
 public void TestCRUD()
 {
     Lz4Package package = new Lz4Package("test.lz4");
     package.AddEntry("test1", new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));
     Assert.That(File.Exists(package.InfoFile));
     Console.WriteLine(File.ReadAllText(package.InfoFile, Encoding.UTF8));
     File.Delete(package.Filename);
     File.Delete(package.InfoFile);
 }
Ejemplo n.º 2
0
 private static void AddFiles(Lz4Package package, string[] args)
 {
     Lz4Mode fast = Lz4Mode.Fast;
     string baseDir = "";
     for (int i = 0; i < args.Length; i++)
     {
         string pattern = args[i];
         if (pattern == "-b")
         {
             baseDir = args[++i];
         }
         else if (pattern == "-h")
         {
             fast = Lz4Mode.HighCompression;
         }
         else if (pattern == "-H")
         {
             fast = Lz4Mode.Fast;
         }
         else
         {
             foreach (string str3 in GetFilenames(baseDir, pattern))
             {
                 if (File.Exists(str3))
                 {
                     if (!str3.StartsWith(baseDir + @"\"))
                     {
                         Console.WriteLine("文件 {0} 不在 {1} 目录下", str3, baseDir);
                     }
                     else
                     {
                         string name = str3.Substring(baseDir.Length + 1);
                         package.AddEntry(name, str3, fast);
                     }
                 }
                 else
                 {
                     Console.WriteLine("文件不存在 " + str3);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private static void Main(string[] args)
 {
     string str;
     if (args.Length == 0)
     {
         Compress();
     }
     else
     {
         str = args[0];
         switch (str)
         {
             case "-?":
             case "/?":
             case "--help":
                 PrintUsage();
                 break;
         }
         if (str == "-d")
         {
             Decompress();
         }
         else
         {
             if (args.Length < 2)
             {
                 PrintUsage("未指定压缩包");
             }
             Lz4Package package = new Lz4Package(args[1]);
             string str2 = str;
             if (str2 == null)
             {
                 goto Label_0120;
             }
             if (str2 != "c")
             {
                 if (str2 == "a")
                 {
                     AddFiles(package, args.Skip(2).ToArray());
                     return;
                 }
                 if ((str2 == "x") || (str2 == "l"))
                 {
                     PrintUsage();
                     return;
                 }
                 goto Label_0120;
             }
             File.Delete(package.Filename);
             File.Delete(package.InfoFile);
             AddFiles(package, args.Skip(2).ToArray());
         }
     }
     return;
     Label_0120:
     PrintUsage(string.Format("未知命令 {0}", str));
 }