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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*******************************************************************************
This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
Copyright (c) 2010 Treeki (treeki@gmail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License 2.0 for more details.
You should have received a copy of the GNU General Public License 2.0
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include <QCoreApplication>
#include "lyt/directorypackage.h"
#include "lyt/archivepackage.h"
#include "lyt/layout.h"
#include <QtCore/QFile>
#include "wii/archiveu8.h"
#include <QDir>
#include "lsrlytexporter.h"
#include <QFile>
#include <QStringList>
#include <stdio.h>
#include <stdlib.h>
#include "lyt/animation.h"
static QIODevice *debugDevice = 0;
void newMsgHandler(QtMsgType type, const char *msg) {
if (debugDevice && type == QtDebugMsg) {
debugDevice->write(msg);
debugDevice->write("\n", 1);
return;
}
switch (type) {
case QtDebugMsg:
fprintf(stderr, "4:D> %s\n", msg);
break;
case QtWarningMsg:
fprintf(stderr, "3:W> %s\n", msg);
break;
case QtCriticalMsg:
fprintf(stderr, "2:C> %s\n", msg);
break;
case QtFatalMsg:
fprintf(stderr, "1:F> %s\n", msg);
abort();
}
}
int main(int argc, char *argv[]) {
qInstallMsgHandler(newMsgHandler);
QCoreApplication a(argc, argv);
QStringList args = a.arguments();
if (args.count() == 4 && args.at(1) == "export") {
QDir expDir(args.at(3));
expDir.mkpath(".");
QFile debugFile(expDir.filePath("LS_ArchiveReadLog.txt"));
debugFile.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile;
LYTArchivePackage eArc(args.at(2));
debugDevice = 0;
debugFile.close();
QFile debugFile2(expDir.filePath("LS_LayoutReadLog.txt"));
debugFile2.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile2;
LSExportPackage(&eArc, expDir.path());
debugDevice = 0;
debugFile2.close();
} else if (args.count() == 4 && args.at(1) == "export-dir") {
QDir dir(args.at(2));
QDir outDir(args.at(3));
outDir.mkpath(".");
QStringList filters("*.arc");
QStringList things = dir.entryList(filters);
foreach (const QString &thing, things) {
QString niceName = thing;
niceName.replace(".arc", "");
fprintf(stdout, "Exporting %s ...\n", thing.toAscii().constData());
QDir expDir = outDir;
expDir.cd("exp_"+niceName);
expDir.mkpath(".");
QFile debugFile(expDir.filePath("LS_ArchiveReadLog.txt"));
debugFile.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile;
LYTArchivePackage eArc(dir.filePath(thing));
debugDevice = 0;
debugFile.close();
QFile debugFile2(expDir.filePath("LS_LayoutReadLog.txt"));
debugFile2.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile2;
LSExportPackage(&eArc, expDir.path());
debugDevice = 0;
debugFile2.close();
}
} else if (args.count() == 4 && args.at(1) == "export-nsmb") {
QDir dir(args.at(2));
QDir outDir(args.at(3));
outDir.mkpath(".");
QStringList things = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
foreach (const QString &thing, things) {
QDir inDir = dir;
inDir.cd(thing);
fprintf(stdout, "Checking dir %s ...\n", thing.toAscii().constData());
if (inDir.exists(thing+".arc")) {
fprintf(stdout, "Exporting ...\n");
QDir expDir = outDir;
expDir.cd("exp_"+thing);
expDir.mkpath(".");
QFile debugFile(expDir.filePath("LS_ArchiveReadLog.txt"));
debugFile.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile;
LYTArchivePackage eArc(inDir.filePath(thing+".arc"));
debugDevice = 0;
debugFile.close();
QFile debugFile2(expDir.filePath("LS_LayoutReadLog.txt"));
debugFile2.open(QFile::WriteOnly | QFile::Text);
debugDevice = &debugFile2;
LSExportPackage(&eArc, expDir.path());
debugDevice = 0;
debugFile2.close();
} else {
fprintf(stdout, "No matching arc found\n");
}
}
} else {
fprintf(stdout, "LayoutStudio command-line un-exporter\n");
fprintf(stdout, "(c) Treeki 2010-2012. Please do not distribute.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Accepted commands:\n");
fprintf(stdout, " + ./LS export path/to/layout.arc output/directory\n");
fprintf(stdout, " exports one layout to RLYT, RLAN and TGA\n");
fprintf(stdout, "\n");
fprintf(stdout, " + ./LS export-dir path/to/input/directory output/directory\n");
fprintf(stdout, " exports every arc file in a specific directory\n");
fprintf(stdout, "\n");
fprintf(stdout, " + ./LS export-nsmb path/to/input/directory output/directory\n");
fprintf(stdout, " exports every arc file in named dirs inside a specfic directory\n");
fprintf(stdout, " for example: inDir/layout1/layout1.arc, inDir/layout2/layout2.arc ...\n");
fprintf(stdout, "\n");
}
return 0;
}
|