added overwrite parameter to wxRenameFile (patch 1467041)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1215,10 +1215,14 @@ Removes \arg{file}, returning true if successful.
|
|||||||
|
|
||||||
\membersection{::wxRenameFile}\label{wxrenamefile}
|
\membersection{::wxRenameFile}\label{wxrenamefile}
|
||||||
|
|
||||||
\func{bool}{wxRenameFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}}
|
\func{bool}{wxRenameFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}, \param{bool overwrite = true}}
|
||||||
|
|
||||||
Renames \arg{file1} to \arg{file2}, returning true if successful.
|
Renames \arg{file1} to \arg{file2}, returning true if successful.
|
||||||
|
|
||||||
|
If \arg{overwrite} parameter is true (default), the destination file is
|
||||||
|
overwritten if it exists, but if \arg{overwrite} is false, the functions fails
|
||||||
|
in this case.
|
||||||
|
|
||||||
|
|
||||||
\membersection{::wxRmdir}\label{wxrmdir}
|
\membersection{::wxRmdir}\label{wxrmdir}
|
||||||
|
|
||||||
|
@@ -436,7 +436,7 @@ WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& file1, const wxString& file2,
|
|||||||
WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
|
WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
|
||||||
|
|
||||||
// Rename file
|
// Rename file
|
||||||
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2);
|
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite = true);
|
||||||
|
|
||||||
// Get current working directory.
|
// Get current working directory.
|
||||||
#if WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6
|
||||||
|
@@ -1106,8 +1106,19 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wxRenameFile (const wxString& file1, const wxString& file2)
|
wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
|
||||||
{
|
{
|
||||||
|
if ( !overwrite && wxFileExists(file2) )
|
||||||
|
{
|
||||||
|
wxLogSysError
|
||||||
|
(
|
||||||
|
_("Failed to rename the file '%s' to '%s' because the destination file already exists."),
|
||||||
|
file1.c_str(), file2.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
|
#if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
|
||||||
// Normal system call
|
// Normal system call
|
||||||
if ( wxRename (file1, file2) == 0 )
|
if ( wxRename (file1, file2) == 0 )
|
||||||
@@ -1115,7 +1126,7 @@ wxRenameFile (const wxString& file1, const wxString& file2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Try to copy
|
// Try to copy
|
||||||
if (wxCopyFile(file1, file2)) {
|
if (wxCopyFile(file1, file2, overwrite)) {
|
||||||
wxRemoveFile(file1);
|
wxRemoveFile(file1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user