X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..9cb98d899582a69072a51a4c06199cebf625c039:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 1056a66fad..fe708cb0a4 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -75,7 +75,7 @@ #include #include "wx/os2/private.h" #endif -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) && !defined(__WXWINE__) +#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) #include #include @@ -144,10 +144,14 @@ #endif #ifdef __WXMAC__ +# ifdef __DARWIN__ +# include "MoreFilesX.h" +# else # include "MoreFiles.h" # include "MoreFilesExtras.h" # include "FullPath.h" # include "FSpCompat.h" +# endif #endif // ---------------------------------------------------------------------------- @@ -256,9 +260,9 @@ void wxPathList::EnsureFileAccessible (const wxString& path) bool wxPathList::Member (const wxString& path) { - for (wxNode * node = First (); node != NULL; node = node->Next ()) + for (wxStringList::Node *node = GetFirst(); node; node = node->GetNext()) { - wxString path2((wxChar *) node->Data ()); + wxString path2( node->GetData() ); if ( #if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__) // Case INDEPENDENT @@ -284,9 +288,9 @@ wxString wxPathList::FindValidPath (const wxString& file) wxChar *filename = (wxChar*) NULL; /* shut up buggy egcs warning */ filename = wxIsAbsolutePath (buf) ? wxFileNameFromPath (buf) : (wxChar *)buf; - for (wxNode * node = First (); node; node = node->Next ()) + for (wxStringList::Node *node = GetFirst(); node; node = node->GetNext()) { - wxChar *path = (wxChar *) node->Data (); + wxChar *path = node->GetData(); wxStrcpy (wxFileFunctionsBuffer, path); wxChar ch = wxFileFunctionsBuffer[wxStrlen(wxFileFunctionsBuffer)-1]; if (ch != wxT('\\') && ch != wxT('/')) @@ -301,7 +305,7 @@ wxString wxPathList::FindValidPath (const wxString& file) } } // for() - return wxString(wxT("")); // Not found + return wxEmptyString; // Not found } wxString wxPathList::FindAbsoluteValidPath (const wxString& file) @@ -428,7 +432,11 @@ wxChar *wxRealPath (wxChar *path) if (p[1] == wxT('.') && p[2] == wxT('.') && (p[3] == SEP || p[3] == wxT('\0'))) { wxChar *q; - for (q = p - 1; q >= path && *q != SEP; q--); + for (q = p - 1; q >= path && *q != SEP; q--) + { + // Empty + } + if (q[0] == SEP && (q[1] != wxT('.') || q[2] != wxT('.') || q[3] != SEP) && (q - 1 <= path || q[-1] != SEP)) { @@ -592,7 +600,11 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) *--d = 0; value = wxGetenv(braces ? start + 1 : start); if (value) { - for ((d = start - 1); (*d++ = *value++) != 0;); + for ((d = start - 1); (*d++ = *value++) != 0;) + { + // Empty + } + d--; if (braces && *s) s++; @@ -616,7 +628,10 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) { /* ~user/filename */ register wxChar *nnm; register wxChar *home; - for (s = nm; *s && *s != SEP; s++); + for (s = nm; *s && *s != SEP; s++) + { + // Empty + } int was_sep; /* MATTHEW: Was there a separator, or NULL? */ was_sep = (*s == SEP); nnm = *s ? s + 1 : s; @@ -643,7 +658,10 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) *(d - 1) = SEP; } s = nm; - while ((*d++ = *s++) != 0); + while ((*d++ = *s++) != 0) + { + // Empty + } delete[] nm_tmp; // clean up alloc /* Now clean up the buffer */ return wxRealPath(buf); @@ -847,8 +865,8 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) int j; OSErr theErr; OSStatus theStatus; - Boolean isDirectory = false; - Str255 theParentPath = "\p"; + Boolean isDirectory = FALSE; + Str255 theParentPath = "\p"; FSSpec theParentSpec; FSRef theParentRef; char theFileName[FILENAME_MAX]; @@ -926,7 +944,7 @@ static char sMacFileNameConversion[ 1000 ] ; #endif void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) { - OSStatus err = noErr ; + OSStatus err = noErr ; #ifdef __DARWIN__ FSRef theRef; @@ -935,9 +953,9 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) // convert the FSRef to an FSSpec err = FSGetCatalogInfo(&theRef, kFSCatInfoNone, NULL, NULL, spec, NULL); #else - if ( strchr( path , ':' ) == NULL ) + if ( strchr( path , ':' ) == NULL ) { - // try whether it is a volume / or a mounted volume + // try whether it is a volume / or a mounted volume strncpy( sMacFileNameConversion , path , 1000 ) ; sMacFileNameConversion[998] = 0 ; strcat( sMacFileNameConversion , ":" ) ; @@ -945,7 +963,7 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) } else { - err = FSpLocationFromFullPath( strlen(path) , path , spec ) ; + err = FSpLocationFromFullPath( strlen(path) , path , spec ) ; } #endif } @@ -1157,7 +1175,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) // create file2 with the same permissions than file1 and open it for // writing - + wxFile fileOut; if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) ) return FALSE; @@ -1244,8 +1262,12 @@ bool wxMkdir(const wxString& dir, int perm) // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too // for the GNU compiler -#if (!(defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__) || defined(__WXMICROWIN__) +#if (!(defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__) + #ifndef MSVCRT if ( mkdir(wxFNCONV(dirname), perm) != 0 ) + #else + if ( mkdir(wxFNCONV(dirname)) != 0 ) + #endif #elif defined(__WXPM__) if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's?? #elif defined(__DOS__) @@ -1426,7 +1448,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) bool needsANSI = TRUE; #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU - // This is not legal code as the compiler + // This is not legal code as the compiler // is allowed destroy the wxCharBuffer. // wxCharBuffer c_buffer(sz); // char *cbuf = (char*)(const char*)c_buffer; @@ -1537,7 +1559,7 @@ wxString wxGetCwd() wxGetWorkingDirectory(buffer, _MAXPATHLEN); wxString str( buffer ); delete [] buffer; - + return str; } @@ -1598,7 +1620,7 @@ bool wxEndsWithPathSeparator(const wxChar *pszFileName) 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 @@ -1637,7 +1659,7 @@ bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFi delete [] szPath; - 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, @@ -1655,7 +1677,7 @@ time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) { wxStructStat buf; wxStat( filename, &buf); - + return buf.st_mtime; } @@ -1668,9 +1690,9 @@ bool wxIsWild( const wxString& pattern ) { wxString tmp = pattern; wxChar *pat = WXSTRINGCAST(tmp); - while (*pat) + while (*pat) { - switch (*pat++) + switch (*pat++) { case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'): return TRUE; @@ -1695,7 +1717,7 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) /* Match if both are empty. */ return pat.empty(); } - + const wxChar *m = pat.c_str(), *n = text.c_str(), *ma = NULL, @@ -1709,7 +1731,7 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) if (dot_special && (*n == wxT('.'))) { - /* Never match so that hidden Unix files + /* Never match so that hidden Unix files * are never found. */ return FALSE; }