Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

/Users/blackie/Documents/myRepository/phobosengine-vc2005/phobosengine/phobosengine/FileUtils.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef FILEUTILS_H
00004 #define FILEUTILS_H
00005 
00006 
00007 #include <string>
00008 
00009 
00010 namespace pge {
00011         namespace fileutils {
00012 
00013 
00015                 static std::string getFilename(const std::string &path, const char &delimiter = '/') {
00016                         //
00017                         // Variables
00018                         //
00019                         size_t pos = 0;
00020                         size_t len = 0;
00021 
00022 
00023                         // Find the last occurence of the delimiter.
00024                         // If it is not found, the path contains only a
00025                         // filename.
00026                         pos = path.find_last_of(delimiter);
00027                         if(pos == std::string::npos) {
00028                                 return path;
00029                         }
00030                         len = path.size() - pos - 1;
00031                         std::string sub = path.substr(pos + 1, len);
00032                         return sub;
00033                 }
00034 
00035 
00037                 static std::string getExtension(const std::string &path, const char delimiter = '/') {
00038                         //
00039                         // variables
00040                         //
00041                         size_t pos = 0;
00042                         size_t len = 0;
00043 
00044 
00045                         pos = path.find_last_of('.');
00046                         if(pos == std::string::npos) {
00047                                 return "not_found";
00048                         }
00049                         len = path.length() - pos;
00050                         std::string sub = path.substr(pos + 1, len);
00051                         return sub;
00052                 }
00053         };
00054 };
00055 
00056 #endif

Generated on Mon Oct 16 12:08:10 2006 for Phobosengine by doxygen 1.3.4