#include "wx/log.h"
-// No, Cygwin doesn't appear to have fnmatch.h after all.
-#if defined(HAVE_FNMATCH_H)
- #include "fnmatch.h"
-#endif
-
#ifdef __WINDOWS__
#include "wx/msw/private.h"
#include "wx/msw/mslu.h"
path such as "C:\Program Files" would be split into 2 paths:
"C:\Program" and "Files"
*/
-// wxT(" ;"); // Don't seperate with colon in DOS (used for drive)
- wxT(";"); // Don't seperate with colon in DOS (used for drive)
+// wxT(" ;"); // Don't separate with colon in DOS (used for drive)
+ wxT(";"); // Don't separate with colon in DOS (used for drive)
#else
wxT(" :;");
#endif
- wxChar *val = wxGetenv (WXSTRINGCAST envVariable);
- if (val && *val)
+ wxString val ;
+ if (wxGetEnv (WXSTRINGCAST envVariable, &val))
{
wxChar *s = MYcopystring (val);
wxChar *save_ptr, *token = wxStrtok (s, PATH_TOKS, &save_ptr);
void wxStripExtension(wxChar *buffer)
{
- int len = wxStrlen(buffer);
- int i = len-1;
- while (i > 0)
- {
- if (buffer[i] == wxT('.'))
+ int len = wxStrlen(buffer);
+ int i = len-1;
+ while (i > 0)
{
- buffer[i] = 0;
- break;
+ if (buffer[i] == wxT('.'))
+ {
+ buffer[i] = 0;
+ break;
+ }
+ i --;
}
- i --;
- }
}
void wxStripExtension(wxString& buffer)
bool
wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3)
{
- wxString outfile;
- if ( !wxGetTempFileName( wxT("cat"), outfile) )
- return false;
-
- FILE *fp1 wxDUMMY_INITIALIZE(NULL);
- FILE *fp2 = NULL;
- FILE *fp3 = NULL;
- // Open the inputs and outputs
- if ((fp1 = wxFopen ( file1, wxT("rb"))) == NULL ||
- (fp2 = wxFopen ( file2, wxT("rb"))) == NULL ||
- (fp3 = wxFopen ( outfile, wxT("wb"))) == NULL)
+#if wxUSE_FILE
+
+ wxFile in1(file1), in2(file2);
+ wxTempFile out(file3);
+
+ if ( !in1.IsOpened() || !in2.IsOpened() || !out.IsOpened() )
+ return false;
+
+ ssize_t ofs;
+ unsigned char buf[1024];
+
+ for( int i=0; i<2; i++)
{
- if (fp1)
- fclose (fp1);
- if (fp2)
- fclose (fp2);
- if (fp3)
- fclose (fp3);
- return false;
+ wxFile *in = i==0 ? &in1 : &in2;
+ do{
+ if ( (ofs = in->Read(buf,WXSIZEOF(buf))) == wxInvalidOffset ) return false;
+ if ( ofs > 0 )
+ if ( !out.Write(buf,ofs) )
+ return false;
+ } while ( ofs == (ssize_t)WXSIZEOF(buf) );
}
- int ch;
- while ((ch = getc (fp1)) != EOF)
- (void) putc (ch, fp3);
- fclose (fp1);
+ return out.Commit();
- while ((ch = getc (fp2)) != EOF)
- (void) putc (ch, fp3);
- fclose (fp2);
+#else
+
+ wxUnusedVar(file1);
+ wxUnusedVar(file2);
+ wxUnusedVar(file3);
+ return false;
- fclose (fp3);
- bool result = wxRenameFile(outfile, file3);
- return result;
+#endif
}
// Copy files
return false;
}
#elif defined(__OS2__)
- if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
+ if ( ::DosCopy((PSZ)file1.c_str(), (PSZ)file2.c_str(), overwrite ? DCPY_EXISTING : 0) != 0 )
return false;
#elif defined(__PALMOS__)
// TODO with http://www.palmos.com/dev/support/docs/protein_books/Memory_Databases_Files/
return false;
-#else // !Win32
+#elif wxUSE_FILE // !Win32
wxStructStat fbuf;
// get permissions of file1
return false;
}
#endif // OS/2 || Mac
+
+#else // !Win32 && ! wxUSE_FILE
+
+ // impossible to simulate with wxWidgets API
+ wxUnusedVar(file1);
+ wxUnusedVar(file2);
+ wxUnusedVar(overwrite);
+ return false;
+
#endif // __WXMSW__ && __WIN32__
return true;
}
// does the path exists? (may have or not '/' or '\\' at the end)
-bool wxPathExists(const wxChar *pszPathName)
+bool wxDirExists(const wxChar *pszPathName)
{
wxString strPath(pszPathName);
return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY);
#elif defined(__OS2__)
- return (::DosSetCurrentDir(WXSTRINGCAST strPath));
+ return (::DosSetCurrentDir((PSZ)(WXSTRINGCAST strPath)));
#else // !__WIN32__
wxStructStat st;
return buf;
#else
+ wxUnusedVar(prefix);
+ wxUnusedVar(buf);
// wxFileName::CreateTempFileName needs wxFile class enabled
return NULL;
#endif
wxFileKind wxGetFileKind(FILE *fp)
{
- // note: the watcom rtl dll doesn't have fileno (the static lib does)
-#if !defined wxFILEKIND_STUB && !(defined __WATCOMC__ && defined __SW_BR)
- return wxGetFileKind(fileno(fp));
-#else
+ // Note: The watcom rtl dll doesn't have fileno (the static lib does).
+ // Should be fixed in version 1.4.
+#if defined(wxFILEKIND_STUB) || \
+ (defined(__WATCOMC__) && __WATCOMC__ <= 1230 && defined(__SW_BR))
(void)fp;
return wxFILE_KIND_DISK;
+#else
+ return wxGetFileKind(fileno(fp));
#endif
}