file functionsinclude files <wx/filefn.h> see also
wxpathlist
::wxdos2unixfilename
::wxdos2unixfilenamevoid wxdos2unixfilename(wxchar *s) converts a dos to a unix filename by replacing backslashes with forward slashes.
::wxfileexistsbool wxfileexists(const wxstring& filename) returns true if the file exists and is a plain file.
::wxfilemodificationtimetime_t wxfilemodificationtime(const wxstring& filename) returns time of last modification of given file. the function returns (time_t)-1 if an error occurred (e.g. file not found).
::wxfilenamefrompathwxstring wxfilenamefrompath(const wxstring& path) char * wxfilenamefrompath(char *path) nb: this function is obsolete, please use wxfilename::splitpath instead. returns the filename for a full path. the second form returns a pointer to temporary storage that should not be deallocated.
::wxfindfirstfilewxstring wxfindfirstfile(const char *spec, int flags = 0) this function does directory searching; returns the first file that matches the path spec, or the empty string. use wxfindnextfile to get the next matching file. neither will report the current directory "." or the parent directory "..". warning as of wx 2.5.2, these functions are not thread-safe! (they use static variables). you probably want to use wxdir::getfirst or wxdirtraverser instead. spec may contain wildcards. flags may be wxdir for restricting the query to directories, wxfile for files or zero for either. for example:
wxstring f = wxfindfirstfile("/home/project/*.*"); while ( !f.empty() ) { ... f = wxfindnextfile(); } ::wxfindnextfilewxstring wxfindnextfile() returns the next file that matches the path passed to wxfindfirstfile. see wxfindfirstfile for an example.
::wxgetdiskspacebool wxgetdiskspace(const wxstring& path, wxlonglong *total = null, wxlonglong *free = null) this function returns the total number of bytes and number of free bytes on the disk containing the directory path (it should exist). both total and free parameters may be null if the corresponding information is not needed. returns true on success, false if an error occurred (for example, the directory doesn't exist). portability this function is implemented for win32, mac os and generic unix provided the system has statfs() function. this function first appeared in wxwidgets 2.3.2.
::wxgetfilekindwxfilekind wxgetfilekind(int fd) wxfilekind wxgetfilekind(file *fp) returns the type of an open file. possible return values are:
enum wxfilekind { wxfile_kind_unknown, wxfile_kind_disk, // a file supporting seeking to arbitrary offsets wxfile_kind_terminal, // a tty wxfile_kind_pipe // a pipe };include files <wx/filefn.h>
::wxgetosdirectorywxstring wxgetosdirectory() returns the windows directory under windows; on other platforms returns the empty string.
::wxisabsolutepathbool wxisabsolutepath(const wxstring& filename) returns true if the argument is an absolute filename, i.e. with a slash or drive name at the beginning.
::wxdirexistsbool wxdirexists(const wxchar *dirname) returns true if dirname exists and is a directory.
::wxpathonlywxstring wxpathonly(const wxstring& path) returns the directory part of the filename.
::wxunix2dosfilenamevoid wxunix2dosfilename(wxchar *s) this function is deprecated, use wxfilename instead. converts a unix to a dos filename by replacing forward slashes with backslashes.
wxchange_umaskwxchange_umask(int mask) under unix this macro changes the current process umask to the given value, unless it is equal to -1 in which case nothing is done, and restores it to the original value on scope exit. it works by declaring a variable which sets umask to mask in its constructor and restores it in its destructor. under other platforms this macro expands to nothing.
::wxconcatfilesbool wxconcatfiles(const wxstring& file1, const wxstring& file2, const wxstring& file3) concatenates file1 and file2 to file3, returning true if successful.
::wxcopyfilebool wxcopyfile(const wxstring& file1, const wxstring& file2, bool overwrite = true) copies file1 to file2, returning true if successful. if overwrite parameter is true (default), the destination file is overwritten if it exists, but if overwrite is false, the functions fails in this case.
::wxgetcwdwxstring wxgetcwd() returns a string containing the current (or working) directory.
::wxgetworkingdirectorywxstring wxgetworkingdirectory(char *buf=null, int sz=1000) nb: this function is deprecated: use wxgetcwd instead. 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. sz is the size of the buffer if supplied.
::wxgettempfilenamechar * wxgettempfilename(const wxstring& prefix, char *buf=null) bool wxgettempfilename(const wxstring& prefix, wxstring& buf) nb: these functions are obsolete, please use wxfilename::createtempfilename instead.
::wxiswildbool wxiswild(const wxstring& pattern) returns true if the pattern contains wildcards. see wxmatchwild.
::wxmatchwildbool wxmatchwild(const wxstring& pattern, const wxstring& text, bool dot_special) returns true if the pattern matches the text; if dot_special is true, filenames beginning with a dot are not matched with wildcard characters. see wxiswild.
::wxmkdirbool wxmkdir(const wxstring& dir, int perm = 0777) makes the directory dir, returning true if successful. perm is the access mask for the directory for the systems on which it is supported (unix) and doesn't have any effect on the other ones.
::wxparsecommondialogsfilterint wxparsecommondialogsfilter(const wxstring& wildcard, wxarraystring& descriptions, wxarraystring& filters) parses the wildcard, returning the number of filters. returns 0 if none or if there's a problem. the arrays will contain an equal number of items found before the error. on platforms where native dialogs handle only one filter per entry, entries in arrays are automatically adjusted. wildcard is in the form: "all files (*)|*|image files (*.jpeg *.png)|*.jpg;*.png" ::wxremovefilebool wxremovefile(const wxstring& file) removes file, returning true if successful.
::wxrenamefilebool wxrenamefile(const wxstring& file1, const wxstring& file2, bool overwrite = true) renames file1 to file2, returning true if successful. if overwrite parameter is true (default), the destination file is overwritten if it exists, but if overwrite is false, the functions fails in this case.
::wxrmdirbool wxrmdir(const wxstring& dir, int flags=0) removes the directory dir, returning true if successful. does not work under vms. the flags parameter is reserved for future use. please notice that there is also a wxrmdir() function which simply wraps the standard posix rmdir() function and so return an integer error code instead of a boolean value (but otherwise is currently identical to wxrmdir), don't confuse these two functions.
::wxsetworkingdirectorybool wxsetworkingdirectory(const wxstring& dir) sets the current working directory, returning true if the operation succeeded. under ms windows, the current drive is also changed if dir contains a drive specification.
::wxsplitpathvoid wxsplitpath(const char * fullname, wxstring * path, wxstring * name, wxstring * ext) nb: this function is obsolete, please use wxfilename::splitpath instead. 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 (path, name or ext) may be null if you are not interested in the value of a particular component. 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). on entry, fullname should be non-null (it may be empty though). on return, path contains the file path (without the trailing separator), name contains the file name and ext 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).
::wxtransferfiletostreambool wxtransferfiletostream(const wxstring& filename, ostream& stream) copies the given file to stream. useful when converting an old application to use streams (within the document/view framework, for example). include files <wx/docview.h>
::wxtransferstreamtofilebool wxtransferstreamtofile(istream& stream const wxstring& filename) copies the given stream to the file filename. useful when converting an old application to use streams (within the document/view framework, for example). include files <wx/docview.h>
|