FileName.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_FileName_hxx
00024 #define __ccxx_FileName_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/String.h++>
00028 
00029 namespace ccxx {
00030 
00054 class COMMONCPP_API FileName
00055 {
00056   public:
00057 
00059   FileName();
00060 
00062   FileName(const String &path);
00063 
00065   FileName(const String &dir, const String &filename);
00066 
00068   FileName(const FileName &other);
00069 
00071   FileName(const char *path);
00072 
00074   FileName& operator=(const FileName &other);
00075 
00077   FileName& operator=(const String &path);
00078 
00080   FileName& operator=(const char *path);
00081 
00083   ~FileName() throw();
00084 
00088   inline String toString() const
00089   { return(getPathName()); }
00090 
00092   String getPathName() const;
00093 
00095   void setPathName(const String &path);
00096 
00100   inline String getVolume() const
00101   { return(_volume); }
00102 
00106   void setVolume(const String &volume);
00107 
00109   inline String getDirectory() const
00110   { return(_dir); }
00111 
00113   void setDirectory(const String &dir);
00114 
00120   FileName& pushDirectory(const String &dir);
00121 
00125   FileName& popDirectory();
00126 
00128   inline String getBaseName() const
00129   { return(_basename); }
00130 
00132   void setBaseName(const String &name);
00133 
00135   inline String getExtension() const
00136   { return(_ext); }
00137 
00139   void setExtension(const String &ext);
00140 
00142   String getFileName() const;
00143 
00152   void setFileName(const String &name);
00153 
00158   bool isAbsolute() const throw();
00159 
00164   FileName& canonicalize();
00165 
00166   private:
00167 
00168   void _rebuildPathName() const;
00169   void _rebuildFileName() const;
00170 
00171   String _volume;
00172   String _dir;
00173   String _basename;
00174   String _ext;
00175   mutable String _filename;
00176   mutable String _pathname;
00177   mutable bool _filenameDirty;
00178   mutable bool _pathnameDirty;
00179 };
00180 
00181 }; // namespace ccxx
00182 
00183 #endif // __ccxx_FileName_hxx
00184 
00185 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3