2008-03-08 13:52:38 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Name: filefn.h
|
2008-03-19 08:02:01 +00:00
|
|
|
|
// Purpose: interface of wxPathList and file functions
|
2008-03-08 13:52:38 +00:00
|
|
|
|
// Author: wxWidgets team
|
2010-07-13 13:29:13 +00:00
|
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@class wxPathList
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
The path list is a convenient way of storing a number of directories, and
|
2008-03-19 08:02:01 +00:00
|
|
|
|
when presented with a filename without a directory, searching for an
|
|
|
|
|
existing file in those directories.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Be sure to look also at wxStandardPaths if you only want to search files in
|
|
|
|
|
some standard paths.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
@library{wxbase}
|
|
|
|
|
@category{file}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
@see wxArrayString, wxStandardPaths, wxFileName
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
class wxPathList : public wxArrayString
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-06-13 14:30:55 +00:00
|
|
|
|
/**
|
|
|
|
|
Standard constructor.
|
|
|
|
|
*/
|
2008-04-01 13:55:38 +00:00
|
|
|
|
wxPathList();
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/**
|
|
|
|
|
Constructs the object calling the Add() function.
|
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
|
wxPathList(const wxArrayString& arr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-04-01 13:55:38 +00:00
|
|
|
|
Adds the given directory to the path list, if the @a path is not already in the list.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
If the path cannot be normalized for some reason, it returns @false.
|
2008-04-01 13:55:38 +00:00
|
|
|
|
|
|
|
|
|
The @a path is always considered to be a directory but no existence checks will be
|
|
|
|
|
done on it (because if it doesn't exist, it could be created later and thus result a
|
|
|
|
|
valid path when FindValidPath() is called).
|
|
|
|
|
|
|
|
|
|
@note if the given path is relative, it won't be made absolute before adding it
|
|
|
|
|
(this is why FindValidPath() may return relative paths).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool Add(const wxString& path);
|
2008-04-01 13:55:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Adds all elements of the given array as paths.
|
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
|
void Add(const wxArrayString& arr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Finds the value of the given environment variable, and adds all paths
|
2008-04-01 13:55:38 +00:00
|
|
|
|
to the path list.
|
|
|
|
|
|
|
|
|
|
Useful for finding files in the @c PATH variable, for example.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
void AddEnvList(const wxString& env_variable);
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-01 13:55:38 +00:00
|
|
|
|
Given a full filename (with path), calls Add() with the path of the file.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool EnsureFileAccessible(const wxString& filename);
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-01 13:55:38 +00:00
|
|
|
|
Like FindValidPath() but this function always returns an absolute path
|
|
|
|
|
(eventually prepending the current working directory to the value returned
|
|
|
|
|
wxPathList::FindValidPath()) or an empty string.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
|
wxString FindAbsoluteValidPath(const wxString& file) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Searches the given file in all paths stored in this class.
|
2008-04-01 13:55:38 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
The first path which concatenated to the given string points to an existing
|
2008-03-19 08:02:01 +00:00
|
|
|
|
file (see wxFileExists()) is returned.
|
2008-04-01 13:55:38 +00:00
|
|
|
|
|
|
|
|
|
If the file wasn't found in any of the stored paths, an empty string is returned.
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
The given string must be a file name, eventually with a path prefix (if the path
|
|
|
|
|
prefix is absolute, only its name will be searched); i.e. it must not end with
|
2008-04-01 13:55:38 +00:00
|
|
|
|
a directory separator (see wxFileName::GetPathSeparator) otherwise an assertion
|
|
|
|
|
will fail.
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
The returned path may be relative to the current working directory.
|
2008-04-01 13:55:38 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
Note in fact that wxPathList can be used to store both relative and absolute
|
2008-04-01 13:55:38 +00:00
|
|
|
|
paths so that if you added relative paths, then the current working directory
|
|
|
|
|
(see wxGetCwd() and wxSetWorkingDirectory()) may affect the value returned
|
|
|
|
|
by this function!
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
|
wxString FindValidPath(const wxString& file) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
// ============================================================================
|
|
|
|
|
// Global functions/macros
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
2009-01-05 20:48:06 +00:00
|
|
|
|
/** @addtogroup group_funcmacro_file */
|
2008-03-19 08:02:01 +00:00
|
|
|
|
//@{
|
|
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
|
/**
|
|
|
|
|
A special return value of many wxWidgets classes to indicate that
|
|
|
|
|
an invalid offset was given.
|
|
|
|
|
*/
|
|
|
|
|
const int wxInvalidOffset = -1;
|
|
|
|
|
|
2008-12-14 15:05:18 +00:00
|
|
|
|
/**
|
|
|
|
|
The type used to store and provide byte offsets or byte sizes for files or streams.
|
|
|
|
|
|
2012-06-23 12:27:14 +00:00
|
|
|
|
This type is usually just a synonym for @c off_t but can be defined as
|
|
|
|
|
@c wxLongLong_t if @c wxHAS_HUGE_FILES is defined but @c off_t is only 32
|
|
|
|
|
bits.
|
2008-12-14 15:05:18 +00:00
|
|
|
|
*/
|
|
|
|
|
typedef off_t wxFileOffset;
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
/**
|
|
|
|
|
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 @a mask in its constructor and restores it in its destructor.
|
|
|
|
|
Under other platforms this macro expands to nothing.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
|
|
|
|
*/
|
2008-10-30 10:32:10 +00:00
|
|
|
|
#define wxCHANGE_UMASK(mask)
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/**
|
|
|
|
|
This function returns the total number of bytes and number of free bytes on
|
2008-03-19 08:02:01 +00:00
|
|
|
|
the disk containing the directory @a path (it should exist). Both @a total
|
|
|
|
|
and @a free parameters may be @NULL if the corresponding information is not
|
|
|
|
|
needed.
|
|
|
|
|
|
2008-04-21 10:34:23 +00:00
|
|
|
|
@since 2.3.2
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@note The generic Unix implementation depends on the system having the
|
|
|
|
|
@c statfs() or @c statvfs() function.
|
|
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
|
@return @true on success, @false if an error occurred (for example, the
|
2008-03-19 08:02:01 +00:00
|
|
|
|
directory doesn’t exist).
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool wxGetDiskSpace(const wxString& path,
|
2008-03-09 12:33:59 +00:00
|
|
|
|
wxLongLong total = NULL,
|
|
|
|
|
wxLongLong free = NULL);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Returns the Windows directory under Windows; other platforms return an
|
2008-03-08 13:52:38 +00:00
|
|
|
|
empty string.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxString wxGetOSDirectory();
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Parses the @a 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. @a wildCard is in the form:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
@code
|
|
|
|
|
"All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
|
|
|
|
|
@endcode
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
int wxParseCommonDialogsFilter(const wxString& wildCard,
|
|
|
|
|
wxArrayString& descriptions,
|
|
|
|
|
wxArrayString& filters);
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Converts a DOS to a Unix filename by replacing backslashes with forward
|
|
|
|
|
slashes.
|
|
|
|
|
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated
|
|
|
|
|
Construct a wxFileName with wxPATH_DOS and then use
|
|
|
|
|
wxFileName::GetFullPath(wxPATH_UNIX) instead.
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
@header{wx/filefn.h}
|
|
|
|
|
*/
|
|
|
|
|
void wxDos2UnixFilename(wxChar* s);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Converts a Unix to a DOS filename by replacing forward slashes with
|
|
|
|
|
backslashes.
|
|
|
|
|
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated
|
|
|
|
|
Construct a wxFileName with wxPATH_UNIX and then use
|
|
|
|
|
wxFileName::GetFullPath(wxPATH_DOS) instead.
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
|
void wxUnix2DosFilename(wxChar* s);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
|
Returns @true if @a dirname exists and is a directory.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool wxDirExists(const wxString& dirname);
|
|
|
|
|
|
|
|
|
|
/**
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated
|
|
|
|
|
This function is obsolete, please use wxFileName::SplitPath() instead.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
This function splits a full file name into components: the path (including
|
2008-03-19 08:02:01 +00:00
|
|
|
|
possible disk/drive specification under Windows), the base name, and the
|
|
|
|
|
extension. Any of the output parameters (@a path, @a name or @a ext) may be
|
|
|
|
|
@NULL if you are not interested in the value of a particular component.
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
wxSplitPath() will correctly handle filenames with both DOS and Unix path
|
2008-03-19 08:02:01 +00:00
|
|
|
|
separators under Windows, however it will not consider backslashes as path
|
|
|
|
|
separators under Unix (where backslash is a valid character in a filename).
|
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
|
On entry, @a fullname should be non-@NULL (it may be empty though).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
On return, @a path contains the file path (without the trailing separator),
|
|
|
|
|
@a name contains the file name and @c 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).
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
void wxSplitPath(const wxString& fullname,
|
|
|
|
|
wxString* path,
|
|
|
|
|
wxString* name,
|
|
|
|
|
wxString* ext);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns time of last modification of given file.
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
The function returns <tt>(time_t)-1</tt> if an error occurred (e.g. file
|
|
|
|
|
not found).
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
time_t wxFileModificationTime(const wxString& filename);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2016-11-21 17:22:22 +00:00
|
|
|
|
Renames @a oldpath to @e newpath, returning @true if successful.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
2016-11-21 17:22:22 +00:00
|
|
|
|
If @a newpath is a directory, @a oldpath is moved into it (@a overwrite is
|
|
|
|
|
ignored in this case). Otherwise, if @a newpath is an existing file, it is
|
2010-11-08 16:28:57 +00:00
|
|
|
|
overwritten if @a overwrite is @true (default) and the function fails if @a
|
|
|
|
|
overwrite is @false.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2016-11-21 17:22:22 +00:00
|
|
|
|
bool wxRenameFile(const wxString& oldpath,
|
|
|
|
|
const wxString& newpath,
|
2008-03-19 08:02:01 +00:00
|
|
|
|
bool overwrite = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2016-11-21 17:22:22 +00:00
|
|
|
|
Copies @a src to @e dest, returning @true if successful. If @a overwrite
|
2008-03-19 08:02:01 +00:00
|
|
|
|
parameter is @true (default), the destination file is overwritten if it
|
|
|
|
|
exists, but if @a overwrite is @false, the functions fails in this case.
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
This function supports resources forks under Mac OS.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2016-11-21 17:22:22 +00:00
|
|
|
|
bool wxCopyFile(const wxString& src,
|
|
|
|
|
const wxString& dest,
|
2008-03-19 08:02:01 +00:00
|
|
|
|
bool overwrite = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns @true if the file exists and is a plain file.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool wxFileExists(const wxString& filename);
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Returns @true if the @a pattern matches the @e text; if @a dot_special is
|
|
|
|
|
@true, filenames beginning with a dot are not matched with wildcard
|
|
|
|
|
characters.
|
|
|
|
|
|
|
|
|
|
@see wxIsWild()
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
bool wxMatchWild(const wxString& pattern,
|
|
|
|
|
const wxString& text,
|
|
|
|
|
bool dot_special);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated This function is deprecated, use wxGetCwd() instead.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
|
@a sz is the size of the buffer if supplied.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
|
wxString wxGetWorkingDirectory(char* buf = NULL, int sz = 1000);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns the directory part of the filename.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxString wxPathOnly(const wxString& path);
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Returns @true if the pattern contains wildcards.
|
|
|
|
|
|
|
|
|
|
@see wxMatchWild()
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool wxIsWild(const wxString& pattern);
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
/**
|
2012-12-01 00:14:07 +00:00
|
|
|
|
Returns @true if the argument is an absolute filename, i.e.\ with a slash
|
2008-03-19 08:02:01 +00:00
|
|
|
|
or drive name at the beginning.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
|
|
|
|
*/
|
|
|
|
|
bool wxIsAbsolutePath(const wxString& filename);
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns a string containing the current (or working) directory.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxString wxGetCwd();
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Sets the current working directory, returning @true if the operation
|
|
|
|
|
succeeded. Under MS Windows, the current drive is also changed if @a dir
|
|
|
|
|
contains a drive specification.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
bool wxSetWorkingDirectory(const wxString& dir);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2016-11-21 17:22:22 +00:00
|
|
|
|
Concatenates @a src1 and @a src2 to @e dest, returning @true if
|
2008-03-19 08:02:01 +00:00
|
|
|
|
successful.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2016-11-21 17:22:22 +00:00
|
|
|
|
bool wxConcatFiles(const wxString& src1,
|
|
|
|
|
const wxString& src2,
|
|
|
|
|
const wxString& dest);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Removes @e file, returning @true if successful.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
bool wxRemoveFile(const wxString& file);
|
|
|
|
|
|
2010-02-10 11:38:41 +00:00
|
|
|
|
/**
|
|
|
|
|
File permission bit names.
|
|
|
|
|
|
|
|
|
|
We define these constants in wxWidgets because S_IREAD &c are not standard.
|
|
|
|
|
However, we do assume that the values correspond to the Unix umask bits.
|
|
|
|
|
*/
|
|
|
|
|
enum wxPosixPermissions
|
|
|
|
|
{
|
|
|
|
|
/// Standard POSIX names for these permission flags with "wx" prefix.
|
|
|
|
|
//@{
|
|
|
|
|
wxS_IRUSR = 00400,
|
|
|
|
|
wxS_IWUSR = 00200,
|
|
|
|
|
wxS_IXUSR = 00100,
|
|
|
|
|
|
|
|
|
|
wxS_IRGRP = 00040,
|
|
|
|
|
wxS_IWGRP = 00020,
|
|
|
|
|
wxS_IXGRP = 00010,
|
|
|
|
|
|
|
|
|
|
wxS_IROTH = 00004,
|
|
|
|
|
wxS_IWOTH = 00002,
|
|
|
|
|
wxS_IXOTH = 00001,
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/// Longer but more readable synonyms for the constants above.
|
|
|
|
|
//@{
|
|
|
|
|
wxPOSIX_USER_READ = wxS_IRUSR,
|
|
|
|
|
wxPOSIX_USER_WRITE = wxS_IWUSR,
|
|
|
|
|
wxPOSIX_USER_EXECUTE = wxS_IXUSR,
|
|
|
|
|
|
|
|
|
|
wxPOSIX_GROUP_READ = wxS_IRGRP,
|
|
|
|
|
wxPOSIX_GROUP_WRITE = wxS_IWGRP,
|
|
|
|
|
wxPOSIX_GROUP_EXECUTE = wxS_IXGRP,
|
|
|
|
|
|
|
|
|
|
wxPOSIX_OTHERS_READ = wxS_IROTH,
|
|
|
|
|
wxPOSIX_OTHERS_WRITE = wxS_IWOTH,
|
|
|
|
|
wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH,
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/// Default mode for the new files: allow reading/writing them to everybody but
|
|
|
|
|
/// the effective file mode will be set after ANDing this value with umask and
|
|
|
|
|
/// so won't include wxS_IW{GRP,OTH} for the default 022 umask value
|
|
|
|
|
wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \
|
|
|
|
|
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \
|
|
|
|
|
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE),
|
|
|
|
|
|
|
|
|
|
/// Default mode for the new directories (see wxFileName::Mkdir): allow
|
|
|
|
|
/// reading/writing/executing them to everybody, but just like wxS_DEFAULT
|
|
|
|
|
/// the effective directory mode will be set after ANDing this value with umask
|
|
|
|
|
wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \
|
|
|
|
|
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \
|
|
|
|
|
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE)
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Makes the directory @a dir, returning @true if successful.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
|
@a perm is the access mask for the directory for the systems on which it is
|
2008-03-08 13:52:38 +00:00
|
|
|
|
supported (Unix) and doesn't have any effect on the other ones.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2010-02-10 11:38:41 +00:00
|
|
|
|
bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Removes the directory @a dir, returning @true if successful. Does not work
|
|
|
|
|
under VMS.
|
|
|
|
|
|
|
|
|
|
The @a flags parameter is reserved for future use.
|
|
|
|
|
|
|
|
|
|
@note There is also a wxRmDir() function which simply wraps the standard
|
|
|
|
|
POSIX @c 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.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
bool wxRmdir(const wxString& dir, int flags = 0);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-03-10 15:24:38 +00:00
|
|
|
|
Returns the next file that matches the path passed to wxFindFirstFile().
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
See wxFindFirstFile() for an example.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxString wxFindNextFile();
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
This function does directory searching; returns the first file that matches
|
|
|
|
|
the path @a 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 2.5.2, these functions are not thread-safe! (they use static
|
|
|
|
|
variables). You probably want to use wxDir::GetFirst() or
|
|
|
|
|
wxDirTraverser instead.
|
|
|
|
|
|
|
|
|
|
@a spec may contain wildcards.
|
|
|
|
|
|
|
|
|
|
@a flags may be wxDIR for restricting the query to directories, wxFILE for
|
|
|
|
|
files or zero for either.
|
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
wxString f = wxFindFirstFile("/home/project/*.*");
|
|
|
|
|
while ( !f.empty() )
|
|
|
|
|
{
|
|
|
|
|
...
|
|
|
|
|
f = wxFindNextFile();
|
|
|
|
|
}
|
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxString wxFindFirstFile(const wxString& spec, int flags = 0);
|
|
|
|
|
|
2012-02-23 16:33:13 +00:00
|
|
|
|
/**
|
|
|
|
|
Parameter indicating how file offset should be interpreted.
|
|
|
|
|
|
|
|
|
|
This is used by wxFFile::Seek() and wxFile::Seek().
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
|
|
|
|
*/
|
|
|
|
|
enum wxSeekMode
|
|
|
|
|
{
|
|
|
|
|
wxFromStart, ///< Seek from the file beginning.
|
|
|
|
|
wxFromCurrent, ///< Seek from the current position.
|
|
|
|
|
wxFromEnd ///< Seek from end of the file.
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
/**
|
|
|
|
|
File kind enumerations returned from wxGetFileKind().
|
|
|
|
|
|
2012-02-23 16:33:13 +00:00
|
|
|
|
Also used by wxFFile::GetKind() and wxFile::GetKind().
|
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
@header{wx/filefn.h}
|
|
|
|
|
*/
|
|
|
|
|
enum wxFileKind
|
|
|
|
|
{
|
|
|
|
|
wxFILE_KIND_UNKNOWN, ///< Unknown file kind, or unable to determine
|
|
|
|
|
wxFILE_KIND_DISK, ///< A file supporting seeking to arbitrary offsets
|
|
|
|
|
wxFILE_KIND_TERMINAL, ///< A tty
|
|
|
|
|
wxFILE_KIND_PIPE ///< A pipe
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
2009-01-05 20:48:06 +00:00
|
|
|
|
/** @addtogroup group_funcmacro_file */
|
2008-03-08 13:52:38 +00:00
|
|
|
|
//@{
|
|
|
|
|
/**
|
2008-03-19 08:02:01 +00:00
|
|
|
|
Returns the type of an open file. Possible return values are enumerations
|
|
|
|
|
of ::wxFileKind.
|
2008-03-09 12:33:59 +00:00
|
|
|
|
|
2008-03-19 08:02:01 +00:00
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
|
|
|
|
wxFileKind wxGetFileKind(int fd);
|
2008-03-09 12:33:59 +00:00
|
|
|
|
wxFileKind wxGetFileKind(FILE* fp);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
//@}
|
|
|
|
|
|
2009-01-05 20:48:06 +00:00
|
|
|
|
/** @addtogroup group_funcmacro_file */
|
2008-03-08 13:52:38 +00:00
|
|
|
|
//@{
|
|
|
|
|
/**
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated
|
|
|
|
|
This function is obsolete, please use wxFileName::SplitPath() instead.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
Returns the filename for a full path. The second form returns a pointer to
|
|
|
|
|
temporary storage that should not be deallocated.
|
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
wxString wxFileNameFromPath(const wxString& path);
|
|
|
|
|
char* wxFileNameFromPath(char* path);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
//@}
|
|
|
|
|
|
2009-01-05 20:48:06 +00:00
|
|
|
|
/** @addtogroup group_funcmacro_file */
|
2008-03-19 08:02:01 +00:00
|
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
/**
|
2009-01-07 01:29:54 +00:00
|
|
|
|
@deprecated
|
|
|
|
|
This function is obsolete, please use wxFileName::CreateTempFileName() instead.
|
2008-03-19 08:02:01 +00:00
|
|
|
|
|
|
|
|
|
@header{wx/filefn.h}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
*/
|
2008-03-19 08:02:01 +00:00
|
|
|
|
char* wxGetTempFileName(const wxString& prefix, char* buf = NULL);
|
|
|
|
|
bool wxGetTempFileName(const wxString& prefix, wxString& buf);
|
|
|
|
|
//@}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|