// Purpose: interface of wxDir and wxDirTraverser
// Author: wxWidgets team
// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
int flags = wxDIR_DEFAULT) const;
/**
- Returns the name of the directory itself. The returned string does not
- have the trailing path separator (slash or backslash).
+ Returns the name of the directory itself.
+
+ The returned string does not have the trailing path separator (slash or
+ backslash).
+
+ Notice that in spite of this the last character of the returned string
+ can still be the path separator if this directory is the root one.
+ Because of this, don't append ::wxFILE_SEP_PATH to the returned value
+ if you do need a slash-terminated directory name but use
+ GetNameWithSep() instead to avoid having duplicate consecutive slashes.
*/
wxString GetName() const;
+ /**
+ Returns the name of the directory with the path separator appended.
+
+ The last character of the returned string is always ::wxFILE_SEP_PATH
+ unless the string is empty, indicating that this directory is invalid.
+
+ @see GetName()
+
+ @since 2.9.4
+ */
+ wxString GetNameWithSep() const;
+
/**
Continue enumerating files which satisfy the criteria specified by the
last call to GetFirst().
Returns the size (in bytes) of all files recursively found in @c dir or
@c wxInvalidSize in case of error.
- In case it happens that while traversing folders a file's size can not
+ In case it happens that while traversing folders a file's size cannot
be read, that file is added to the @a filesSkipped array, if not @NULL,
and then skipped. This usually happens with some special folders which
are locked by the operating system or by another process. Remember that
*/
bool IsOpened() const;
+ /**
+ Creates a directory.
+
+ This is just an alias for wxFileName::Mkdir(); refer to that function
+ for more info.
+ */
+ static bool Make(const wxString &dir, int perm = wxS_DIR_DEFAULT,
+ int flags = 0);
+
/**
Open the directory for enumerating, returns @true on success or @false
if an error occurred.
bool Open(const wxString& dir);
/**
- Enumerate all files and directories under the given directory
- recursively calling the element of the provided wxDirTraverser object
- for each of them.
-
- More precisely, the function will really recurse into subdirectories if
- @a flags contains ::wxDIR_DIRS flag. It will ignore the files (but
- still possibly recurse into subdirectories) if ::wxDIR_FILES flag is
- given.
- See ::wxDirFlags for the list of the possible flags.
+ Removes a directory.
+
+ This is just an alias for wxFileName::Rmdir(); refer to that function
+ for more info.
+ */
+ static bool Remove(const wxString &dir, int flags = 0);
+
+ /**
+ Enumerate all files and directories under the given directory.
+
+ If @a flags contains ::wxDIR_DIRS this enumeration is recursive, i.e.
+ all the subdirectories of the given one and the files inside them will
+ be traversed. Otherwise only the files in this directory itself are.
+
+ If @a flags doesn't contain ::wxDIR_FILES then only subdirectories are
+ examined but not normal files. It doesn't make sense to not specify
+ either ::wxDIR_DIRS or ::wxDIR_FILES and usually both of them should be
+ specified, as is the case by default.
For each directory found, @ref wxDirTraverser::OnDir() "sink.OnDir()"
is called and @ref wxDirTraverser::OnFile() "sink.OnFile()" is called
for every file. Depending on the return value, the enumeration may
- continue or stop.
+ continue or stop. If entering a subdirectory fails, @ref
+ wxDirTraverser::OnOpenError() "sink.OnOpenError()" is called.
The function returns the total number of files found or @c "(size_t)-1"
on error.
+ See ::wxDirFlags for the full list of the possible flags.
+
@see GetAllFiles()
*/
size_t Traverse(wxDirTraverser& sink,