log error message in wxRmdir() for consistency with wxMkdir() and some code cleanup (e.g. get rid of gly OS_FILENAME macro) (closes #10435)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-31 22:56:02 +00:00
parent 7b2e024e8a
commit 4a3c54bfa5

View File

@@ -116,13 +116,6 @@ static wxChar wxFileFunctionsBuffer[4*_MAXPATHLEN];
const int wxInvalidOffset = -1; const int wxInvalidOffset = -1;
#endif #endif
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// translate the filenames before passing them to OS functions
#define OS_FILENAME(s) (s.fn_str())
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -1188,7 +1181,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
#if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__) #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
// no chmod in VA. Should be some permission API for HPFS386 partitions // no chmod in VA. Should be some permission API for HPFS386 partitions
// however // however
if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 ) if ( chmod(file2.fn_str(), fbuf.st_mode) != 0 )
{ {
wxLogSysError(_("Impossible to set permissions for the file '%s'"), wxLogSysError(_("Impossible to set permissions for the file '%s'"),
file2.c_str()); file2.c_str());
@@ -1253,7 +1246,7 @@ bool wxRemoveFile(const wxString& file)
int res = 1; int res = 1;
// TODO with VFSFileDelete() // TODO with VFSFileDelete()
#else #else
int res = unlink(OS_FILENAME(file)); int res = unlink(file.fn_str());
#endif #endif
return res == 0; return res == 0;
@@ -1263,14 +1256,16 @@ bool wxMkdir(const wxString& dir, int perm)
{ {
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
return false; return false;
#elif defined(__WXMAC__) && !defined(__UNIX__) #else
return (mkdir(dir.fn_str() , 0 ) == 0); #if defined(__WXMAC__) && !defined(__UNIX__)
#else // !Mac if ( mkdir(dir.fn_str(), 0) != 0 )
const wxChar *dirname = dir.c_str();
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
// for the GNU compiler // for the GNU compiler
#if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__) #elif (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || \
(defined(__GNUWIN32__) && !defined(__MINGW32__)) || \
defined(__WINE__) || defined(__WXMICROWIN__)
const wxChar *dirname = dir.c_str();
#if defined(MSVCRT) #if defined(MSVCRT)
wxUnusedVar(perm); wxUnusedVar(perm);
if ( mkdir(wxFNCONV(dirname)) != 0 ) if ( mkdir(wxFNCONV(dirname)) != 0 )
@@ -1279,8 +1274,9 @@ bool wxMkdir(const wxString& dir, int perm)
#endif #endif
#elif defined(__OS2__) #elif defined(__OS2__)
wxUnusedVar(perm); wxUnusedVar(perm);
if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's?? if (::DosCreateDir(dir.c_str(), NULL) != 0) // enhance for EAB's??
#elif defined(__DOS__) #elif defined(__DOS__)
const wxChar *dirname = dir.c_str();
#if defined(__WATCOMC__) #if defined(__WATCOMC__)
(void)perm; (void)perm;
if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 ) if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 )
@@ -1291,36 +1287,43 @@ bool wxMkdir(const wxString& dir, int perm)
#endif #endif
#else // !MSW, !DOS and !OS/2 VAC++ #else // !MSW, !DOS and !OS/2 VAC++
wxUnusedVar(perm); wxUnusedVar(perm);
#ifdef __WXWINCE__ #ifdef __WXWINCE__
if ( !CreateDirectory(dirname, NULL) ) if ( CreateDirectory(dir, NULL) == 0 )
#else #else
if ( wxMkDir(dir.fn_str()) != 0 ) if ( wxMkDir(dir.fn_str()) != 0 )
#endif #endif
#endif // !MSW/MSW #endif // !MSW/MSW
{ {
wxLogSysError(_("Directory '%s' couldn't be created"), dirname); wxLogSysError(_("Directory '%s' couldn't be created"), dir);
return false; return false;
} }
return true; return true;
#endif // Mac/!Mac #endif // PALMOS/!PALMOS
} }
bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
{ {
#if defined(__VMS__) #if defined(__VMS__)
return false; //to be changed since rmdir exists in VMS7.x return false; //to be changed since rmdir exists in VMS7.x
#elif defined(__OS2__)
return (::DosDeleteDir(dir.c_str()) == 0);
#elif defined(__WXWINCE__)
return (RemoveDirectory(dir) != 0);
#elif defined(__WXPALMOS__) #elif defined(__WXPALMOS__)
// TODO with VFSFileRename() // TODO with VFSFileRename()
return false; return false;
#else #else
return (wxRmDir(OS_FILENAME(dir)) == 0); #if defined(__OS2__)
#endif if ( ::DosDeleteDir(dir.c_str()) != 0 )
#elif defined(__WXWINCE__)
if ( RemoveDirectory(dir) == 0 )
#else
if ( wxRmDir(dir.fn_str()) != 0 )
#endif
{
wxLogSysError(_("Directory '%s' couldn't be deleted"), dir);
return false;
}
return true;
#endif // PALMOS/!PALMOS
} }
// does the path exists? (may have or not '/' or '\\' at the end) // does the path exists? (may have or not '/' or '\\' at the end)