X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3826db3ef5fc3ac97fb91aa11eb2381b2c96248d..6f34921d9369a31de14e4b07e4824e2d701710f0:/src/common/filefn.cpp?ds=inline diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index b0fff2802d..d0a65e01ec 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -26,6 +26,7 @@ #endif #include "wx/utils.h" +#include #include #include @@ -45,7 +46,7 @@ #include #endif -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #ifndef __GNUWIN32__ #include #include @@ -69,7 +70,7 @@ #include #endif -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #include "windows.h" #endif @@ -90,7 +91,7 @@ void wxPathList::Add (const wxString& path) void wxPathList::AddEnvList (const wxString& envVariable) { static const char PATH_TOKS[] = -#ifdef __WXMSW__ +#ifdef __WINDOWS__ " ;"; // Don't seperate with colon in DOS (used for drive) #else " :;"; @@ -107,7 +108,7 @@ void wxPathList::AddEnvList (const wxString& envVariable) Add (copystring (token)); while (token) { - if ((token = strtok (NULL, PATH_TOKS)) != NULL) + if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL) Add (wxString(token)); } } @@ -135,7 +136,7 @@ bool wxPathList::Member (const wxString& path) { wxString path2((char *) node->Data ()); if ( -#if defined(__WXMSW__) || defined(__VMS__) +#if defined(__WINDOWS__) || defined(__VMS__) // Case INDEPENDENT path.CompareTo (path2, wxString::ignoreCase) == 0 #else @@ -166,7 +167,7 @@ wxString wxPathList::FindValidPath (const wxString& file) if (ch != '\\' && ch != '/') strcat (wxBuffer, "/"); strcat (wxBuffer, filename); -#ifdef __WXMSW__ +#ifdef __WINDOWS__ Unix2DosFilename (wxBuffer); #endif if (wxFileExists (wxBuffer)) @@ -193,7 +194,7 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) lastCh = buf[len-1]; if (lastCh != '/' && lastCh != '\\') { -#ifdef __WXMSW__ +#ifdef __WINDOWS__ strcat(buf, "\\"); #else strcat(buf, "/"); @@ -236,7 +237,7 @@ wxIsAbsolutePath (const wxString& filename) #ifdef __VMS__ || (filename[0] == '[' && filename[1] != '.') #endif -#ifdef __WXMSW__ +#ifdef __WINDOWS__ /* MSDOS */ || filename[0] == '\\' || (isalpha (filename[0]) && filename[1] == ':') #endif @@ -267,6 +268,21 @@ void wxStripExtension(char *buffer) } } +void wxStripExtension(wxString& buffer) +{ + size_t len = buffer.Length(); + size_t i = len-1; + while (i > 0) + { + if (buffer.GetChar(i) == '.') + { + buffer = buffer.Left(i); + break; + } + i --; + } +} + // Destructive removal of /./ and /../ stuff char *wxRealPath (char *path) { @@ -323,7 +339,7 @@ char *wxRealPath (char *path) char *wxCopyAbsolutePath(const wxString& filename) { if (filename == "") - return NULL; + return (char *) NULL; if (! IsAbsolutePath(wxExpandPath(wxBuffer, filename))) { char buf[_MAXPATHLEN]; @@ -426,7 +442,7 @@ char *wxExpandPath(char *buf, const char *name) #endif { register char *start = d; - register braces = (*s == '{' || *s == '('); + register int braces = (*s == '{' || *s == '('); register char *value; while ((*d++ = *s)) if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') ) @@ -507,7 +523,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin static char dest[_MAXPATHLEN]; if (filename == "") - return NULL; + return (char *) NULL; strcpy (dest, WXSTRINGCAST filename); #ifdef __WXMSW__ @@ -515,9 +531,9 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin #endif // Handle environment - char *val = NULL; - char *tcp = NULL; - if (envname != NULL && (val = getenv (WXSTRINGCAST envname)) != NULL && + char *val = (char *) NULL; + char *tcp = (char *) NULL; + if (envname != WXSTRINGCAST NULL && (val = getenv (WXSTRINGCAST envname)) != NULL && (tcp = strstr (dest, val)) != NULL) { strcpy (wxBuffer, tcp + strlen (val)); @@ -649,7 +665,7 @@ wxPathOnly (char *path) #endif } - return NULL; + return (char *) NULL; } // Return just the directory, or NULL if no directory @@ -721,7 +737,11 @@ wxDos2UnixFilename (char *s) } void +#ifdef __WXMSW__ wxUnix2DosFilename (char *s) +#else +wxUnix2DosFilename (char *WXUNUSED(s)) +#endif { // Yes, I really mean this to happen under DOS only! JACS #ifdef __WXMSW__ @@ -741,9 +761,9 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil { char *outfile = wxGetTempFileName("cat"); - FILE *fp1 = NULL; - FILE *fp2 = NULL; - FILE *fp3 = NULL; + FILE *fp1 = (FILE *) NULL; + FILE *fp2 = (FILE *) NULL; + FILE *fp3 = (FILE *) NULL; // Open the inputs and outputs if ((fp1 = fopen (WXSTRINGCAST file1, "rb")) == NULL || (fp2 = fopen (WXSTRINGCAST file2, "rb")) == NULL || @@ -824,7 +844,9 @@ bool wxRemoveFile(const wxString& file) bool wxMkdir(const wxString& dir) { -#ifdef __VMS__ +#if defined(__WXSTUBS__) + return FALSE; +#elif defined(__VMS__) return FALSE; #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); @@ -904,7 +926,7 @@ bool wxPathExists(const char *pszPathName) // Get a temporary filename, opening and closing the file. char *wxGetTempFileName(const wxString& prefix, char *buf) { -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #ifndef __WIN32__ char tmp[144]; @@ -941,9 +963,9 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) return buf; } } - cerr << "wxWindows: error finding temporary file name.\n"; + cerr << _("wxWindows: error finding temporary file name.\n"); if (buf) buf[0] = 0; - return NULL; + return (char *) NULL; #endif } @@ -955,8 +977,8 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) // Flags are reserved for future use. #ifndef __VMS__ -static DIR *wxDirStream = NULL; -static char *wxFileSpec = NULL; +static DIR *wxDirStream = (DIR *) NULL; +static char *wxFileSpec = (char *) NULL; static int wxFindFileFlags = 0; #endif @@ -984,13 +1006,13 @@ char *wxFindFirstFile(const char *spec, int flags) p = "."; if ((wxDirStream=opendir(p))==NULL) - return NULL; + return (char *) NULL; /* MATTHEW: [5] wxFindNextFile can do the rest of the work */ return wxFindNextFile(); #endif // ifndef __VMS__ - return NULL; + return (char *) NULL; } char *wxFindNextFile(void) @@ -1000,7 +1022,7 @@ char *wxFindNextFile(void) /* MATTHEW: [2] Don't crash if we read too many times */ if (!wxDirStream) - return NULL; + return (char *) NULL; // Find path only so we can concatenate // found file onto path @@ -1044,11 +1066,11 @@ char *wxFindNextFile(void) } } closedir(wxDirStream); - wxDirStream = NULL; + wxDirStream = (DIR *) NULL; #endif // ifndef __VMS__ - return NULL; + return (char *) NULL; } #elif defined(__WXMSW__) @@ -1240,7 +1262,7 @@ bool wxSetWorkingDirectory(const wxString& d) { #ifdef __UNIX__ return (chdir(d) == 0); -#elif defined(__WXMSW__) +#elif defined(__WINDOWS__) #ifdef __WIN32__ return (bool)(SetCurrentDirectory(d) != 0); @@ -1285,7 +1307,7 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) { // we assume that it's not empty wxCHECK_MSG( !IsEmpty(pszFile), FALSE, - "empty file name in wxFindFileInPath"); + _("empty file name in wxFindFileInPath")); // skip path separator in the beginning of the file name if present if ( wxIsPathSeparator(*pszFile) ) @@ -1297,7 +1319,7 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) wxString strFile; char *pc; - for ( pc = strtok(szPath, PATH_SEP); pc; pc = strtok(NULL, PATH_SEP) ) { + for ( pc = strtok(szPath, PATH_SEP); pc; pc = strtok((char *) NULL, PATH_SEP) ) { // search for the file in this directory strFile = pc; if ( !wxEndsWithPathSeparator(pc) ) @@ -1320,23 +1342,23 @@ void WXDLLEXPORT wxSplitPath(const char *pszFileName, wxString *pstrName, wxString *pstrExt) { - wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" ); + wxCHECK_RET( pszFileName, _("NULL file name in wxSplitPath") ); const char *pDot = strrchr(pszFileName, FILE_SEP_EXT); const char *pSepUnix = strrchr(pszFileName, FILE_SEP_PATH_UNIX); const char *pSepDos = strrchr(pszFileName, FILE_SEP_PATH_DOS); // take the last of the two - uint nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0; - uint nPosDos = pSepDos ? pSepDos - pszFileName : 0; + size_t nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0; + size_t nPosDos = pSepDos ? pSepDos - pszFileName : 0; if ( nPosDos > nPosUnix ) nPosUnix = nPosDos; - uint nLen = Strlen(pszFileName); +// size_t nLen = Strlen(pszFileName); if ( pstrPath ) *pstrPath = wxString(pszFileName, nPosUnix); if ( pDot ) { - uint nPosDot = pDot - pszFileName; + size_t nPosDot = pDot - pszFileName; if ( pstrName ) *pstrName = wxString(pszFileName + nPosUnix + 1, nPosDot - nPosUnix); if ( pstrExt )