Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

streams.File.h

00001 /*----------------------------------------------------------------------------
00002   SWORD 2000 - Software With Objects for Rapid Development
00003   Copyright (C) 2003 Eric NICOLAS
00004   ----------------------------------------------------------------------------
00005   SWORD is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU Lesser General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   SWORD is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public License
00016   along with SWORD; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018   --------------------------------------------------------------------------*/
00019 #ifndef _SWORD_STREAMS_FILE_
00020 #define _SWORD_STREAMS_FILE_
00021 
00022 #include "sword/time.Time.h"
00023 
00024 namespace sword {
00025 
00026         class SWORDDECL File {
00027         public:
00028                 File();
00029                 File(const char *pathname);
00030                 File(const std::string &pathname);
00031                 File(const File &file);
00032                 File(const File &file, const std::string &pathname);
00033                 File(const File &file, const char *pathname);
00034 
00035                 void add(const std::string &pathname);
00036                 void canonize() const;
00037                 void canonize(const std::string &basepath) const;
00038 
00039                 std::string pathname() const;
00040                 std::string path()     const;
00041                 std::string filename() const;
00042                 std::string fileext()  const;
00043 
00044                 bool exists()          const;
00045                 bool isFile()          const;
00046                 bool isDirectory()     const;
00047                 bool isLink()          const;
00048                 Time time()            const;
00049                 word size()            const;
00050 
00051                 // --- special directories factory
00052 
00053                 enum Special
00054                 {
00055                         spHome            = 0,    // Portable, $HOME or "My Documents"
00056                         spTemp            = 1,    // Portable
00057                         spCurrent         = 2,    // Portable, current working directory
00058                         spApplicationData = 3,    // MsWindows only
00059                         spStartMenu       = 4     // MsWindows only
00060                 };
00061 
00062                 static File special(Special which);
00063 
00064                 // --- exceptions
00065                 class NoEntryException : public Exception {};
00066                 class SpecialDirException : public Exception {};
00067 
00068         private:
00069                 mutable std::string pathname_;
00070                 mutable bool        canonic_;
00071                 //
00072                 void canonize_(char *dest1) const;
00073                 static bool exists_  (const std::string &pathname);
00074         };
00075 
00076 } // namespace sword
00077 
00078 #include "sword.private/streams.File.inl"
00079 
00080 #endif // _SWORD_STREAMS_FILE_

Generated on Tue Dec 23 20:08:56 2003 for SWORD by doxygen1.3-rc2