]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/filefn.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: File- and directory-related functions
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "filefn.h"
21 bool WXDLLEXPORT
wxFileExists(const wxString
& filename
);
22 #define FileExists wxFileExists
24 // does the path exist? (may have or not '/' or '\\' at the end)
25 bool WXDLLEXPORT
wxPathExists(const char *pszPathName
);
27 #define wxDirExists wxPathExists
28 #define DirExists wxDirExists
30 bool WXDLLEXPORT
wxIsAbsolutePath(const wxString
& filename
);
31 #define IsAbsolutePath wxIsAbsolutePath
34 char* WXDLLEXPORT
wxFileNameFromPath(char *path
);
35 wxString WXDLLEXPORT
wxFileNameFromPath(const wxString
& path
);
36 #define FileNameFromPath wxFileNameFromPath
39 char* WXDLLEXPORT
wxPathOnly(char *path
);
40 wxString WXDLLEXPORT
wxPathOnly(const wxString
& path
);
41 #define PathOnly wxPathOnly
44 wxString WXDLLEXPORT
wxRealPath(const wxString
& path
);
46 void WXDLLEXPORT
wxDos2UnixFilename(char *s
);
47 #define Dos2UnixFilename wxDos2UnixFilename
49 void WXDLLEXPORT
wxUnix2DosFilename(char *s
);
50 #define Unix2DosFilename wxUnix2DosFilename
52 // Strip the extension, in situ
53 void WXDLLEXPORT
wxStripExtension(char *buffer
);
55 // Get a temporary filename, opening and closing the file.
56 char* WXDLLEXPORT
wxGetTempFileName(const wxString
& prefix
, char *buf
= NULL
);
58 // Expand file name (~/ and ${OPENWINHOME}/ stuff)
59 char* WXDLLEXPORT
wxExpandPath(char *dest
, const char *path
);
61 // Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
62 // and make (if under the home tree) relative to home
63 // [caller must copy-- volatile]
64 char* WXDLLEXPORT
wxContractPath (const wxString
& filename
,
65 const wxString
& envname
= "", const wxString
& user
= "");
67 // Destructive removal of /./ and /../ stuff
68 char* WXDLLEXPORT
wxRealPath(char *path
);
70 // Allocate a copy of the full absolute path
71 char* WXDLLEXPORT
wxCopyAbsolutePath(const wxString
& path
);
73 // Get first file name matching given wild card.
74 // Flags are reserved for future use.
77 char* WXDLLEXPORT
wxFindFirstFile(const char *spec
, int flags
= wxFILE
);
78 char* WXDLLEXPORT
wxFindNextFile(void);
80 // Does the pattern contain wildcards?
81 bool WXDLLEXPORT
wxIsWild(const wxString
& pattern
);
83 // Does the pattern match the text (usually a filename)?
84 // If dot_special is TRUE, doesn't match * against . (eliminating
85 // `hidden' dot files)
86 bool WXDLLEXPORT
wxMatchWild(const wxString
& pattern
, const wxString
& text
, bool dot_special
= TRUE
);
88 // Concatenate two files to form third
89 bool WXDLLEXPORT
wxConcatFiles(const wxString
& file1
, const wxString
& file2
, const wxString
& file3
);
91 // Copy file1 to file2
92 bool WXDLLEXPORT
wxCopyFile(const wxString
& file1
, const wxString
& file2
);
95 bool WXDLLEXPORT
wxRemoveFile(const wxString
& file
);
98 bool WXDLLEXPORT
wxRenameFile(const wxString
& file1
, const wxString
& file2
);
100 // Get current working directory.
101 // If buf is NULL, allocates space using new, else
103 // IMPORTANT NOTE getcwd is know not to work under some releases
104 // of Win32s 1.3, according to MS release notes!
105 char* WXDLLEXPORT
wxGetWorkingDirectory(char *buf
= NULL
, int sz
= 1000);
107 // Set working directory
108 bool WXDLLEXPORT
wxSetWorkingDirectory(const wxString
& d
);
111 bool WXDLLEXPORT
wxMkdir(const wxString
& dir
);
113 // Remove directory. Flags reserved for future use.
114 bool WXDLLEXPORT
wxRmdir(const wxString
& dir
, int flags
= 0);
116 // separators in file names
117 #define FILE_SEP_EXT '.'
118 #define FILE_SEP_DSK ':'
119 #define FILE_SEP_PATH_DOS '\\'
120 #define FILE_SEP_PATH_UNIX '/'
122 // separator in the path list (as in PATH environment variable)
123 // NB: these are strings and not characters on purpose!
124 #define PATH_SEP_DOS ";"
125 #define PATH_SEP_UNIX ":"
127 // platform independent versions
129 #define FILE_SEP_PATH FILE_SEP_PATH_UNIX
130 #define PATH_SEP PATH_SEP_UNIX
132 #define FILE_SEP_PATH FILE_SEP_PATH_DOS
133 #define PATH_SEP PATH_SEP_DOS
134 #endif // Unix/Windows
136 // is the char a path separator?
137 inline bool wxIsPathSeparator(char c
)
138 { return c
== FILE_SEP_PATH_DOS
|| c
== FILE_SEP_PATH_UNIX
; }
140 // does the string ends with path separator?
141 bool WXDLLEXPORT
wxEndsWithPathSeparator(const char *pszFileName
);
143 // find a file in a list of directories, returns false if not found
144 bool WXDLLEXPORT
wxFindFileInPath(wxString
*pStr
, const char *pszPath
, const char *pszFile
);
147 class WXDLLEXPORT wxPathList
: public wxStringList
149 DECLARE_DYNAMIC_CLASS(wxPathList
)
152 void AddEnvList(const wxString
& envVariable
); // Adds all paths in environment variable
153 void Add(const wxString
& path
);
154 wxString
FindValidPath(const wxString
& filename
); // Find the first full path
155 // for which the file exists
156 wxString
FindAbsoluteValidPath(const wxString
& filename
); // Find the first full path
157 // for which the file exists; ensure it's an absolute
158 // path that gets returned.
159 void EnsureFileAccessible(const wxString
& path
); // Given full path and filename,
161 bool Member(const wxString
& path
);