// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "filefn.h"
#endif
#include "wx/mac/private.h" // includes mac headers
#endif
+#ifdef __WXWINCE__
+#include "wx/msw/wince/time.h"
+#include "wx/msw/private.h"
+#else
#include <time.h>
+#endif
-#ifndef __MWERKS__
+#ifdef __WXWINCE__
+// Nothing
+#elif !defined(__MWERKS__)
#include <sys/types.h>
#include <sys/stat.h>
#else
#include "wx/os2/private.h"
#endif
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
-#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
+#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !defined(__WXWINCE__)
#include <direct.h>
#include <dos.h>
#include <io.h>
#endif
#ifdef __WINDOWS__
- #include <windows.h>
+ #include "wx/msw/wrapwin.h"
#include "wx/msw/mslu.h"
// for _getcwd
// wxPathList
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
+// IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
static inline wxChar* MYcopystring(const wxString& s)
{
// Add paths e.g. from the PATH environment variable
void wxPathList::AddEnvList (const wxString& envVariable)
{
+ // No environment variables on WinCE
+#ifndef __WXWINCE__
static const wxChar PATH_TOKS[] =
#ifdef __WINDOWS__
/*
delete [] s;
}
+#endif
}
// Given a full filename (with path), ensure that that file can
bool wxPathList::Member (const wxString& path)
{
- for (wxStringList::Node *node = GetFirst(); node; node = node->GetNext())
+ for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext())
{
wxString path2( node->GetData() );
if (
wxChar buf[_MAXPATHLEN];
wxStrcpy(buf, wxFileFunctionsBuffer);
- wxChar *filename = (wxChar*) NULL; /* shut up buggy egcs warning */
- filename = wxIsAbsolutePath (buf) ? wxFileNameFromPath (buf) : (wxChar *)buf;
+ wxChar *filename = wxIsAbsolutePath (buf) ? wxFileNameFromPath (buf) : (wxChar *)buf;
- for (wxStringList::Node *node = GetFirst(); node; node = node->GetNext())
+ for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext())
{
- wxChar *path = node->GetData();
+ const wxChar *path = node->GetData();
wxStrcpy (wxFileFunctionsBuffer, path);
wxChar ch = wxFileFunctionsBuffer[wxStrlen(wxFileFunctionsBuffer)-1];
if (ch != wxT('\\') && ch != wxT('/'))
} else
# endif
#endif
+ // No env variables on WinCE
+#ifndef __WXWINCE__
#ifdef __WXMSW__
if (*s++ == wxT('$') && (*s == wxT('{') || *s == wxT(')')))
#else
s++;
}
}
+#endif
+ // __WXWINCE__
}
/* Expand ~ and ~user */
#endif
// Handle environment
- const wxChar *val = (const wxChar *) NULL;
- wxChar *tcp = (wxChar *) NULL;
+ const wxChar *val;
+#ifndef __WXWINCE__
+ wxChar *tcp;
if (envname != WXSTRINGCAST NULL && (val = wxGetenv (WXSTRINGCAST envname)) != NULL &&
(tcp = wxStrstr (dest, val)) != NULL)
{
wxStrcat (tcp, wxT("}"));
wxStrcat (tcp, wxFileFunctionsBuffer);
}
+#endif
// Handle User's home (ignore root homes!)
- size_t len = 0;
+ size_t len;
if ((val = wxGetUserHome (user)) != NULL &&
(len = wxStrlen(val)) > 2 &&
wxStrncmp(dest, val, len) == 0)
}
// create path string for return value
- wxString result( thePath ) ;
+ wxString result( thePath , wxConvLocal) ;
#else
Handle myPath ;
short length ;
(*myPath)[length-1] = 0 ;
// create path string for return value
- wxString result = wxMacMakeStringFromCString( *myPath ) ;
+ wxString result( *myPath , wxConvLocal) ;
// free allocated handle
::HUnlock( myPath ) ;
#if wxUSE_UNICODE
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec )
{
- return wxMacFilename2FSSpec( wxMacStringToCString( wxString( path ) ) , spec ) ;
+ return wxMacFilename2FSSpec( wxConvFile.cWC2MB(path) , spec ) ;
}
#endif
if ( !wxGetTempFileName( wxT("cat"), outfile) )
return FALSE;
- FILE *fp1 = (FILE *) NULL;
- FILE *fp2 = (FILE *) NULL;
- FILE *fp3 = (FILE *) NULL;
+ FILE *fp1 wxDUMMY_INITIALIZE(NULL);
+ FILE *fp2 wxDUMMY_INITIALIZE(NULL);
+ FILE *fp3 wxDUMMY_INITIALIZE(NULL);
// Open the inputs and outputs
if ((fp1 = wxFopen ( file1, wxT("rb"))) == NULL ||
(fp2 = wxFopen ( file2, wxT("rb"))) == NULL ||
bool
wxRenameFile (const wxString& file1, const wxString& file2)
{
- // Normal system call
+#ifndef __WXWINCE__
+ // Normal system call
if ( wxRename (file1, file2) == 0 )
return TRUE;
+#endif
// Try to copy
if (wxCopyFile(file1, file2)) {
#endif
#else // !MSW, !DOS and !OS/2 VAC++
(void)perm;
+#ifdef __WXWINCE__
+ if ( !CreateDirectory(dirname, NULL) )
+#else
if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 )
+#endif
#endif // !MSW/MSW
{
wxLogSysError(_("Directory '%s' couldn't be created"), dirname);
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(__WXPM__)
- return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
+ return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else
-#ifdef __SALFORDC__
- return FALSE; // What to do?
+#ifdef __WXWINCE__
+ return (CreateDirectory(dir, NULL) != 0);
#else
- return (wxRmDir(OS_FILENAME(dir)) == 0);
+ return (wxRmDir(OS_FILENAME(dir)) == 0);
#endif
#endif
return wxEmptyString;
}
- int dirFlags = 0;
+ int dirFlags;
switch (flags)
{
case wxDIR: dirFlags = wxDIR_DIRS; break;
// copies into buf.
wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
{
+#ifdef __WXWINCE__
+ return NULL;
+#else
if ( !buf )
{
buf = new wxChar[sz + 1];
}
- bool ok = 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
#undef cbuf
#endif
+
+#endif
+ // __WXWINCE__
}
wxString wxGetCwd()
bool wxSetWorkingDirectory(const wxString& d)
{
#if defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
- return (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
+ return (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
#elif defined(__WXPM__)
- return (::DosSetCurrentDir((PSZ)d.c_str()) == 0);
+ return (::DosSetCurrentDir((PSZ)d.c_str()) == 0);
#elif defined(__WINDOWS__)
-
+
#ifdef __WIN32__
- return (bool)(SetCurrentDirectory(d) != 0);
+#ifdef __WXWINCE__
+ // No equivalent in WinCE
+ return FALSE;
#else
- // Must change drive, too.
- bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':'));
- if (isDriveSpec)
- {
- wxChar firstChar = d[0];
-
- // To upper case
- if (firstChar > 90)
- firstChar = firstChar - 32;
-
- // To a drive number
- unsigned int driveNo = firstChar - 64;
- if (driveNo > 0)
+ return (bool)(SetCurrentDirectory(d) != 0);
+#endif
+#else
+ // Must change drive, too.
+ bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':'));
+ if (isDriveSpec)
{
- unsigned int noDrives;
- _dos_setdrive(driveNo, &noDrives);
+ wxChar firstChar = d[0];
+
+ // To upper case
+ if (firstChar > 90)
+ firstChar = firstChar - 32;
+
+ // To a drive number
+ unsigned int driveNo = firstChar - 64;
+ if (driveNo > 0)
+ {
+ unsigned int noDrives;
+ _dos_setdrive(driveNo, &noDrives);
+ }
}
- }
- bool success = (chdir(WXSTRINGCAST d) == 0);
-
- return success;
+ bool success = (chdir(WXSTRINGCAST d) == 0);
+
+ return success;
#endif
-
+
#endif
}
// On non-Windows platform, probably just return the empty string.
wxString wxGetOSDirectory()
{
-#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
+#ifdef __WXWINCE__
+ return wxString(wxT("\\Windows"));
+#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
wxChar buf[256];
GetWindowsDirectory(buf, 256);
return wxString(buf);
time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename)
{
+#ifdef __WXWINCE__
+ FILETIME creationTime, lastAccessTime, lastWriteTime;
+ HANDLE fileHandle = ::CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
+ 0, FILE_ATTRIBUTE_NORMAL, 0);
+ if (fileHandle == INVALID_HANDLE_VALUE)
+ return 0;
+ else
+ {
+ if (GetFileTime(fileHandle, & creationTime, & lastAccessTime, & lastWriteTime))
+ {
+ CloseHandle(fileHandle);
+
+ wxDateTime dateTime;
+ FILETIME ftLocal;
+ if ( !::FileTimeToLocalFileTime(&lastWriteTime, &ftLocal) )
+ {
+ wxLogLastError(_T("FileTimeToLocalFileTime"));
+ }
+
+ SYSTEMTIME st;
+ if ( !::FileTimeToSystemTime(&ftLocal, &st) )
+ {
+ wxLogLastError(_T("FileTimeToSystemTime"));
+ }
+
+ dateTime.Set(st.wDay, wxDateTime::Month(st.wMonth - 1), st.wYear,
+ st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
+ return dateTime.GetTicks();
+ }
+ else
+ return 0;
+ }
+#else
wxStructStat buf;
wxStat( filename, &buf);
return buf.st_mtime;
+#endif
}