1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
|
<HTML>
<head><title>File functions</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="filefunctions"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx264.htm#functions"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx264.htm#functions"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx266.htm#topic1060"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>File functions</H2>
<P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/utils.h><P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx168.htm#wxpathlist">wxPathList</A><P>
<A HREF="#topic1044">::wxDirExists</A><BR>
<A HREF="#topic1045">::wxDos2UnixFilename</A><BR>
<A HREF="#topic1046">::wxFileExists</A><BR>
<A HREF="#topic1047">::wxFileNameFromPath</A><BR>
<A HREF="#wxfindfirstfile">::wxFindFirstFile</A><BR>
<A HREF="#wxfindnextfile">::wxFindNextFile</A><BR>
<A HREF="#wxgetosdirectory">::wxGetOSDirectory</A><BR>
<A HREF="#topic1048">::wxIsAbsolutePath</A><BR>
<A HREF="#topic1049">::wxPathOnly</A><BR>
<A HREF="#topic1050">::wxUnix2DosFilename</A><BR>
<A HREF="#topic1051">::wxConcatFiles</A><BR>
<A HREF="#topic1052">::wxCopyFile</A><BR>
<A HREF="#wxgetcwd">::wxGetCwd</A><BR>
<A HREF="#wxgethostname">::wxGetHostName</A><BR>
<A HREF="#wxgetemailaddress">::wxGetEmailAddress</A><BR>
<A HREF="#wxgetuserid">::wxGetUserId</A><BR>
<A HREF="#wxgetusername">::wxGetUserName</A><BR>
<A HREF="#topic1053">::wxGetWorkingDirectory</A><BR>
<A HREF="#topic1054">::wxGetTempFileName</A><BR>
<A HREF="#wxiswild">::wxIsWild</A><BR>
<A HREF="#wxmatchwild">::wxMatchWild</A><BR>
<A HREF="#topic1055">::wxMkdir</A><BR>
<A HREF="#topic1056">::wxRemoveFile</A><BR>
<A HREF="#topic1057">::wxRenameFile</A><BR>
<A HREF="#topic1058">::wxRmdir</A><BR>
<A HREF="#topic1059">::wxSetWorkingDirectory</A><BR>
<A HREF="#wxsplitfunction">::wxSplitPath</A><BR>
<A HREF="#wxtransferfiletostream">::wxTransferFileToStream</A><BR>
<A HREF="#wxtransferstreamtofile">::wxTransferStreamToFile</A><BR>
<P>
<HR>
<A NAME="topic1044"></A>
<H3>::wxDirExists</H3>
<P>
<B>bool</B> <B>wxDirExists</B>(<B>const wxString& </B><I>dirname</I>)<P>
Returns TRUE if the directory exists.<P>
<HR>
<A NAME="topic1045"></A>
<H3>::wxDos2UnixFilename</H3>
<P>
<B>void</B> <B>Dos2UnixFilename</B>(<B>const wxString& </B><I>s</I>)<P>
Converts a DOS to a Unix filename by replacing backslashes with forward
slashes.<P>
<HR>
<A NAME="topic1046"></A>
<H3>::wxFileExists</H3>
<P>
<B>bool</B> <B>wxFileExists</B>(<B>const wxString& </B><I>filename</I>)<P>
Returns TRUE if the file exists.<P>
<HR>
<A NAME="topic1047"></A>
<H3>::wxFileNameFromPath</H3>
<P>
<B>wxString</B> <B>wxFileNameFromPath</B>(<B>const wxString& </B><I>path</I>)<P>
<B>char*</B> <B>wxFileNameFromPath</B>(<B>char* </B><I>path</I>)<P>
Returns the filename for a full path. The second form returns a pointer to
temporary storage that should not be deallocated.<P>
<HR>
<A NAME="wxfindfirstfile"></A>
<H3>::wxFindFirstFile</H3>
<P>
<B>wxString</B> <B>wxFindFirstFile</B>(<B>const char*</B><I>spec</I>, <B>int</B><I> flags = 0</I>)<P>
This function does directory searching; returns the first file
that matches the path <I>spec</I>, or the empty string. Use <A HREF="wx265.htm#wxfindnextfile">wxFindNextFile</A> to
get the next matching file.<P>
<I>spec</I> may contain wildcards.<P>
<I>flags</I> is reserved for future use.<P>
For example:<P>
<PRE>
wxString f = wxFindFirstFile("/home/project/*.*");
while ( !f.IsEmpty() )
{
...
f = wxFindNextFile();
}
</PRE>
<HR>
<A NAME="wxfindnextfile"></A>
<H3>::wxFindNextFile</H3>
<P>
<B>wxString</B> <B>wxFindFirstFile</B>()<P>
Returns the next file that matches the path passed to <A HREF="wx265.htm#wxfindfirstfile">wxFindFirstFile</A>.<P>
<HR>
<A NAME="wxgetosdirectory"></A>
<H3>::wxGetOSDirectory</H3>
<P>
<B>wxString</B> <B>wxGetOSDirectory</B>()<P>
Returns the Windows directory under Windows; on other platforms returns the empty string.<P>
<HR>
<A NAME="topic1048"></A>
<H3>::wxIsAbsolutePath</H3>
<P>
<B>bool</B> <B>wxIsAbsolutePath</B>(<B>const wxString& </B><I>filename</I>)<P>
Returns TRUE if the argument is an absolute filename, i.e. with a slash
or drive name at the beginning.<P>
<HR>
<A NAME="topic1049"></A>
<H3>::wxPathOnly</H3>
<P>
<B>wxString</B> <B>wxPathOnly</B>(<B>const wxString& </B><I>path</I>)<P>
Returns the directory part of the filename.<P>
<HR>
<A NAME="topic1050"></A>
<H3>::wxUnix2DosFilename</H3>
<P>
<B>void</B> <B>wxUnix2DosFilename</B>(<B>const wxString& </B><I>s</I>)<P>
Converts a Unix to a DOS filename by replacing forward
slashes with backslashes.<P>
<HR>
<A NAME="topic1051"></A>
<H3>::wxConcatFiles</H3>
<P>
<B>bool</B> <B>wxConcatFiles</B>(<B>const wxString& </B><I>file1</I>, <B>const wxString& </B><I>file2</I>,
<B>const wxString& </B><I>file3</I>)<P>
Concatenates <I>file1</I> and <I>file2</I> to <I>file3</I>, returning
TRUE if successful.<P>
<HR>
<A NAME="topic1052"></A>
<H3>::wxCopyFile</H3>
<P>
<B>bool</B> <B>wxCopyFile</B>(<B>const wxString& </B><I>file1</I>, <B>const wxString& </B><I>file2</I>)<P>
Copies <I>file1</I> to <I>file2</I>, returning TRUE if successful.<P>
<HR>
<A NAME="wxgetcwd"></A>
<H3>::wxGetCwd</H3>
<P>
<B>wxString</B> <B>wxGetCwd</B>()<P>
Returns a string containing the current (or working) directory.<P>
<HR>
<A NAME="wxgethostname"></A>
<H3>::wxGetHostName</H3>
<P>
<B>bool</B> <B>wxGetHostName</B>(<B>const wxString& </B><I>buf</I>, <B>int </B><I>sz</I>)<P>
Copies the current host machine's name into the supplied buffer.<P>
Under Windows or NT, this function first looks in the environment
variable SYSTEM_NAME; if this is not found, the entry <B>HostName</B>
in the <B>wxWindows</B> section of the WIN.INI file is tried.<P>
Returns TRUE if successful, FALSE otherwise.<P>
<HR>
<A NAME="wxgetemailaddress"></A>
<H3>::wxGetEmailAddress</H3>
<P>
<B>bool</B> <B>wxGetEmailAddress</B>(<B>const wxString& </B><I>buf</I>, <B>int </B><I>sz</I>)<P>
Copies the user's email address into the supplied buffer, by
concatenating the values returned by <A HREF="wx265.htm#wxgethostname">wxGetHostName</A>
and <A HREF="wx265.htm#wxgetuserid">wxGetUserId</A>.<P>
Returns TRUE if successful, FALSE otherwise.<P>
<HR>
<A NAME="wxgetuserid"></A>
<H3>::wxGetUserId</H3>
<P>
<B>bool</B> <B>wxGetUserId</B>(<B>const wxString& </B><I>buf</I>, <B>int </B><I>sz</I>)<P>
Copies the current user id into the supplied buffer.<P>
Under Windows or NT, this function first looks in the environment
variables USER and LOGNAME; if neither of these is found, the entry <B>UserId</B>
in the <B>wxWindows</B> section of the WIN.INI file is tried.<P>
Returns TRUE if successful, FALSE otherwise.<P>
<HR>
<A NAME="wxgetusername"></A>
<H3>::wxGetUserName</H3>
<P>
<B>bool</B> <B>wxGetUserName</B>(<B>const wxString& </B><I>buf</I>, <B>int </B><I>sz</I>)<P>
Copies the current user name into the supplied buffer.<P>
Under Windows or NT, this function looks for the entry <B>UserName</B>
in the <B>wxWindows</B> section of the WIN.INI file. If PenWindows
is running, the entry <B>Current</B> in the section <B>User</B> of
the PENWIN.INI file is used.<P>
Returns TRUE if successful, FALSE otherwise.<P>
<HR>
<A NAME="topic1053"></A>
<H3>::wxGetWorkingDirectory</H3>
<P>
<B>wxString</B> <B>wxGetWorkingDirectory</B>(<B>char*</B><I>buf=NULL</I>, <B>int </B><I>sz=1000</I>)<P>
This function is obsolete: use <A HREF="wx265.htm#wxgetcwd">wxGetCwd</A> instead.<P>
Copies the current working directory into the buffer if supplied, or
copies the working directory into new storage (which you must delete yourself)
if the buffer is NULL.<P>
<I>sz</I> is the size of the buffer if supplied.<P>
<HR>
<A NAME="topic1054"></A>
<H3>::wxGetTempFileName</H3>
<P>
<B>char*</B> <B>wxGetTempFileName</B>(<B>const wxString& </B><I>prefix</I>, <B>char* </B><I>buf=NULL</I>)<P>
Makes a temporary filename based on <I>prefix</I>, opens and closes the file,
and places the name in <I>buf</I>. If <I>buf</I> is NULL, new store
is allocated for the temporary filename using <I>new</I>.<P>
Under Windows, the filename will include the drive and name of the
directory allocated for temporary files (usually the contents of the
TEMP variable). Under Unix, the <TT>/tmp</TT> directory is used.<P>
It is the application's responsibility to create and delete the file.<P>
<HR>
<A NAME="wxiswild"></A>
<H3>::wxIsWild</H3>
<P>
<B>bool</B> <B>wxIsWild</B>(<B>const wxString& </B><I>pattern</I>)<P>
Returns TRUE if the pattern contains wildcards. See <A HREF="wx265.htm#wxmatchwild">wxMatchWild</A>.<P>
<HR>
<A NAME="wxmatchwild"></A>
<H3>::wxMatchWild</H3>
<P>
<B>bool</B> <B>wxMatchWild</B>(<B>const wxString& </B><I>pattern</I>, <B>const wxString& </B><I>text</I>, <B>bool</B><I> dot_special</I>)<P>
Returns TRUE if the <I>pattern</I> matches the <I>text</I>; if <I>
dot_special</I> is TRUE, filenames beginning with a dot are not matched
with wildcard characters. See <A HREF="wx265.htm#wxiswild">wxIsWild</A>.<P>
<HR>
<A NAME="topic1055"></A>
<H3>::wxMkdir</H3>
<P>
<B>bool</B> <B>wxMkdir</B>(<B>const wxString& </B><I>dir</I>)<P>
Makes the directory <I>dir</I>, returning TRUE if successful.<P>
<HR>
<A NAME="topic1056"></A>
<H3>::wxRemoveFile</H3>
<P>
<B>bool</B> <B>wxRemoveFile</B>(<B>const wxString& </B><I>file</I>)<P>
Removes <I>file</I>, returning TRUE if successful.<P>
<HR>
<A NAME="topic1057"></A>
<H3>::wxRenameFile</H3>
<P>
<B>bool</B> <B>wxRenameFile</B>(<B>const wxString& </B><I>file1</I>, <B>const wxString& </B><I>file2</I>)<P>
Renames <I>file1</I> to <I>file2</I>, returning TRUE if successful.<P>
<HR>
<A NAME="topic1058"></A>
<H3>::wxRmdir</H3>
<P>
<B>bool</B> <B>wxRmdir</B>(<B>const wxString& </B><I>dir</I>, <B>int</B><I> flags=0</I>)<P>
Removes the directory <I>dir</I>, returning TRUE if successful. Does not work under VMS.<P>
The <I>flags</I> parameter is reserved for future use.<P>
<HR>
<A NAME="topic1059"></A>
<H3>::wxSetWorkingDirectory</H3>
<P>
<B>bool</B> <B>wxSetWorkingDirectory</B>(<B>const wxString& </B><I>dir</I>)<P>
Sets the current working directory, returning TRUE if the operation succeeded.
Under MS Windows, the current drive is also changed if <I>dir</I> contains a drive specification.<P>
<HR>
<A NAME="wxsplitfunction"></A>
<H3>::wxSplitPath</H3>
<P>
<B>void</B> <B>wxSplitPath</B>(<B>const char *</B><I> fullname</I>, <B>const wxString *</B><I> path</I>, <B>const wxString *</B><I> name</I>, <B>const wxString *</B><I> ext</I>)<P>
This function splits a full file name into components: the path (including possible disk/drive
specification under Windows), the base name and the extension. Any of the output parameters
(<I>path</I>, <I>name</I> or <I>ext</I>) may be NULL if you are not interested in the value of
a particular component.<P>
wxSplitPath() will correctly handle filenames with both DOS and Unix path separators under
Windows, however it will not consider backslashes as path separators under Unix (where backslash
is a valid character in a filename).<P>
On entry, <I>fullname</I> should be non NULL (it may be empty though).<P>
On return, <I>path</I> contains the file path (without the trailing separator), <I>name</I>
contains the file name and <I>ext</I> contains the file extension without leading dot. All
three of them may be empty if the corresponding component is. The old contents of the
strings pointed to by these parameters will be overwritten in any case (if the pointers
are not NULL).<P>
<HR>
<A NAME="wxtransferfiletostream"></A>
<H3>::wxTransferFileToStream</H3>
<P>
<B>bool</B> <B>wxTransferFileToStream</B>(<B>const wxString& </B><I>filename</I>, <B>ostream& </B><I>stream</I>)<P>
Copies the given file to <I>stream</I>. Useful when converting an old application to
use streams (within the document/view framework, for example).<P>
Use of this function requires the file wx_doc.h to be included.<P>
<HR>
<A NAME="wxtransferstreamtofile"></A>
<H3>::wxTransferStreamToFile</H3>
<P>
<B>bool</B> <B>wxTransferStreamToFile</B>(<B>istream& </B><I>stream</I> <B>const wxString& </B><I>filename</I>)<P>
Copies the given stream to the file <I>filename</I>. Useful when converting an old application to
use streams (within the document/view framework, for example).<P>
Use of this function requires the file wx_doc.h to be included.<P>
</BODY></HTML>
|