applied patch 410892 (wxCopyFile uses ::CopyFile under Win32, has overwrite parameter)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -213,9 +213,12 @@ TRUE if successful.
|
|||||||
|
|
||||||
\membersection{::wxCopyFile}
|
\membersection{::wxCopyFile}
|
||||||
|
|
||||||
\func{bool}{wxCopyFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}}
|
\func{bool}{wxCopyFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}, \param{bool }{overwrite = TRUE}}
|
||||||
|
|
||||||
Copies {\it file1} to {\it file2}, returning TRUE if successful.
|
Copies {\it file1} to {\it file2}, returning TRUE if successful. If
|
||||||
|
{\it overwrite} parameter is TRUE (default), the destination file is overwritten
|
||||||
|
if it exists, but if {\it overwrite} is FALSE, the functions failes in this
|
||||||
|
case.
|
||||||
|
|
||||||
\membersection{::wxGetCwd}\label{wxgetcwd}
|
\membersection{::wxGetCwd}\label{wxgetcwd}
|
||||||
|
|
||||||
|
@@ -220,7 +220,8 @@ WXDLLEXPORT bool wxMatchWild(const wxString& pattern, const wxString& text, boo
|
|||||||
WXDLLEXPORT bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
|
WXDLLEXPORT bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
|
||||||
|
|
||||||
// Copy file1 to file2
|
// Copy file1 to file2
|
||||||
WXDLLEXPORT bool wxCopyFile(const wxString& file1, const wxString& file2);
|
WXDLLEXPORT bool wxCopyFile(const wxString& file1, const wxString& file2,
|
||||||
|
bool overwrite = TRUE);
|
||||||
|
|
||||||
// Remove file
|
// Remove file
|
||||||
WXDLLEXPORT bool wxRemoveFile(const wxString& file);
|
WXDLLEXPORT bool wxRemoveFile(const wxString& file);
|
||||||
|
@@ -996,8 +996,15 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
|
|||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
bool
|
bool
|
||||||
wxCopyFile (const wxString& file1, const wxString& file2)
|
wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
|
||||||
{
|
{
|
||||||
|
#if defined(__WIN32__)
|
||||||
|
// CopyFile() copies file attributes and modification time too, so use it
|
||||||
|
// instead of our code if available
|
||||||
|
//
|
||||||
|
// NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
|
||||||
|
return ::CopyFile(file1, file2, !overwrite);
|
||||||
|
#else // !Win32
|
||||||
wxStructStat fbuf;
|
wxStructStat fbuf;
|
||||||
|
|
||||||
// get permissions of file1
|
// get permissions of file1
|
||||||
@@ -1017,7 +1024,7 @@ wxCopyFile (const wxString& file1, const wxString& file2)
|
|||||||
|
|
||||||
// remove file2, if it exists. This is needed for creating
|
// remove file2, if it exists. This is needed for creating
|
||||||
// file2 with the correct permissions in the next step
|
// file2 with the correct permissions in the next step
|
||||||
if ( wxFileExists(file2) && !wxRemoveFile(file2) )
|
if ( wxFileExists(file2) && (!overwrite || !wxRemoveFile(file2)))
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Impossible to overwrite the file '%s'"),
|
wxLogSysError(_("Impossible to overwrite the file '%s'"),
|
||||||
file2.c_str());
|
file2.c_str());
|
||||||
@@ -1033,7 +1040,7 @@ wxCopyFile (const wxString& file1, const wxString& file2)
|
|||||||
// create file2 with the same permissions than file1 and open it for
|
// create file2 with the same permissions than file1 and open it for
|
||||||
// writing
|
// writing
|
||||||
wxFile fileOut;
|
wxFile fileOut;
|
||||||
if ( !fileOut.Create(file2, TRUE, fbuf.st_mode & 0777) )
|
if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
@@ -1066,8 +1073,10 @@ wxCopyFile (const wxString& file1, const wxString& file2)
|
|||||||
file2.c_str());
|
file2.c_str());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // OS/2 || Mac
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#endif // __WXMSW__ && __WIN32__
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Reference in New Issue
Block a user