00001 // Filename: filenameUnifier.h 00002 // Created by: drose (05Dec00) 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 #ifndef FILENAMEUNIFIER_H 00020 #define FILENAMEUNIFIER_H 00021 00022 #include <pandatoolbase.h> 00023 00024 #include <filename.h> 00025 00026 #include "pmap.h" 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : FilenameUnifier 00030 // Description : This static class does the job of converting 00031 // filenames from relative to absolute to canonical or 00032 // whatever is appropriate. Its main purpose is to 00033 // allow us to write relative pathnames to the bam file 00034 // and turn them back into absolute pathnames on read, 00035 // so that a given bam file does not get tied to 00036 // absolute pathnames. 00037 //////////////////////////////////////////////////////////////////// 00038 class FilenameUnifier { 00039 public: 00040 static void set_txa_filename(const Filename &txa_filename); 00041 static void set_rel_dirname(const Filename &rel_dirname); 00042 00043 static Filename make_bam_filename(Filename filename); 00044 static Filename get_bam_filename(Filename filename); 00045 static Filename make_egg_filename(Filename filename); 00046 static Filename make_user_filename(Filename filename); 00047 00048 private: 00049 static void make_canonical(Filename &filename); 00050 00051 static Filename _txa_filename; 00052 static Filename _txa_dir; 00053 static Filename _rel_dirname; 00054 00055 typedef pmap<string, string> CanonicalFilenames; 00056 static CanonicalFilenames _canonical_filenames; 00057 }; 00058 00059 #endif 00060