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}
|
||||
|
||||
\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}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
// 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
|
||||
WXDLLEXPORT bool wxRemoveFile(const wxString& file);
|
||||
|
@@ -996,8 +996,15 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
|
||||
|
||||
// Copy files
|
||||
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;
|
||||
|
||||
// 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
|
||||
// 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'"),
|
||||
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
|
||||
// writing
|
||||
wxFile fileOut;
|
||||
if ( !fileOut.Create(file2, TRUE, fbuf.st_mode & 0777) )
|
||||
if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
|
||||
return FALSE;
|
||||
|
||||
#ifdef __UNIX__
|
||||
@@ -1059,15 +1066,17 @@ wxCopyFile (const wxString& file1, const wxString& file2)
|
||||
}
|
||||
|
||||
#if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
|
||||
// no chmod in VA. SHould be some permission API for HPFS386 partitions however
|
||||
// no chmod in VA. SHould be some permission API for HPFS386 partitions however
|
||||
if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 )
|
||||
{
|
||||
wxLogSysError(_("Impossible to set permissions for the file '%s'"),
|
||||
file2.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
#endif // OS/2 || Mac
|
||||
|
||||
return TRUE;
|
||||
#endif // __WXMSW__ && __WIN32__
|
||||
}
|
||||
|
||||
bool
|
||||
|
Reference in New Issue
Block a user