Next step on bringing PalmOS build to the same filelist as in bakefiles: adjustements in file related wxAPI.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32352 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-02-24 18:01:42 +00:00
parent f469584d64
commit 683510536f
4 changed files with 69 additions and 36 deletions

View File

@@ -54,7 +54,15 @@ BASE_CMN_SRC = \
../../src/common/dynlib.cpp \ ../../src/common/dynlib.cpp \
../../src/common/dynload.cpp \ ../../src/common/dynload.cpp \
../../src/common/encconv.cpp \ ../../src/common/encconv.cpp \
../../src/common/extended.c ../../src/common/extended.c \
../../src/common/ffile.cpp \
../../src/common/file.cpp \
../../src/common/fileconf.cpp \
../../src/common/filefn.cpp \
../../src/common/filename.cpp \
../../src/common/filesys.cpp \
../../src/common/fmapbase.cpp \
../../src/common/fs_zip.cpp
SOURCES = ../../samples/minimal/minimal.cpp \ SOURCES = ../../samples/minimal/minimal.cpp \
$(BASE_CMN_SRC) \ $(BASE_CMN_SRC) \
@@ -87,18 +95,12 @@ $(BASE_CMN_SRC) \
../../src/common/effects.cpp \ ../../src/common/effects.cpp \
../../src/common/event.cpp \ ../../src/common/event.cpp \
../../src/common/fddlgcmn.cpp \ ../../src/common/fddlgcmn.cpp \
../../src/common/ffile.cpp \
../../src/common/file.cpp \
../../src/common/fileconf.cpp \
../../src/common/filesys.cpp \
../../src/common/fldlgcmn.cpp \ ../../src/common/fldlgcmn.cpp \
../../src/common/fmapbase.cpp \
../../src/common/fontcmn.cpp \ ../../src/common/fontcmn.cpp \
../../src/common/fontmap.cpp \ ../../src/common/fontmap.cpp \
../../src/common/framecmn.cpp \ ../../src/common/framecmn.cpp \
../../src/common/fs_inet.cpp \ ../../src/common/fs_inet.cpp \
../../src/common/fs_mem.cpp \ ../../src/common/fs_mem.cpp \
../../src/common/fs_zip.cpp \
../../src/common/ftp.cpp \ ../../src/common/ftp.cpp \
../../src/common/gaugecmn.cpp \ ../../src/common/gaugecmn.cpp \
../../src/common/gbsizer.cpp \ ../../src/common/gbsizer.cpp \
@@ -295,7 +297,7 @@ SLD_FILE = ../../include/wx/palmos/wxWidgets.sld
# Register Creator ID at: http://dev.palmos.com/creatorid/ # Register Creator ID at: http://dev.palmos.com/creatorid/
## -------------------------------------------------------------------------- ## --------------------------------------------------------------------------
CREATOR_ID = bapp CREATOR_ID = wx06
DB_TYPE = appl DB_TYPE = appl
DATABASE_RESET = DATABASE_RESET =

View File

@@ -39,7 +39,9 @@
#include "wx/filefn.h" #include "wx/filefn.h"
#include "wx/datetime.h" #include "wx/datetime.h"
#if wxUSE_FILE
class WXDLLIMPEXP_BASE wxFile; class WXDLLIMPEXP_BASE wxFile;
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
@@ -240,12 +242,14 @@ public:
void AssignHomeDir(); void AssignHomeDir();
static wxString GetHomeDir(); static wxString GetHomeDir();
#if wxUSE_FILE
// get a temp file name starting with the specified prefix and open the // get a temp file name starting with the specified prefix and open the
// file passed to us using this name for writing (atomically if // file passed to us using this name for writing (atomically if
// possible) // possible)
void AssignTempFileName(const wxString& prefix, wxFile *fileTemp = NULL); void AssignTempFileName(const wxString& prefix, wxFile *fileTemp = NULL);
static wxString CreateTempFileName(const wxString& prefix, static wxString CreateTempFileName(const wxString& prefix,
wxFile *fileTemp = NULL); wxFile *fileTemp = NULL);
#endif // wxUSE_FILE
// directory creation and removal. // directory creation and removal.
bool Mkdir( int perm = 0777, int flags = 0); bool Mkdir( int perm = 0777, int flags = 0);

View File

@@ -75,7 +75,7 @@
#endif // __GNUWIN32__ #endif // __GNUWIN32__
#endif // __WINDOWS__ #endif // __WINDOWS__
#if defined __VMS__ #if defined(__VMS__)
#include <fab.h> #include <fab.h>
#endif #endif
@@ -294,9 +294,11 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file)
bool bool
wxFileExists (const wxString& filename) wxFileExists (const wxString& filename)
{ {
#if defined(__WXPALMOS__)
return false;
#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
// we must use GetFileAttributes() instead of the ANSI C functions because // we must use GetFileAttributes() instead of the ANSI C functions because
// it can cope with network (UNC) paths unlike them // it can cope with network (UNC) paths unlike them
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
DWORD ret = ::GetFileAttributes(filename); DWORD ret = ::GetFileAttributes(filename);
return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY); return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
@@ -1001,6 +1003,9 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
#elif defined(__OS2__) #elif defined(__OS2__)
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 ) if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
return false; return false;
#elif defined(__PALMOS__)
// TODO with http://www.palmos.com/dev/support/docs/protein_books/Memory_Databases_Files/
return false;
#else // !Win32 #else // !Win32
wxStructStat fbuf; wxStructStat fbuf;
@@ -1080,7 +1085,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
bool bool
wxRenameFile (const wxString& file1, const wxString& file2) wxRenameFile (const wxString& file1, const wxString& file2)
{ {
#ifndef __WXWINCE__ #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
// Normal system call // Normal system call
if ( wxRename (file1, file2) == 0 ) if ( wxRename (file1, file2) == 0 )
return true; return true;
@@ -1106,6 +1111,9 @@ bool wxRemoveFile(const wxString& file)
int res = wxRemove(file); int res = wxRemove(file);
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
int res = unlink(wxFNCONV(file)); int res = unlink(wxFNCONV(file));
#elif defined(__WXPALMOS__)
int res = 1;
// TODO with VFSFileDelete()
#else #else
int res = unlink(OS_FILENAME(file)); int res = unlink(OS_FILENAME(file));
#endif #endif
@@ -1115,7 +1123,9 @@ bool wxRemoveFile(const wxString& file)
bool wxMkdir(const wxString& dir, int perm) bool wxMkdir(const wxString& dir, int perm)
{ {
#if defined(__WXMAC__) && !defined(__UNIX__) #if defined(__WXPALMOS__)
return false;
#elif defined(__WXMAC__) && !defined(__UNIX__)
return (mkdir( wxFNCONV(dir) , 0 ) == 0); return (mkdir( wxFNCONV(dir) , 0 ) == 0);
#else // !Mac #else // !Mac
const wxChar *dirname = dir.c_str(); const wxChar *dirname = dir.c_str();
@@ -1160,19 +1170,18 @@ bool wxMkdir(const wxString& dir, int perm)
bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
{ {
#ifdef __VMS__ #if defined(__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(__OS2__) #elif defined(__OS2__)
return (::DosDeleteDir((PSZ)dir.c_str()) == 0); return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else #elif defined(__WXWINCE__)
#ifdef __WXWINCE__
return (CreateDirectory(dir, NULL) != 0); return (CreateDirectory(dir, NULL) != 0);
#elif defined(__WXPALMOS__)
// TODO with VFSFileRename()
return false;
#else #else
return (wxRmDir(OS_FILENAME(dir)) == 0); return (wxRmDir(OS_FILENAME(dir)) == 0);
#endif #endif
#endif
} }
// does the path exists? (may have or not '/' or '\\' at the end) // does the path exists? (may have or not '/' or '\\' at the end)
@@ -1200,7 +1209,9 @@ bool wxPathExists(const wxChar *pszPathName)
strPath << _T('.'); strPath << _T('.');
#endif #endif
#if defined(__WIN32__) && !defined(__WXMICROWIN__) #if defined(__WXPALMOS__)
return false;
#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
// stat() can't cope with network paths // stat() can't cope with network paths
DWORD ret = ::GetFileAttributes(strPath); DWORD ret = ::GetFileAttributes(strPath);
@@ -1221,6 +1232,7 @@ bool wxPathExists(const wxChar *pszPathName)
// Get a temporary filename, opening and closing the file. // Get a temporary filename, opening and closing the file.
wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf) wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf)
{ {
#if wxUSE_FILE
wxString filename = wxFileName::CreateTempFileName(prefix); wxString filename = wxFileName::CreateTempFileName(prefix);
if ( filename.empty() ) if ( filename.empty() )
return NULL; return NULL;
@@ -1231,11 +1243,15 @@ wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf)
buf = MYcopystring(filename); buf = MYcopystring(filename);
return buf; return buf;
#else
// wxFileName::CreateTempFileName needs wxFile class enabled
return NULL;
#endif
} }
bool wxGetTempFileName(const wxString& prefix, wxString& buf) bool wxGetTempFileName(const wxString& prefix, wxString& buf)
{ {
buf = wxFileName::CreateTempFileName(prefix); buf = wxGetTempFileName(prefix);
return !buf.empty(); return !buf.empty();
} }
@@ -1304,7 +1320,10 @@ wxString wxFindNextFile()
// copies into buf. // copies into buf.
wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
{ {
#ifdef __WXWINCE__ #if defined(__WXPALMOS__)
// TODO ?
return NULL;
#elif defined(__WXWINCE__)
return NULL; return NULL;
#else #else
if ( !buf ) if ( !buf )
@@ -1556,7 +1575,9 @@ void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName,
time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename)
{ {
#ifdef __WXWINCE__ #if defined(__WXPALMOS__)
return 0;
#elif defined(__WXWINCE__)
FILETIME creationTime, lastAccessTime, lastWriteTime; FILETIME creationTime, lastAccessTime, lastWriteTime;
HANDLE fileHandle = ::CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE fileHandle = ::CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
0, FILE_ATTRIBUTE_NORMAL, 0); 0, FILE_ATTRIBUTE_NORMAL, 0);
@@ -1860,14 +1881,16 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
// //
wxFileKind wxGetFileKind(int fd) wxFileKind wxGetFileKind(int fd)
{ {
#if !defined (__WXWINCE__) #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
if (isatty(fd)) if (isatty(fd))
return wxFILE_KIND_TERMINAL; return wxFILE_KIND_TERMINAL;
#endif #endif
#if defined __WXWINCE__ #if defined(__WXPALMOS__)
return wxFILE_KIND_UNKNOWN; return wxFILE_KIND_UNKNOWN;
#elif defined __WXMSW__ #elif defined(__WXWINCE__)
return wxFILE_KIND_UNKNOWN;
#elif defined(__WXMSW__)
switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE) switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
{ {
case FILE_TYPE_DISK: case FILE_TYPE_DISK:
@@ -1878,7 +1901,7 @@ wxFileKind wxGetFileKind(int fd)
return wxFILE_KIND_UNKNOWN; return wxFILE_KIND_UNKNOWN;
#elif defined __UNIX__ #elif defined(__UNIX__)
struct stat st; struct stat st;
fstat(fd, &st); fstat(fd, &st);
@@ -1887,7 +1910,7 @@ wxFileKind wxGetFileKind(int fd)
if (!S_ISREG(st.st_mode)) if (!S_ISREG(st.st_mode))
return wxFILE_KIND_UNKNOWN; return wxFILE_KIND_UNKNOWN;
#if defined __VMS__ #if defined(__VMS__)
if (st.st_fab_rfm != FAB$C_STMLF) if (st.st_fab_rfm != FAB$C_STMLF)
return wxFILE_KIND_UNKNOWN; return wxFILE_KIND_UNKNOWN;
#endif #endif

View File

@@ -573,6 +573,8 @@ wxString wxFileName::GetHomeDir()
return ::wxGetHomeDir(); return ::wxGetHomeDir();
} }
#if wxUSE_FILE
void wxFileName::AssignTempFileName(const wxString& prefix, wxFile *fileTemp) void wxFileName::AssignTempFileName(const wxString& prefix, wxFile *fileTemp)
{ {
wxString tempname = CreateTempFileName(prefix, fileTemp); wxString tempname = CreateTempFileName(prefix, fileTemp);
@@ -604,7 +606,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
} }
path = dir + wxT("\\") + prefix; path = dir + wxT("\\") + prefix;
int i = 1; int i = 1;
while (wxFileExists(path)) while (FileExists(path))
{ {
path = dir + wxT("\\") + prefix ; path = dir + wxT("\\") + prefix ;
path << i; path << i;
@@ -720,7 +722,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
} }
#else // !HAVE_MKTEMP (includes __DOS__) #else // !HAVE_MKTEMP (includes __DOS__)
// generate the unique file name ourselves // generate the unique file name ourselves
#if !defined(__DOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) ) #if !defined(__DOS__) && !defined(__PALMOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) )
path << (unsigned int)getpid(); path << (unsigned int)getpid();
#endif #endif
@@ -731,7 +733,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
{ {
// 3 hex digits is enough for numTries == 1000 < 4096 // 3 hex digits is enough for numTries == 1000 < 4096
pathTry = path + wxString::Format(_T("%.03x"), (unsigned int) n); pathTry = path + wxString::Format(_T("%.03x"), (unsigned int) n);
if ( !wxFile::Exists(pathTry) ) if ( !FileExists(pathTry) )
{ {
break; break;
} }
@@ -782,6 +784,8 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
return path; return path;
} }
#endif // wxUSE_FILE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// directory operations // directory operations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------