-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmileConfig.cs
66 lines (57 loc) · 1.84 KB
/
SmileConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Ionic.Zip;
using System.Reflection;
namespace UniversalEmoticonPackBuilderLib
{
public abstract class SmilePackBuilder
{
protected string packRootPath;
protected string path;
protected string imagePath;
protected string buildPath;
protected PackInfo pack;
protected string client;
public SmilePackBuilder(PackInfo pack, string client, string path)
{
this.pack = pack;
this.client = client;
this.buildPath = path;
this.packRootPath = path + String.Format("{0}/", PathPackFullName);
}
public void CopySmiley(string orig_file, string[] equivs)
{
File.Copy(orig_file, imagePath + RenameFile(orig_file), true);
WriteEntry(RenameFile(orig_file), equivs);
}
public void Finish()
{
EndFile();
using (ZipFile zip = new ZipFile())
{
zip.FlattenFoldersOnExtract = false;
zip.AddDirectory(packRootPath);
zip.Comment = pack.Description;
zip.Save(String.Format("{0}{1}.zip", buildPath, PathPackFullName));
}
Directory.CreateDirectory(packRootPath).Delete(true);
}
protected abstract void WriteEntry(string file, string[] equivs);
protected abstract void EndFile();
protected virtual string RenameFile(string fname)
{
return fname;
}
public string PackFullName
{
get { return String.Format("{0} for {1}", pack.FullName, client); }
}
public string PathPackFullName
{
get { return PackFullName.Replace(' ', '_').ToLower(); }
}
}
}