File.h

Go to the documentation of this file.
00001 
00002 //Luke Lenhart (2007)
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 #include <string>
00007 #include <vector>
00008 
00009 namespace MPMA
00010 {
00011     class Directory;
00012 
00016     class Filename
00017     {
00018     public:
00019         Filename(const std::string &filename); 
00020         inline Filename(const char *filename) { *this=Filename(std::string(filename)); } 
00021 
00023         inline operator const std::string&() const { return fname; }
00024 
00026         inline const char* c_str() const { return fname.c_str(); }
00027 
00029         Directory GetPath() const;
00030 
00032         std::string GetFilenameNoPath(bool includeExtension=true) const;
00033 
00035         std::string GetFilenameExtension() const;
00036 
00037     private:
00038         std::string fname;
00039 
00040         //remove rediculousness from a filename
00041         void PurifyFilename();
00042     };
00043 
00045     class Directory
00046     {
00047     public:
00048         Directory(); 
00049         Directory(const Filename &initialPath); 
00050 
00052         bool CreateDirectory() const;
00053 
00055         std::vector<std::string> GetFiles() const;
00057         std::vector<std::string> GetSubDirectories() const;
00058 
00060         void StepOut();
00062         void StepInto(const std::string &subdir);
00063 
00065         inline operator const std::string&() const {return path;}
00066 
00068         inline const char* c_str() const { return path.c_str(); }
00069 
00071         inline Filename File(const std::string &fname) const {return Filename(path+"/"+fname);}
00072 
00074         static Directory GetWorkingDirectory();
00075 
00077         void SetWorkingDirectory() const;
00078 
00079     private:
00080         std::string path;
00081     };
00082 
00083 } //namespace MPMA

Generated on Sat Aug 9 15:05:05 2008 for MPMA Framework by  doxygen 1.5.6