just added some _T()s
[wxWidgets.git] / include / wx / filename.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filename.h
3 // Purpose: wxFileName - encapsulates a file path
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
24 #include "wx/filefn.h"
25
26 // ----------------------------------------------------------------------------
27 // constants
28 // ----------------------------------------------------------------------------
29
30 // the various values for the path format: this mainly affects the path
31 // separator but also whether or not the path has the drive part (as under
32 // Windows)
33 enum wxPathFormat
34 {
35 wxPATH_NATIVE = 0,
36 wxPATH_UNIX,
37 wxPATH_MAC,
38 wxPATH_DOS,
39
40 wxPATH_BEOS = wxPATH_UNIX,
41 wxPATH_WIN = wxPATH_DOS,
42 wxPATH_OS2 = wxPATH_DOS
43 };
44
45 // the kind of normalization to do with the file name: these values can be
46 // or'd together to perform several operations at once
47 enum wxPathNormalize
48 {
49 wxPATH_NORM_ENV_VARS = 0x0001, // replace env vars with their values
50 wxPATH_NORM_ABSOLUTE = 0x0002, // squeeze all .. and . and prepend cwd
51 wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user
52 wxPATH_NORM_ALL = 0x0007
53 };
54
55 // ----------------------------------------------------------------------------
56 // wxFileName: encapsulates a file path
57 // ----------------------------------------------------------------------------
58
59 class WXDLLEXPORT wxFileName
60 {
61 public:
62 // constructors and assignment
63 wxFileName()
64 { }
65 wxFileName( const wxFileName &filepath );
66 wxFileName( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE )
67 { Assign( path, dir_only, format ); }
68 void Assign( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE );
69 void Assign( const wxFileName &filepath );
70
71 // Only native form
72 bool FileExists();
73 static bool FileExists( const wxString &file );
74
75 bool DirExists();
76 static bool DirExists( const wxString &dir );
77
78 void AssignCwd();
79 static wxString GetCwd();
80
81 bool SetCwd();
82 static bool SetCwd( const wxString &cwd );
83
84 void AssignHomeDir();
85 static wxString GetHomeDir();
86
87 void AssignTempFileName( const wxString &prefix );
88
89 bool Mkdir( int perm = 0777 );
90 static bool Mkdir( const wxString &dir, int perm = 0777 );
91
92 bool Rmdir();
93 static bool Rmdir( const wxString &dir );
94
95 // Remove . and .. (under Unix ~ as well)
96 bool Normalize( const wxString &cwd = wxEmptyString, const wxString &home = wxEmptyString );
97
98 // Comparison
99 bool SameAs( const wxFileName &filepath, bool upper_case = TRUE );
100
101 // Tests
102 bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
103 bool IsRelative( wxPathFormat format = wxPATH_NATIVE );
104 bool IsAbsolute( wxPathFormat format = wxPATH_NATIVE );
105 bool IsWild( wxPathFormat format = wxPATH_NATIVE );
106
107 // Dir accessors
108 void AppendDir( const wxString &dir );
109 void PrependDir( const wxString &dir );
110 void InsertDir( int before, const wxString &dir );
111 void RemoveDir( int pos );
112 size_t GetDirCount() const { return m_dirs.GetCount(); }
113
114 // Other accessors
115 void SetExt( const wxString &ext ) { m_ext = ext; }
116 wxString GetExt() const { return m_ext; }
117 bool HasExt() const { return !m_ext.IsEmpty(); }
118
119 void SetName( const wxString &name ) { m_name = name; }
120 wxString GetName() const { return m_name; }
121 bool HasName() const { return !m_name.IsEmpty(); }
122
123 // name and ext
124 void SetFullName( const wxString name, wxPathFormat format = wxPATH_NATIVE );
125 wxString GetFullName();
126
127 const wxArrayString &GetDirs() const { return m_dirs; }
128
129 // Construct path only
130 wxString GetPath( bool add_separator = FALSE, wxPathFormat format = wxPATH_NATIVE ) const;
131
132 // Construct full path with name and ext
133 wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
134
135
136 static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE );
137
138 private:
139 wxArrayString m_dirs;
140 wxString m_name;
141 wxString m_ext;
142 };
143
144 #endif // _WX_FILENAME_H_
145