00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _cdirectory_h
00018 #define _cdirectory_h
00019
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022
00023 #ifdef _WINDOWS
00024 #include <spl/configwin32.h>
00025 #else
00026 #include <spl/autoconf/config.h>
00027 #endif
00028
00029 #include <spl/Memory.h>
00030 #include <spl/io/Permissions.h>
00031 #include <spl/RefCountPtr.h>
00032 #include <spl/String.h>
00033 #include <spl/collection/Vector.h>
00034
00044 class Directory : public IMemoryValidate, public IComparable
00045 {
00046 protected:
00047 String m_raw;
00048 RefCountPtr<Vector<StringPtr> > m_parts;
00049
00050 static char m_seperator;
00051
00052 public:
00053 Directory( const String& director );
00054 Directory( const Directory& dir );
00055 virtual ~Directory();
00056
00057 Directory& operator =(const Directory& dir);
00058
00059 Directory Parent() const;
00060
00061 inline Vector<StringPtr> ListFiles(const String& filter) const
00062 {
00063 return ListFiles(m_raw, filter);
00064 }
00065
00066 inline StringPtr RemoveTrailingSeperator() const
00067 {
00068 return RemoveTrailingSeperator(ToString());
00069 }
00070
00071 inline bool IsDirectory() const
00072 {
00073 return IsDirectory(m_raw);
00074 }
00075
00076 virtual int32 HashCode() const;
00077 virtual bool Equals( const IComparable& a ) const;
00078 virtual int Compare( const IComparable& a ) const;
00079 virtual int32 MajicNumber() const;
00080
00081 StringPtr ToString() const;
00082
00083 static void ChangeWorkingDirectory(const String& directory);
00084
00085 static StringPtr GetWorkingDirectory();
00086
00087 static Vector<StringPtr> ListFiles(const String& directory, const String& filter);
00088
00089 inline static char SeperatorChar() { return m_seperator; }
00090
00091 static StringPtr RemoveTrailingSeperator(const String& path);
00092
00093 static bool IsDirectory(const String &path);
00094
00095 static void Delete(const String& path);
00096 static void Rename(const String& oldname, const String& newname);
00097 static void Create(const String& path, const Permissions& perm = Permissions::DefaultDirPerms);
00098
00099 #ifdef DEBUG
00100 void ValidateMem() const;
00101 void CheckMem() const;
00102 #endif
00103 };
00104
00105 REGISTER_TYPEOF(84, Directory);
00106
00109 #endif