git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28544
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
path.CompareTo (path2) == 0
#endif
)
path.CompareTo (path2) == 0
#endif
)
}
wxString wxPathList::FindValidPath (const wxString& file)
}
wxString wxPathList::FindValidPath (const wxString& file)
// "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
// is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
if (filename.Find(':') != wxNOT_FOUND && filename[0] != ':')
// "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
// is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
if (filename.Find(':') != wxNOT_FOUND && filename[0] != ':')
#else
// Unix like or Windows
if (filename[0] == wxT('/'))
#else
// Unix like or Windows
if (filename[0] == wxT('/'))
#endif
#ifdef __VMS__
if ((filename[0] == wxT('[') && filename[1] != wxT('.')))
#endif
#ifdef __VMS__
if ((filename[0] == wxT('[') && filename[1] != wxT('.')))
#endif
#if defined(__WINDOWS__) || defined(__OS2__)
// MSDOS like
if (filename[0] == wxT('\\') || (wxIsalpha (filename[0]) && filename[1] == wxT(':')))
#endif
#if defined(__WINDOWS__) || defined(__OS2__)
// MSDOS like
if (filename[0] == wxT('\\') || (wxIsalpha (filename[0]) && filename[1] == wxT(':')))
{
wxString outfile;
if ( !wxGetTempFileName( wxT("cat"), outfile) )
{
wxString outfile;
if ( !wxGetTempFileName( wxT("cat"), outfile) )
FILE *fp1 wxDUMMY_INITIALIZE(NULL);
FILE *fp2 = NULL;
FILE *fp1 wxDUMMY_INITIALIZE(NULL);
FILE *fp2 = NULL;
fclose (fp2);
if (fp3)
fclose (fp3);
fclose (fp2);
if (fp3)
fclose (fp3);
wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
file1.c_str(), file2.c_str());
wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
file1.c_str(), file2.c_str());
}
#elif defined(__OS2__)
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
}
#elif defined(__OS2__)
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
#else // !Win32
wxStructStat fbuf;
#else // !Win32
wxStructStat fbuf;
// from it anyhow
wxLogSysError(_("Impossible to get permissions for file '%s'"),
file1.c_str());
// from it anyhow
wxLogSysError(_("Impossible to get permissions for file '%s'"),
file1.c_str());
}
// open file1 for reading
wxFile fileIn(file1, wxFile::read);
if ( !fileIn.IsOpened() )
}
// open file1 for reading
wxFile fileIn(file1, wxFile::read);
if ( !fileIn.IsOpened() )
// remove file2, if it exists. This is needed for creating
// file2 with the correct permissions in the next step
// remove file2, if it exists. This is needed for creating
// file2 with the correct permissions in the next step
{
wxLogSysError(_("Impossible to overwrite the file '%s'"),
file2.c_str());
{
wxLogSysError(_("Impossible to overwrite the file '%s'"),
file2.c_str());
wxFile fileOut;
if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
wxFile fileOut;
if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
#ifdef __UNIX__
/// restore the old umask
#ifdef __UNIX__
/// restore the old umask
{
count = fileIn.Read(buf, WXSIZEOF(buf));
if ( fileIn.Error() )
{
count = fileIn.Read(buf, WXSIZEOF(buf));
if ( fileIn.Error() )
// end of file?
if ( !count )
break;
if ( fileOut.Write(buf, count) < count )
// end of file?
if ( !count )
break;
if ( fileOut.Write(buf, count) < count )
}
// we can expect fileIn to be closed successfully, but we should ensure
// that fileOut was closed as some write errors (disk full) might not be
// detected before doing this
if ( !fileIn.Close() || !fileOut.Close() )
}
// we can expect fileIn to be closed successfully, but we should ensure
// that fileOut was closed as some write errors (disk full) might not be
// detected before doing this
if ( !fileIn.Close() || !fileOut.Close() )
#if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
// no chmod in VA. Should be some permission API for HPFS386 partitions
#if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
// no chmod in VA. Should be some permission API for HPFS386 partitions
{
wxLogSysError(_("Impossible to set permissions for the file '%s'"),
file2.c_str());
{
wxLogSysError(_("Impossible to set permissions for the file '%s'"),
file2.c_str());
}
#endif // OS/2 || Mac
#endif // __WXMSW__ && __WIN32__
}
#endif // OS/2 || Mac
#endif // __WXMSW__ && __WIN32__
#ifndef __WXWINCE__
// Normal system call
if ( wxRename (file1, file2) == 0 )
#ifndef __WXWINCE__
// Normal system call
if ( wxRename (file1, file2) == 0 )
#endif
// Try to copy
if (wxCopyFile(file1, file2)) {
wxRemoveFile(file1);
#endif
// Try to copy
if (wxCopyFile(file1, file2)) {
wxRemoveFile(file1);
}
bool wxRemoveFile(const wxString& file)
}
bool wxRemoveFile(const wxString& file)
// for the GNU compiler
#if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
#if defined(MSVCRT)
// for the GNU compiler
#if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
#if defined(MSVCRT)
if ( mkdir(wxFNCONV(dirname)) != 0 )
#else
if ( mkdir(wxFNCONV(dirname), perm) != 0 )
if ( mkdir(wxFNCONV(dirname)) != 0 )
#else
if ( mkdir(wxFNCONV(dirname), perm) != 0 )
{
wxLogSysError(_("Directory '%s' couldn't be created"), dirname);
{
wxLogSysError(_("Directory '%s' couldn't be created"), dirname);
#endif // Mac/!Mac
}
bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
{
#ifdef __VMS__
#endif // Mac/!Mac
}
bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
{
#ifdef __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((PSZ)dir.c_str()) == 0);
#else
#elif defined(__OS2__)
return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else
buf = new wxChar[sz + 1];
}
buf = new wxChar[sz + 1];
}
- bool ok wxDUMMY_INITIALIZE(FALSE);
+ bool ok wxDUMMY_INITIALIZE(false);
// for the compilers which have Unicode version of _getcwd(), call it
// directly, for the others call the ANSI version and do the translation
#if !wxUSE_UNICODE
#define cbuf buf
#else // wxUSE_UNICODE
// for the compilers which have Unicode version of _getcwd(), call it
// directly, for the others call the ANSI version and do the translation
#if !wxUSE_UNICODE
#define cbuf buf
#else // wxUSE_UNICODE
#if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
// This is not legal code as the compiler
#if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
// This is not legal code as the compiler
#if wxUSE_UNICODE_MSLU
if ( wxGetOsVersion() != wxWIN95 )
#else
#if wxUSE_UNICODE_MSLU
if ( wxGetOsVersion() != wxWIN95 )
#else
- char *cbuf = NULL; // never really used because needsANSI will always be FALSE
+ char *cbuf = NULL; // never really used because needsANSI will always be false
#endif
{
ok = _wgetcwd(buf, sz) != NULL;
#endif
{
ok = _wgetcwd(buf, sz) != NULL;
cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
wxStrcpy( buf , res ) ;
cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
wxStrcpy( buf , res ) ;
}
#elif defined(__OS2__)
APIRET rc;
}
#elif defined(__OS2__)
APIRET rc;
#ifdef __WIN32__
#ifdef __WXWINCE__
// No equivalent in WinCE
#ifdef __WIN32__
#ifdef __WXWINCE__
// No equivalent in WinCE
#else
return (bool)(SetCurrentDirectory(d) != 0);
#endif
#else
return (bool)(SetCurrentDirectory(d) != 0);
#endif
return len && wxIsPathSeparator(pszFileName[len - 1]);
}
return len && wxIsPathSeparator(pszFileName[len - 1]);
}
-// find a file in a list of directories, returns FALSE if not found
+// find a file in a list of directories, returns false if not found
bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile)
{
// we assume that it's not empty
bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile)
{
// we assume that it's not empty
- wxCHECK_MSG( !wxIsEmpty(pszFile), FALSE,
+ wxCHECK_MSG( !wxIsEmpty(pszFile), false,
_T("empty file name in wxFindFileInPath"));
// skip path separator in the beginning of the file name if present
_T("empty file name in wxFindFileInPath"));
// skip path separator in the beginning of the file name if present
- return pc != NULL; // if TRUE => we breaked from the loop
+ return pc != NULL; // if true => we breaked from the loop
}
void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName,
}
void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName,
switch (*pat++)
{
case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
switch (*pat++)
{
case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
case wxT('\\'):
if (!*pat++)
case wxT('\\'):
if (!*pat++)
{
/* Never match so that hidden Unix files
* are never found. */
{
/* Never match so that hidden Unix files
* are never found. */
m++;
/* Quoting "nothing" is a bad thing */
if (!*m)
m++;
/* Quoting "nothing" is a bad thing */
if (!*m)
just = 0;
goto not_matched;
}
just = 0;
goto not_matched;
}
* impossible to match it
*/
if (!*n)
* impossible to match it
*/
if (!*n)
if (extension == wxT("exe"))
return executable;
else
if (extension == wxT("exe"))
return executable;
else