*** empty log message ***

This commit is contained in:
Mike Goslin 2000-10-10 22:07:45 +00:00
parent aa85f44e26
commit 5b755a1019
3 changed files with 28 additions and 18 deletions

View File

@ -19,7 +19,8 @@ main(int argc, char *argv[]) {
extern char *optarg;
extern int optind;
int flag = getopt(argc, argv, "x:c:v");
int flag = getopt(argc, argv, "xcvr:");
Filename rel_path;
while (flag != EOF) {
switch (flag) {
case 'x':
@ -30,16 +31,24 @@ main(int argc, char *argv[]) {
case 'v':
verbose = true;
break;
case 'r':
rel_path = optarg;
break;
default:
cerr << "Unhandled switch: " << flag << endl;
break;
}
flag = getopt(argc, argv, "x:c:v");
flag = getopt(argc, argv, "xcvr:");
}
argc -= (optind - 1);
argv += (optind - 1);
Filename dest_file = argv[0];
if (argc <= 1) {
cerr << "Usage: multify -[x,c|v] <dest_file> <src_file> ..." << endl;
return 0;
}
Filename dest_file = argv[1];
dest_file.set_binary();
if (verbose == true) {
@ -52,7 +61,7 @@ main(int argc, char *argv[]) {
Multifile mfile;
if (extract == false) {
for (int i = 1; i < argc; i++) {
for (int i = 2; i < argc; i++) {
Filename in_file = argv[i];
in_file.set_binary();
mfile.add(in_file);
@ -62,7 +71,7 @@ main(int argc, char *argv[]) {
cerr << "Failed to write: " << dest_file << endl;
} else {
mfile.read(dest_file);
mfile.extract_all();
mfile.extract_all(rel_path);
}
return 1;

View File

@ -233,19 +233,20 @@ read_from_multifile(ifstream &read_stream) {
// Description: Writes to a individual file
////////////////////////////////////////////////////////////////////
bool Multifile::Memfile::
write(void) {
write(const Filename &rel_path) {
ofstream write_stream;
_name.set_binary();
_name.make_dir();
if (!_name.open_write(write_stream)) {
Filename name = rel_path.get_fullpath() + _name.get_fullpath();
name.set_binary();
name.make_dir();
if (!name.open_write(write_stream)) {
express_cat.error()
<< "Multifile::Memfile::write() - Failed to open output file: "
<< _name << endl;
<< name << endl;
return false;
}
express_cat.debug()
<< "Writing to file: " << _name << endl;
<< "Writing to file: " << name << endl;
write_stream.write(_buffer, _buffer_length);
return true;
@ -607,11 +608,11 @@ reset(void) {
// Description:
////////////////////////////////////////////////////////////////////
bool Multifile::
extract(const Filename &name) {
extract(const Filename &name, const Filename &rel_path) {
MemfileList::iterator found;
found = find_if(_files.begin(), _files.end(), MemfileMatch(name));
if (found != _files.end()) {
(*found)->write();
(*found)->write(rel_path);
return true;
}
return false;
@ -623,11 +624,11 @@ extract(const Filename &name) {
// Description:
////////////////////////////////////////////////////////////////////
void Multifile::
extract_all(void) {
extract_all(const Filename &rel_path) {
express_cat.debug()
<< "Multifile::extract_all() - Extracting all files" << endl;
MemfileList::iterator i;
for (i = _files.begin(); i != _files.end(); ++i)
(*i)->write();
(*i)->write(rel_path);
}

View File

@ -45,8 +45,8 @@ public:
bool write(Filename name);
bool write(char *&start, int &size);
bool write_extract(char *&start, int &size);
bool extract(const Filename &name);
void extract_all(void);
bool extract(const Filename &name, const Filename &rel_path = "");
void extract_all(const Filename &rel_path = "");
void reset(void);
bool parse_header(char *&start, int &size);
@ -64,7 +64,7 @@ private:
bool read(const Filename &name);
bool read_from_multifile(ifstream &read_stream);
bool write(void);
bool write(const Filename &rel_path);
void write_to_multifile(ofstream &write_stream);
bool write(char *&start, int &size);
void reset(void);