summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-12 15:44:55 +0200
committerTreeki <treeki@gmail.com>2012-09-12 15:44:55 +0200
commit9ab95a0f0efa2fa1d15da6bd6c2b5e923bb1af42 (patch)
treec094ef3585989ea2abe02e1b6627dc4f71d43b73
parent3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10 (diff)
downloadLayoutStudio-9ab95a0f0efa2fa1d15da6bd6c2b5e923bb1af42.tar.gz
LayoutStudio-9ab95a0f0efa2fa1d15da6bd6c2b5e923bb1af42.zip
console interface
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]LayoutStudio.pro1
-rwxr-xr-x[-rw-r--r--]main.cpp117
2 files changed, 106 insertions, 12 deletions
diff --git a/LayoutStudio.pro b/LayoutStudio.pro
index cd34307..2b61e62 100644..100755
--- a/LayoutStudio.pro
+++ b/LayoutStudio.pro
@@ -2,6 +2,7 @@
# Project created by QtCreator 2010-10-03T04:03:27
# -------------------------------------------------
QT += xml
+CONFIG += console
TARGET = LayoutStudio
TEMPLATE = app
SOURCES += main.cpp \
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;