-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProgram.cs
More file actions
90 lines (75 loc) · 2.74 KB
/
Program.cs
File metadata and controls
90 lines (75 loc) · 2.74 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.IO;
namespace UnityPackager
{
internal class Program
{
public static void Main(string[] args)
{
if (args.Length == 0)
{
PrintUsage();
Environment.Exit(1);
return;
}
else if (args[0].ToLower() == "pack")
{
if (args.Length <= 3)
{
PrintUsage();
Environment.Exit(1);
return;
}
else if ((args.Length - 2) % 2 != 0)
{
PrintUsage();
Environment.Exit(1);
return;
}
string outputFile = args[1];
if (!Path.IsPathRooted(outputFile))
outputFile = Path.GetFullPath(outputFile);
Dictionary<string, string> fileMap = new Dictionary<string, string>();
for (int i = 2; i < args.Length; i += 2)
{
string fromPath = args[i];
if (!Path.IsPathRooted(args[i]))
fromPath = Path.GetFullPath(fromPath);
string toPath = args[i + 1];
fileMap.Add(fromPath, toPath);
}
Packer.Pack(fileMap, outputFile);
}
else if (args[0].ToLower() == "unpack")
{
if (args.Length != 3)
{
PrintUsage();
Environment.Exit(1);
return;
}
string inputFile = args[1];
if (!Path.IsPathRooted(inputFile))
inputFile = Path.GetFullPath(inputFile);
string outputFolder = args[2];
if (!Path.IsPathRooted(outputFolder))
outputFolder = Path.GetFullPath(outputFolder);
Unpacker.Unpack(inputFile, outputFolder);
}
else
{
PrintUsage();
}
}
private static void PrintUsage()
{
Console.WriteLine("Usage:");
Console.WriteLine("\t" + "UnityPackager pack <output> [(<input-file> <target-path>)]...");
Console.WriteLine("\t" + "UnityPackager unpack <input-file> <output-folder>");
Console.WriteLine("Example:");
Console.WriteLine("\t" + "UnityPackager pack MyPackage.unitypackage MyFile.cs Assets/MyFile.cs");
Console.WriteLine("\t" + "UnityPackager unpack MyPackage.unitypackage MyProjectFolder");
}
}
}