]>
Commit | Line | Data |
---|---|---|
df5ddbca RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: filename.h | |
3 | // Purpose: wxFileName - encapsulates ice cream | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 28.12.00 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2000 Robert Roebling | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_FILENAME_H_ | |
13 | #define _WX_FILENAME_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "filename.h" | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/string.h" | |
21 | #endif | |
22 | ||
23 | // ridiculously enough, this will replace DirExists with wxDirExists etc | |
ee66f092 | 24 | #include "wx/filefn.h" |
df5ddbca RR |
25 | |
26 | enum wxPathFormat | |
27 | { | |
28 | wxPATH_NATIVE = 0, | |
29 | wxPATH_UNIX, | |
30 | wxPATH_MAC, | |
31 | wxPATH_DOS, | |
ee66f092 | 32 | |
df5ddbca RR |
33 | wxPATH_BEOS = wxPATH_UNIX, |
34 | wxPATH_WIN = wxPATH_DOS, | |
35 | wxPATH_OS2 = wxPATH_DOS | |
ee66f092 | 36 | |
df5ddbca RR |
37 | }; |
38 | ||
39 | class WXDLLEXPORT wxFileName | |
40 | { | |
41 | public: | |
42 | // constructors and assignment | |
a35b27b1 | 43 | wxFileName() |
df5ddbca | 44 | { } |
a35b27b1 | 45 | wxFileName( const wxFileName &filepath ); |
df5ddbca RR |
46 | wxFileName( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE ) |
47 | { Assign( path, dir_only, format ); } | |
48 | void Assign( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE ); | |
a35b27b1 RR |
49 | void Assign( const wxFileName &filepath ); |
50 | ||
df5ddbca RR |
51 | // Only native form |
52 | bool FileExists(); | |
a35b27b1 RR |
53 | static bool FileExists( const wxString &file ); |
54 | ||
df5ddbca | 55 | bool DirExists(); |
a35b27b1 RR |
56 | static bool DirExists( const wxString &dir ); |
57 | ||
df5ddbca | 58 | void AssignCwd(); |
a35b27b1 RR |
59 | static wxString GetCwd(); |
60 | ||
61 | bool SetCwd(); | |
62 | static bool SetCwd( const wxString &cwd ); | |
63 | ||
64 | void AssignHomeDir(); | |
65 | static wxString GetHomeDir(); | |
66 | ||
df5ddbca | 67 | void AssignTempFileName( const wxString &prefix ); |
a35b27b1 RR |
68 | |
69 | bool Mkdir( int perm = 0777 ); | |
70 | static bool Mkdir( const wxString &dir, int perm = 0777 ); | |
71 | ||
72 | bool Rmdir(); | |
73 | static bool Rmdir( const wxString &dir ); | |
74 | ||
df5ddbca | 75 | // Remove . and .. (under Unix ~ as well) |
a35b27b1 RR |
76 | bool Normalize( const wxString &cwd = wxEmptyString, const wxString &home = wxEmptyString ); |
77 | ||
df5ddbca | 78 | // Comparison |
a35b27b1 RR |
79 | bool SameAs( const wxFileName &filepath, bool upper_case = TRUE ); |
80 | ||
df5ddbca RR |
81 | // Tests |
82 | bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE ); | |
83 | bool IsRelative( wxPathFormat format = wxPATH_NATIVE ); | |
84 | bool IsAbsolute( wxPathFormat format = wxPATH_NATIVE ); | |
85 | bool IsWild( wxPathFormat format = wxPATH_NATIVE ); | |
a35b27b1 | 86 | |
df5ddbca RR |
87 | // Dir accessors |
88 | void AppendDir( const wxString &dir ); | |
89 | void PrependDir( const wxString &dir ); | |
90 | void InsertDir( int before, const wxString &dir ); | |
91 | void RemoveDir( int pos ); | |
92 | size_t GetDirCount() { return m_dirs.GetCount(); } | |
a35b27b1 | 93 | |
df5ddbca RR |
94 | // Other accessors |
95 | void SetExt( const wxString &ext ) { m_ext = ext; } | |
96 | wxString GetExt() const { return m_ext; } | |
97 | bool HasExt() const { return !m_ext.IsEmpty(); } | |
a35b27b1 | 98 | |
df5ddbca RR |
99 | void SetName( const wxString &name ) { m_name = name; } |
100 | wxString GetName() const { return m_name; } | |
101 | bool HasName() const { return !m_name.IsEmpty(); } | |
a35b27b1 RR |
102 | |
103 | // name and ext | |
104 | void SetFullName( const wxString name, wxPathFormat format = wxPATH_NATIVE ); | |
105 | wxString GetFullName(); | |
106 | ||
df5ddbca | 107 | const wxArrayString &GetDirs() const { return m_dirs; } |
a35b27b1 | 108 | |
df5ddbca | 109 | // Construct path only |
a35b27b1 RR |
110 | wxString GetPath( bool add_separator = FALSE, wxPathFormat format = wxPATH_NATIVE ) const; |
111 | ||
df5ddbca RR |
112 | // Construct full path with name and ext |
113 | wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const; | |
a35b27b1 RR |
114 | |
115 | ||
df5ddbca | 116 | static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE ); |
a35b27b1 | 117 | |
df5ddbca RR |
118 | private: |
119 | wxArrayString m_dirs; | |
120 | wxString m_name; | |
121 | wxString m_ext; | |
122 | }; | |
123 | ||
124 | ||
125 | ||
126 | #endif // _WX_FFILENAME_H_ | |
127 |