示例#1
0
 public PckPackerEntryEntry(string resPath, PckArchiveEntry entry) : base(resPath)
 {
     if (entry is null)
     {
         throw new ArgumentNullException(nameof(entry));
     }
     Entry = entry;
 }
示例#2
0
 /// <summary>
 /// Adds entry from PckArchiveEntry with a new resPath.
 /// </summary>
 /// <param name="resPath">The resPath to entry. It should start with res://</param>
 public static void Add(this PckPacker source, string resPath, PckArchiveEntry entry)
 {
     if (source is null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     source.Add(new PckPackerEntryEntry(resPath, entry));
 }
示例#3
0
        public static string GetMD5String(this PckArchiveEntry source)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(string.Concat(source.MD5.Select(b => b.ToString("x2"))));
        }
示例#4
0
        public static void ExtractToFile(this PckArchiveEntry source, string destFileName, bool overwrite = false)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (destFileName is null)
            {
                throw new ArgumentNullException(nameof(destFileName));
            }

            using var fs = File.Open(destFileName, overwrite ? FileMode.Create : FileMode.CreateNew);
            using var es = source.Open();
            es.CopyTo(fs);
        }
示例#5
0
        public static void ExtractRelativeToDirectory(this PckArchiveEntry source, string destDirectoryName, bool overwrite = false)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (destDirectoryName is null)
            {
                throw new ArgumentNullException(nameof(destDirectoryName));
            }

            var relPath  = source.Path.Replace("res://", "");
            var destPath = Path.Combine(destDirectoryName, relPath);

            Directory.CreateDirectory(Path.GetDirectoryName(destPath));
            source.ExtractToFile(destPath, overwrite);
        }