X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..3d4c6a214ac5b00dbf5e314e369471135db81c0d:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 0c3cb57f31..2a17499d5e 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -40,10 +40,12 @@ #include #include +#ifdef __UNIX__ #include #include +#endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #ifndef __GNUWIN32__ #include #include @@ -67,7 +69,7 @@ #include #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include "windows.h" #endif @@ -88,7 +90,7 @@ void wxPathList::Add (const wxString& path) void wxPathList::AddEnvList (const wxString& envVariable) { static const char PATH_TOKS[] = -#ifdef __WINDOWS__ +#ifdef __WXMSW__ " ;"; // Don't seperate with colon in DOS (used for drive) #else " :;"; @@ -133,7 +135,7 @@ bool wxPathList::Member (const wxString& path) { wxString path2((char *) node->Data ()); if ( -#if defined(__WINDOWS__) || defined(__VMS__) +#if defined(__WXMSW__) || defined(__VMS__) // Case INDEPENDENT path.CompareTo (path2, wxString::ignoreCase) == 0 #else @@ -164,7 +166,7 @@ wxString wxPathList::FindValidPath (const wxString& file) if (ch != '\\' && ch != '/') strcat (wxBuffer, "/"); strcat (wxBuffer, filename); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ Unix2DosFilename (wxBuffer); #endif if (wxFileExists (wxBuffer)) @@ -191,7 +193,7 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) lastCh = buf[len-1]; if (lastCh != '/' && lastCh != '\\') { -#ifdef __WINDOWS__ +#ifdef __WXMSW__ strcat(buf, "\\"); #else strcat(buf, "/"); @@ -234,7 +236,7 @@ wxIsAbsolutePath (const wxString& filename) #ifdef __VMS__ || (filename[0] == '[' && filename[1] != '.') #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ /* MSDOS */ || filename[0] == '\\' || (isalpha (filename[0]) && filename[1] == ':') #endif @@ -268,7 +270,7 @@ void wxStripExtension(char *buffer) // Destructive removal of /./ and /../ stuff char *wxRealPath (char *path) { -#ifdef __WINDOWS__ +#ifdef __WXMSW__ static const char SEP = '\\'; Unix2DosFilename(path); #else @@ -298,7 +300,7 @@ char *wxRealPath (char *path) path[0] = SEP; path[1] = '\0'; } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ /* Check that path[2] is NULL! */ else if (path[1] == ':' && !path[2]) { @@ -328,7 +330,7 @@ char *wxCopyAbsolutePath(const wxString& filename) buf[0] = '\0'; wxGetWorkingDirectory(buf, sizeof(buf)/sizeof(char)); char ch = buf[strlen(buf) - 1]; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (ch != '\\' && ch != '/') strcat(buf, "\\"); #else @@ -379,7 +381,7 @@ char *wxExpandPath(char *buf, const char *name) trimchars[2] = '\t'; trimchars[3] = 0; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ const char SEP = '\\'; #else const char SEP = '/'; @@ -400,7 +402,7 @@ char *wxExpandPath(char *buf, const char *name) s = nm; d = lnm; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ q = FALSE; #else q = nm[0] == '\\' && nm[1] == '~'; @@ -408,7 +410,7 @@ char *wxExpandPath(char *buf, const char *name) /* Expand inline environment variables */ while ((*d++ = *s)) { -#ifndef __WINDOWS__ +#ifndef __WXMSW__ if (*s == '\\') { if ((*(d - 1) = *++s)) { s++; @@ -417,7 +419,7 @@ char *wxExpandPath(char *buf, const char *name) break; } else #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (*s++ == '$' && (*s == '{' || *s == ')')) #else if (*s++ == '$') @@ -508,7 +510,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin return NULL; strcpy (dest, WXSTRINGCAST filename); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ Unix2DosFilename(dest); #endif @@ -535,7 +537,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin strcpy(wxBuffer, "~"); if (user && *user) strcat(wxBuffer, user); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // strcat(wxBuffer, "\\"); #else // strcat(wxBuffer, "/"); @@ -566,7 +568,7 @@ char *wxFileNameFromPath (char *path) #endif return tcp + 1; } /* while */ -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (isalpha (*path) && *(path + 1) == ':') return path + 2; #endif @@ -593,7 +595,7 @@ wxString wxFileNameFromPath (const wxString& path1) #endif return wxString(tcp + 1); } /* while */ -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (isalpha (*path) && *(path + 1) == ':') return wxString(path + 2); #endif @@ -635,7 +637,7 @@ wxPathOnly (char *path) else i --; } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Try Drive specifier if (isalpha (buf[0]) && buf[1] == ':') { @@ -683,7 +685,7 @@ wxString wxPathOnly (const wxString& path) else i --; } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Try Drive specifier if (isalpha (buf[0]) && buf[1] == ':') { @@ -710,7 +712,7 @@ wxDos2UnixFilename (char *s) { if (*s == '\\') *s = '/'; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ else *s = wxToLower (*s); // Case INDEPENDENT #endif @@ -719,10 +721,10 @@ wxDos2UnixFilename (char *s) } void -wxUnix2DosFilename (char *WXUNUSED(s)) +wxUnix2DosFilename (char *s) { // Yes, I really mean this to happen under DOS only! JACS -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (s) while (*s) { @@ -824,7 +826,7 @@ bool wxMkdir(const wxString& dir) { #ifdef __VMS__ return FALSE; -#elif (defined(__GNUWIN32__) && !defined(__MINGW32__)) || !defined(__WINDOWS__) +#elif (defined(__GNUWIN32__) && !defined(__MINGW32__)) || !defined(__WXMSW__) return (mkdir (WXSTRINGCAST dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0); #else return (mkdir(WXSTRINGCAST dir) == 0); @@ -845,7 +847,7 @@ bool wxDirExists(const wxString& dir) { #ifdef __VMS__ return FALSE; -#elif !defined(__WINDOWS__) +#elif !defined(__WXMSW__) struct stat sbuf; return (stat(dir, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE; #else @@ -902,7 +904,7 @@ bool wxPathExists(const char *pszPathName) // Get a temporary filename, opening and closing the file. char *wxGetTempFileName(const wxString& prefix, char *buf) { -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #ifndef __WIN32__ char tmp[144]; @@ -1049,7 +1051,7 @@ char *wxFindNextFile(void) return NULL; } -#elif defined(__WINDOWS__) +#elif defined(__WXMSW__) #ifdef __WIN32__ HANDLE wxFileStrucHandle = INVALID_HANDLE_VALUE; @@ -1064,7 +1066,7 @@ static struct _find_t wxFileStruc; static wxString wxFileSpec = ""; static int wxFindFileFlags; -char *wxFindFirstFile(const wxString& spec, int flags) +char *wxFindFirstFile(const char *spec, int flags) { wxFileSpec = spec; wxFindFileFlags = flags; /* MATTHEW: [5] Remember flags */ @@ -1214,7 +1216,7 @@ char *wxFindNextFile(void) } #endif - // __WINDOWS__ + // __WXMSW__ // Get current working directory. // If buf is NULL, allocates space using new, else @@ -1238,7 +1240,7 @@ bool wxSetWorkingDirectory(const wxString& d) { #ifdef __UNIX__ return (chdir(d) == 0); -#elif defined(__WINDOWS__) +#elif defined(__WXMSW__) #ifdef __WIN32__ return (bool)(SetCurrentDirectory(d) != 0); @@ -1282,7 +1284,8 @@ bool wxEndsWithPathSeparator(const char *pszFileName) bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) { // we assume that it's not empty - wxCHECK_RET( Strlen(pszFile) != 0, FALSE); + wxCHECK_MSG( !IsEmpty(pszFile), FALSE, + "empty file name in wxFindFileInPath"); // skip path separator in the beginning of the file name if present if ( wxIsPathSeparator(*pszFile) )