diff --git a/UniversalEmoticonPackBuilder/Ionic.Zip.dll b/UniversalEmoticonPackBuilder/Ionic.Zip.dll
new file mode 100644
index 0000000..95fa928
Binary files /dev/null and b/UniversalEmoticonPackBuilder/Ionic.Zip.dll differ
diff --git a/UniversalEmoticonPackBuilder/Program.cs b/UniversalEmoticonPackBuilder/Program.cs
index 0bd1790..a693c46 100644
--- a/UniversalEmoticonPackBuilder/Program.cs
+++ b/UniversalEmoticonPackBuilder/Program.cs
@@ -7,6 +7,7 @@
using System.Threading;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
+using Ionic.Zip;
namespace QIPSmileBuilder
{
@@ -112,23 +113,37 @@ static void Main(string[] args)
abstract class SmileConfig
{
+ protected string packRootPath;
protected string path;
+ protected string imagePath;
+
protected PackInfo pack;
protected string client;
-
- public SmileConfig(PackInfo pack, string client) {
+
+ public SmileConfig(PackInfo pack, string client, string path)
+ {
this.pack = pack;
this.client = client;
+ this.packRootPath = path + String.Format("{0}/", PathPackFullName);
}
public void CopySmiley(string orig_file, string[] equivs)
{
- File.Copy(orig_file, path + RenameFile(orig_file), true);
+ 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("build/{0}.zip", PathPackFullName));
+ }
+ Directory.CreateDirectory(packRootPath).Delete(true);
}
protected abstract void WriteEntry(string file, string[] equivs);
@@ -142,6 +157,11 @@ public string PackFullName
{
get { return String.Format("{0} for {1}", pack.FullName, client); }
}
+
+ public string PathPackFullName
+ {
+ get { return PackFullName.Replace(' ', '_').ToLower(); }
+ }
}
// class that stores emoticon pack info
diff --git a/UniversalEmoticonPackBuilder/Writers.cs b/UniversalEmoticonPackBuilder/Writers.cs
index 64637e4..bd56618 100644
--- a/UniversalEmoticonPackBuilder/Writers.cs
+++ b/UniversalEmoticonPackBuilder/Writers.cs
@@ -11,9 +11,11 @@ class QipSmileConfig : SmileConfig
private int counter = 0;
public QipSmileConfig(string path, PackInfo pack)
- : base(pack, "QIP")
+ : base(pack, "QIP", path)
{
- this.path = path + String.Format("{0}/", PackFullName);
+ this.path = packRootPath + String.Format("{0}/", PackFullName);
+ this.imagePath = this.path;
+
Directory.CreateDirectory(this.path);
defineFile = new StreamWriter(this.path + "_define.ini", false, Encoding.GetEncoding("windows-1251"));
@@ -29,9 +31,14 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
defineFile.Flush();
- var w = new StreamWriter(this.path + "_define_vis.ini", false, Encoding.GetEncoding("windows-1251"));
- w.Write("1-{0}", counter + 1);
- w.Flush();
+ defineFile.Close();
+
+ using (var w = new StreamWriter(this.path + "_define_vis.ini", false, Encoding.GetEncoding("windows-1251")))
+ {
+ w.Write("1-{0}", counter + 1);
+ w.Flush();
+ w.Close();
+ }
}
protected override string RenameFile(string fname)
@@ -59,9 +66,10 @@ class PidginSmileConfig : SmileConfig
private StreamWriter pidginTheme;
public PidginSmileConfig(string path, PackInfo pack)
- : base(pack, "Pidgin")
+ : base(pack, "Pidgin", path)
{
- this.path = path + String.Format("{0}/{1}/", PackFullName);
+ this.path = packRootPath + String.Format("{0}/", PackFullName);
+ this.imagePath = this.path;
Directory.CreateDirectory(this.path);
pidginTheme = new StreamWriter(this.path + "theme", false, Encoding.GetEncoding("windows-1251"));
@@ -81,6 +89,7 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
pidginTheme.Flush();
+ pidginTheme.Close();
}
}
@@ -89,9 +98,10 @@ class AdiumSmileConfig : SmileConfig
private XmlTextWriter plistWriter;
public AdiumSmileConfig(string path, PackInfo pack)
- : base(pack, "Adium")
+ : base(pack, "Adium", path)
{
- this.path = path + String.Format("{0} {1} by {2} for {3}/{0}.AdiumEmoticonSet/", pack.name, pack.version, pack.author, client);
+ this.path = packRootPath + String.Format("{0}.AdiumEmoticonSet/", PackFullName);
+ this.imagePath = this.path;
Directory.CreateDirectory(this.path);
plistWriter = new XmlTextWriter(this.path + "Emoticons.plist", Encoding.UTF8);
@@ -130,6 +140,7 @@ protected override void EndFile()
plistWriter.WriteEndElement();
plistWriter.WriteEndDocument();
plistWriter.Flush();
+ plistWriter.Close();
}
}
@@ -138,9 +149,10 @@ class MirandaSmileConfig : SmileConfig
private StreamWriter mirandaTheme;
public MirandaSmileConfig(string path, PackInfo pack)
- : base(pack, "Miranda")
+ : base(pack, "Miranda", path)
{
- this.path = path + String.Format("{0} {1} by {2} for Miranda/Animated/", pack.name, pack.version, pack.author);
+ this.path = packRootPath + String.Format("{0}/", PackFullName);
+ this.imagePath = this.path + "Animated/";
Directory.CreateDirectory(this.path);
mirandaTheme = new StreamWriter(this.path + pack.name + ".msl", false, Encoding.GetEncoding("utf-8"));
@@ -159,6 +171,7 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
mirandaTheme.Flush();
+ mirandaTheme.Close();
}
}
@@ -167,9 +180,10 @@ class WIMSkin : SmileConfig
private StreamWriter wimSkin;
public WIMSkin(string path, PackInfo pack)
- : base(pack, "WIM")
+ : base(pack, "WIM", path)
{
- this.path = path + String.Format("{0} {1} by {2} for WIM/PlurkSmilies/", pack.name, pack.version, pack.author);
+ this.path = packRootPath + String.Format("{0}/", PackFullName);
+ this.imagePath = this.path + "PlurkSmilies/";
Directory.CreateDirectory(this.path);
wimSkin = new StreamWriter(this.path + pack.name + ".lua", false, Encoding.GetEncoding("utf-8"));
@@ -189,5 +203,6 @@ protected override void EndFile()
{
wimSkin.WriteLine("};");
wimSkin.Flush();
+ wimSkin.Close();
}
}
\ No newline at end of file
diff --git a/UniversalEmoticonPackBuilder/emoticon_build.csproj b/UniversalEmoticonPackBuilder/emoticon_build.csproj
index e0deb17..9475f21 100644
--- a/UniversalEmoticonPackBuilder/emoticon_build.csproj
+++ b/UniversalEmoticonPackBuilder/emoticon_build.csproj
@@ -34,6 +34,9 @@
4
+
+ .\Ionic.Zip.dll
+