From ebcf12e1a7594c5c4d222718abb2979cc7bb3986 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 22 Feb 2001 01:42:55 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/eggbase/eggFilter.cxx | 10 ++------ pandatool/src/eggbase/eggWriter.cxx | 37 ++++++++++++++++++++++------- pandatool/src/eggbase/eggWriter.h | 1 + pandatool/src/eggprogs/Sources.pp | 8 +++++++ 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/pandatool/src/eggbase/eggFilter.cxx b/pandatool/src/eggbase/eggFilter.cxx index 765706fba5..145c0eccca 100644 --- a/pandatool/src/eggbase/eggFilter.cxx +++ b/pandatool/src/eggbase/eggFilter.cxx @@ -42,14 +42,8 @@ EggFilter(bool allow_last_param, bool allow_stdout) : //////////////////////////////////////////////////////////////////// bool EggFilter:: handle_args(ProgramBase::Args &args) { - if (_allow_last_param && !_got_output_filename && args.size() > 1) { - _got_output_filename = true; - _output_filename = args.back(); - args.pop_back(); - - if (!verify_output_file_safe()) { - return false; - } + if (!check_last_arg(args)) { + return false; } return EggReader::handle_args(args); diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx index a44741b53a..5955556adc 100644 --- a/pandatool/src/eggbase/eggWriter.cxx +++ b/pandatool/src/eggbase/eggWriter.cxx @@ -146,14 +146,8 @@ get_output_filename() const { //////////////////////////////////////////////////////////////////// bool EggWriter:: handle_args(ProgramBase::Args &args) { - if (_allow_last_param && !_got_output_filename && !args.empty()) { - _got_output_filename = true; - _output_filename = args.back(); - args.pop_back(); - - if (!verify_output_file_safe()) { - return false; - } + if (!check_last_arg(args)) { + return false; } if (!args.empty()) { @@ -166,6 +160,33 @@ handle_args(ProgramBase::Args &args) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: EggWriter::check_last_arg +// Access: Protected +// Description: Checks if the last filename on the argument list is +// an egg file (if _allow_last_param was set true), and +// removes it from the argument list if it is. Returns +// true if the arguments are good, false if something is +// invalid. +//////////////////////////////////////////////////////////////////// +bool EggWriter:: +check_last_arg(ProgramBase::Args &args) { + if (_allow_last_param && !_got_output_filename && !args.empty()) { + Filename filename = args.back(); + if (filename.get_extension() == "egg") { + _got_output_filename = true; + _output_filename = filename; + args.pop_back(); + + if (!verify_output_file_safe()) { + return false; + } + } + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: EggWriter::post_command_line // Access: Protected, Virtual diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h index 34857d1a59..fb8591264a 100644 --- a/pandatool/src/eggbase/eggWriter.h +++ b/pandatool/src/eggbase/eggWriter.h @@ -27,6 +27,7 @@ public: protected: virtual bool handle_args(Args &args); + bool check_last_arg(Args &args); virtual bool post_command_line(); bool verify_output_file_safe() const; diff --git a/pandatool/src/eggprogs/Sources.pp b/pandatool/src/eggprogs/Sources.pp index 84ec81ff70..9b9846f7f1 100644 --- a/pandatool/src/eggprogs/Sources.pp +++ b/pandatool/src/eggprogs/Sources.pp @@ -14,3 +14,11 @@ eggTrans.cxx eggTrans.h #end noinst_bin_target + +#begin bin_target + #define TARGET egg-texture-cards + + #define SOURCES \ + eggTextureCards.cxx eggTextureCards.h + +#end bin_target