summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]main.cpp117
1 files changed, 105 insertions, 12 deletions
diff --git a/main.cpp b/main.cpp
index a8ae533..1a46dfe 100644..100755
--- a/main.cpp
+++ b/main.cpp
@@ -31,42 +31,135 @@
#include "lsrlytexporter.h"
#include <QFile>
#include <QStringList>
-#include <cstdio>
+#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));
- LSExportPackage(&eArc, args.at(3));
+ 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) {
- LYTArchivePackage eArc(dir.filePath(thing));
QString niceName = thing;
niceName.replace(".arc", "");
- LSExportPackage(&eArc, outDir.filePath("exp_"+niceName));
+ 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));
- QStringList filters("*.arc");
- QStringList things = dir.entryList(filters);
+ outDir.mkpath(".");
+ QStringList things = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
foreach (const QString &thing, things) {
- QString niceName = thing;
- niceName.replace(".arc", "");
QDir inDir = dir;
- inDir.cd(niceName);
- LYTArchivePackage eArc(inDir.filePath(thing));
- LSExportPackage(&eArc, outDir.filePath("exp_"+niceName));
+ 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 {
- std::printf("LayoutStudio command-line un-exporter");
+ 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;