summaryrefslogtreecommitdiff
path: root/cd-tool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cd-tool.cpp')
-rw-r--r--cd-tool.cpp54
1 files changed, 46 insertions, 8 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp
index e828233..8016aa9 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -26,18 +26,22 @@
#include <string.h>
#include "Input.h"
#include "Output.h"
+#include "Buffer.h"
#include "cdreader.h"
#include "cdutils.h"
#include "generic.h"
#include "Main.h"
#include "cdabstract.h"
+#include "isobuilder.h"
+
int lga = 0;
struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"ppf", 1, NULL, 'p'},
{"mode", 1, NULL, 'm'},
- {"force", 1, NULL, 'f'},
+ {"force", 0, NULL, 'f'},
+ {"verbose", 0, NULL, 'v'},
{0, 0, NULL, 0 }
};
@@ -71,6 +75,7 @@ void showhelp(void) {
" extract <file> <addr> <size> - extract some sectors to <file>\n"
" insert-file <file> <path> - insert the file to <path>\n"
" insert <file> <addr> - insert some sectors at <addr>\n"
+" copy <isofile> - copy to another iso\n"
"\n", argv[0]);
}
@@ -96,7 +101,7 @@ virtual int startup() throw (GeneralException) {
verbosity = M_WARNING;
- while ((c = getopt_long(argc, argv, "Hhm:p:f", long_options, NULL)) != EOF) {
+ while ((c = getopt_long(argc, argv, "Hhm:p:fv", long_options, NULL)) != EOF) {
switch (c) {
case 'h':
case 'H':
@@ -112,6 +117,9 @@ virtual int startup() throw (GeneralException) {
case 'f':
force = 1;
break;
+ case 'v':
+ verbosity = M_INFO;
+ break;
}
}
@@ -140,7 +148,6 @@ virtual int startup() throw (GeneralException) {
if (!cdutil->get_iso_infos())
exit(-1);
-
if (!strcmp(argv[optind], "infos")) {
cdutil->show_iso_infos();
} else if (!strcmp(argv[optind], "path")) {
@@ -167,7 +174,8 @@ virtual int startup() throw (GeneralException) {
cdutil->show_head_entry();
cdutil->show_dir(&dir);
} else if (!strcmp(argv[optind], "extract-file")) {
- cdutils::DirEntry dir;
+ cdutils::DirEntry * dir;
+ Byte * buffer;
optind++;
if ((argc - 2) != optind) {
@@ -178,14 +186,21 @@ virtual int startup() throw (GeneralException) {
arg1 = argv[optind++];
arg2 = argv[optind++];
file = new Output(arg1);
- dir = cdutil->find_path(f = strdup(arg2));
- free(f);
- if (!dir.R) {
+ dir = cdutil->find_path(&buffer, arg2);
+ if (!dir) {
printm(M_ERROR, "Path %s was not found on iso.\n", arg2);
throw Exit(-1);
}
printm(M_STATUS, "Reading path %s to file %s.\n", arg2, arg1);
- cdutil->read_file(file, type, dir.Sector, dir.Size);
+#if 0
+ cdutil->read_file(file, type, dir->Sector, dir->Size);
+#else
+ cdfile * f = new cdfile(cdutil, dir, type);
+ printm(M_STATUS, f->GetName());
+ copy(f, file);
+ delete f;
+#endif
+ free(buffer);
} else if (!strcmp(argv[optind], "extract")) {
optind++;
if ((argc - 3) != optind) {
@@ -279,6 +294,29 @@ virtual int startup() throw (GeneralException) {
file = new Input(arg1);
printm(M_STATUS, "Writing file %s at sector %i.\n", arg1, sector);
cdutil->write_file(file, type, sector);
+ } else if (!strcmp(argv[optind], "copy")) {
+ optind++;
+ if ((argc - 1) != optind) {
+ showhelp();
+ printm(M_ERROR, "copy needs one argument.\n");
+ throw Exit(-1);
+ }
+ arg1 = argv[optind];
+ Output * o = new Output(arg1);
+ isobuilder * b = new isobuilder(o);
+ isobuilder::DirTree * root = b->setbasics(isobuilder::createpvd(cdutil));
+ iso_r->seek(0);
+ b->foreword(iso_r);
+ b->copydir(root, ".", cdutil, cdutil->rootDir);
+
+ Buffer * buf = new Buffer(true);
+ (*buf) << "Touched!\n";
+ b->createfile(root, buf, "TOUCHED.TXT")->setbasicsxa();
+ b->close();
+
+ delete o; o = 0;
+ delete b; b = 0;
+ delete buf; buf = 0;
} else {
showhelp();
printm(M_ERROR, "Command %s unknow.\n", argv[optind]);