]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/filename.h
ed12d77dc207ff8ba27c90b8b4591b33db9b8018
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileName - encapsulates a file path
4 // Author: Robert Roebling
8 // Copyright: (c) 2000 Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FILENAME_H_
13 #define _WX_FILENAME_H_
16 #pragma interface "filename.h"
20 #include "wx/string.h"
23 // ridiculously enough, this will replace DirExists with wxDirExists etc
24 #include "wx/filefn.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
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
40 wxPATH_BEOS
= wxPATH_UNIX
,
41 wxPATH_WIN
= wxPATH_DOS
,
42 wxPATH_OS2
= wxPATH_DOS
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
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
55 // ----------------------------------------------------------------------------
56 // wxFileName: encapsulates a file path
57 // ----------------------------------------------------------------------------
59 class WXDLLEXPORT wxFileName
62 // constructors and assignment
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
);
73 static bool FileExists( const wxString
&file
);
76 static bool DirExists( const wxString
&dir
);
79 static wxString
GetCwd();
82 static bool SetCwd( const wxString
&cwd
);
85 static wxString
GetHomeDir();
87 void AssignTempFileName( const wxString
&prefix
);
89 bool Mkdir( int perm
= 0777 );
90 static bool Mkdir( const wxString
&dir
, int perm
= 0777 );
93 static bool Rmdir( const wxString
&dir
);
95 // Remove . and .. (under Unix ~ as well)
96 bool Normalize( const wxString
&cwd
= wxEmptyString
, const wxString
&home
= wxEmptyString
);
99 bool SameAs( const wxFileName
&filepath
, bool upper_case
= TRUE
);
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
);
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(); }
115 void SetExt( const wxString
&ext
) { m_ext
= ext
; }
116 wxString
GetExt() const { return m_ext
; }
117 bool HasExt() const { return !m_ext
.IsEmpty(); }
119 void SetName( const wxString
&name
) { m_name
= name
; }
120 wxString
GetName() const { return m_name
; }
121 bool HasName() const { return !m_name
.IsEmpty(); }
124 void SetFullName( const wxString name
, wxPathFormat format
= wxPATH_NATIVE
);
125 wxString
GetFullName();
127 const wxArrayString
&GetDirs() const { return m_dirs
; }
129 // Construct path only
130 wxString
GetPath( bool add_separator
= FALSE
, wxPathFormat format
= wxPATH_NATIVE
) const;
132 // Construct full path with name and ext
133 wxString
GetFullPath( wxPathFormat format
= wxPATH_NATIVE
) const;
136 static wxPathFormat
GetFormat( wxPathFormat format
= wxPATH_NATIVE
);
139 wxArrayString m_dirs
;
144 #endif // _WX_FILENAME_H_