cel_filepath.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00004 //
00005 // (C) 2003-2006 Celartem Technology Inc. All rights reserved.
00006 //----------------------------------------------------------------------------
00007 
00008 #ifndef _cel_filepath_h_
00009 #define _cel_filepath_h_
00010 
00011 #include "cel_base.h"
00012 #include "cel_string.h"
00013 #include "cel_fileutil.h"
00014 
00015 namespace Celartem
00016 {
00017     //------------------------------------------------------------------------
00026     class Path
00027     {
00028     public:
00032         Path() {}
00033 
00039         Path(const Path& inFilePath) {assign(inFilePath.m_filePath);}
00040 
00047         Path(const String& inFilePath) {assign(inFilePath);}
00048 
00055         Path(const char* inFilePath) {assign(inFilePath);}
00056 
00063         Path(const utf8s& inFilePath) {assign(inFilePath);}
00064 
00071         Path(const UChar2 *inFilePath) {assign(inFilePath);}
00072 
00079         Path(const UChar4 *inFilePath) {assign(inFilePath);}
00080 
00088         Path& operator=(const Path& inFilePath)
00089         {
00090             assign(inFilePath.m_filePath);
00091             return *this;
00092         }
00093 
00102         Path& operator=(const String& inFilePath)
00103         {
00104             assign(inFilePath);
00105             return *this;
00106         }
00107 
00116         Path& operator=(const utf8s& inFilePath)
00117         {
00118             assign(inFilePath);
00119             return *this;
00120         }
00121 
00130         Path& operator=(const UChar2 *inFilePath)
00131         {
00132             assign(inFilePath);
00133             return *this;
00134         }
00135 
00144         Path& operator=(const UChar4 *inFilePath)
00145         {
00146             assign(inFilePath);
00147             return *this;
00148         }
00149 
00157         operator String() const {return m_filePath;}
00158 
00166         String getPath() const {return m_filePath;}
00167 
00174         void assign(const String& inFilePath)
00175         {
00176             m_filePath = FileUtils::normalizePath(inFilePath);
00177         }
00178 
00187         String getBodyFileName() const
00188         {
00189             return FileUtils::getFileNameFromPath(m_filePath);
00190         }
00191         
00200         String removeFileNameFromPath() const
00201         {
00202             return FileUtils::removeFileNameFromPath(m_filePath);
00203         }
00204         
00213         String removeTrailingPathSeparator() const
00214         {
00215             return FileUtils::removeTrailingPathSeparator(m_filePath);
00216         }
00217 
00223         String getExtension() const
00224         {
00225             return FileUtils::getExtension(m_filePath);
00226         }
00227 
00233         String removeExtension() const
00234         {
00235             return FileUtils::removeExtensionFromPath(m_filePath);
00236         }
00237 
00243         bool doesExist() const
00244         {
00245             return FileUtils::doesExist(m_filePath);
00246         }
00247 
00254         bool isDirectory() const
00255         {
00256             return FileUtils::isDirectory(m_filePath);
00257         }
00258 
00264         bool deleteFile() const
00265         {
00266             return FileUtils::deleteFile(m_filePath);
00267         }
00268 
00280         bool overwriteWith(
00281             const Path& inSrc,
00282             bool forceOverwrite = false) const
00283         {
00284             return FileUtils::copyFile(
00285                 inSrc.m_filePath, m_filePath, forceOverwrite);
00286         }
00287 
00296         bool replaceWith(const Path& inReplacer) const
00297         {
00298             return FileUtils::replaceFile(
00299                 m_filePath, inReplacer.m_filePath);
00300         }
00301 
00302     private:
00303         String m_filePath;
00304     };
00305 }
00306 
00307 #endif // _cel_filepath_h_

This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:21:54 2008.