Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/test_filename.cxx

Go to the documentation of this file.
00001 // Filename: test_filename.cxx
00002 // Created by:  drose (18Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "filename.h"
00020 #include "config_util.h"
00021 
00022 #include <dSearchPath.h>
00023 
00024 #include <stdlib.h>
00025 
00026 void
00027  show_filename(const Filename &f) {
00028   nout
00029     << "get_fullpath = " << f.get_fullpath() << "\n"
00030     /*
00031     << "  _dirname_end = " << f._dirname_end
00032     << " _basename_start = " << f._basename_start << "\n"
00033     << "  _basename_end = " << f._basename_end
00034     << " _extension_start = " << f._extension_start << "\n"
00035     */
00036 
00037     << "get_dirname = " << f.get_dirname() << "\n"
00038     << "get_basename = " << f.get_basename() << "\n"
00039     << "get_fullpath_wo_extension = " << f.get_fullpath_wo_extension() << "\n"
00040     << "get_basename_wo_extension = " << f.get_basename_wo_extension() << "\n"
00041     << "get_extension = " << f.get_extension() << "\n"
00042     << "\n";
00043 }
00044 
00045 
00046 int
00047 main(int argc, char *argv[]) {
00048   if (argc < 2) {
00049     nout << "Specify filename on command line.\n";
00050     exit(1);
00051   }
00052 
00053   Filename f(argv[1]);
00054 
00055   show_filename(f);
00056 
00057   if (argc >= 3) {
00058     Filename t(argv[2]);
00059     nout << "f is " << f << " exists = " << f.exists() << "\n"
00060          << "t is " << t << " exists = " << t.exists() << "\n";
00061 
00062     nout << "f.compare_timestamps(t, true, true) = "
00063          << f.compare_timestamps(t, true, true) << "\n"
00064          << "f.compare_timestamps(t, true, false) = "
00065          << f.compare_timestamps(t, true, false) << "\n"
00066          << "f.compare_timestamps(t, false, true) = "
00067          << f.compare_timestamps(t, false, true) << "\n"
00068          << "f.compare_timestamps(t, false, false) = "
00069          << f.compare_timestamps(t, false, false) << "\n";
00070   }
00071   /*
00072   if (argc >= 3) {
00073     nout << "\nRelative to: " << argv[2] << "\n";
00074     f.make_relative_to(argv[2]);
00075     show_filename(f);
00076 
00077   } else {
00078     nout << "Searching on model path: " << get_model_path() << "\n";
00079     if (f.resolve_filename(get_model_path())) {
00080       nout << "Found: " << f << "\n";
00081     } else {
00082       nout << "not found.\n";
00083     }
00084 
00085     int index = f.find_on_searchpath(get_model_path());
00086     nout << "Found at position " << index << ": " << f << "\n";
00087   }
00088   */
00089 
00090   /*
00091   f.set_extension("new_extension");
00092   show_filename(f);
00093 
00094   f.set_extension("");
00095   show_filename(f);
00096 
00097   f.set_extension("ext");
00098   show_filename(f);
00099 
00100   f.set_dirname("/new/dirname");
00101   show_filename(f);
00102 
00103   f.set_dirname("/");
00104   show_filename(f);
00105 
00106   f.set_dirname("");
00107   show_filename(f);
00108 
00109   f.set_dirname("/dir/name/");
00110   show_filename(f);
00111 
00112   f.set_basename_wo_extension("base_name");
00113   show_filename(f);
00114   */
00115 
00116   return(0);
00117 }
00118 
00119 

Generated on Fri May 2 00:43:45 2003 for Panda by doxygen1.3