File.h

Go to the documentation of this file.
00001 
00002 //Luke Lenhart (2008-2009)
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 {
00014     class Filename
00015     {
00016     public:
00017         Filename(); 
00018         Filename(const std::string &name); 
00019         inline Filename(const char *name) { *this=Filename(std::string(name)); } 
00020 
00022         inline operator std::string() const  { return GetName(); }
00023 
00025         inline const char* c_str() const { tempCStrCache=GetName(); return tempCStrCache.c_str(); }
00026 
00028         std::string GetPath() const;
00029 
00031         std::string GetName(bool includePath=true, bool includeExtension=true) const;
00032 
00034         std::string GetNameExtension() const;
00035 
00037         std::vector<std::string> GetFiles() const;
00038 
00040         std::vector<std::string> GetSubDirectories() const;
00041 
00043         void StepOut();
00044 
00046         void StepInto(const std::string &name);
00047 
00049         bool IsRoot() const;
00050 
00051     private:
00052         std::vector<std::string> nameParts;
00053         bool isAbsolutePath;
00054 
00055         void StepOutOfHome(); //start at home, then step out
00056 
00057         mutable std::string tempCStrCache;
00058     };
00059 
00061     class FileUtils
00062     {
00063     public:
00065         static Filename GetWorkingDirectory();
00066 
00068         static void SetWorkingDirectory(const Filename &path);
00069 
00071         static bool CreateDirectory(const Filename &path);
00072     };
00073 
00074 } //namespace MPMA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends