From: Włodzimierz Skiba Date: Thu, 24 Feb 2005 18:01:42 +0000 (+0000) Subject: Next step on bringing PalmOS build to the same filelist as in bakefiles: adjustements... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/683510536fc4c7eb8e0bfbc5868619f0ab3287df 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 --- diff --git a/build/palmos/makefile b/build/palmos/makefile index 3d43071952..c30d176310 100644 --- a/build/palmos/makefile +++ b/build/palmos/makefile @@ -54,7 +54,15 @@ BASE_CMN_SRC = \ ../../src/common/dynlib.cpp \ ../../src/common/dynload.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 \ $(BASE_CMN_SRC) \ @@ -87,18 +95,12 @@ $(BASE_CMN_SRC) \ ../../src/common/effects.cpp \ ../../src/common/event.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/fmapbase.cpp \ ../../src/common/fontcmn.cpp \ ../../src/common/fontmap.cpp \ ../../src/common/framecmn.cpp \ ../../src/common/fs_inet.cpp \ ../../src/common/fs_mem.cpp \ -../../src/common/fs_zip.cpp \ ../../src/common/ftp.cpp \ ../../src/common/gaugecmn.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/ ## -------------------------------------------------------------------------- -CREATOR_ID = bapp +CREATOR_ID = wx06 DB_TYPE = appl DATABASE_RESET = diff --git a/include/wx/filename.h b/include/wx/filename.h index 9711cd6fa8..654ab52707 100644 --- a/include/wx/filename.h +++ b/include/wx/filename.h @@ -39,7 +39,9 @@ #include "wx/filefn.h" #include "wx/datetime.h" +#if wxUSE_FILE class WXDLLIMPEXP_BASE wxFile; +#endif // ---------------------------------------------------------------------------- // constants @@ -240,12 +242,14 @@ public: void AssignHomeDir(); static wxString GetHomeDir(); +#if wxUSE_FILE // get a temp file name starting with the specified prefix and open the // file passed to us using this name for writing (atomically if // possible) void AssignTempFileName(const wxString& prefix, wxFile *fileTemp = NULL); static wxString CreateTempFileName(const wxString& prefix, wxFile *fileTemp = NULL); +#endif // wxUSE_FILE // directory creation and removal. bool Mkdir( int perm = 0777, int flags = 0); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 876619c2c7..ae3ff0335e 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -75,7 +75,7 @@ #endif // __GNUWIN32__ #endif // __WINDOWS__ -#if defined __VMS__ +#if defined(__VMS__) #include #endif @@ -230,7 +230,7 @@ bool wxPathList::Member (const wxString& path) { wxString path2( node->GetData() ); if ( -#if defined(__WINDOWS__) || defined(__OS2__) || defined(__VMS__) || defined (__WXMAC__) +#if defined(__WINDOWS__) || defined(__OS2__) || defined(__VMS__) || defined(__WXMAC__) // Case INDEPENDENT path.CompareTo (path2, wxString::ignoreCase) == 0 #else @@ -294,9 +294,11 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) bool 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 // it can cope with network (UNC) paths unlike them -#if defined(__WIN32__) && !defined(__WXMICROWIN__) DWORD ret = ::GetFileAttributes(filename); return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY); @@ -1001,6 +1003,9 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) #elif defined(__OS2__) if ( ::DosCopy(file2, file2, 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 wxStructStat fbuf; @@ -1080,7 +1085,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) bool wxRenameFile (const wxString& file1, const wxString& file2) { -#ifndef __WXWINCE__ +#if !defined(__WXWINCE__) && !defined(__WXPALMOS__) // Normal system call if ( wxRename (file1, file2) == 0 ) return true; @@ -1103,20 +1108,25 @@ bool wxRemoveFile(const wxString& file) || defined(__DMC__) \ || defined(__GNUWIN32__) \ || (defined(__MWERKS__) && defined(__MSL__)) - int res = wxRemove(file); + int res = wxRemove(file); #elif defined(__WXMAC__) - int res = unlink(wxFNCONV(file)); + int res = unlink(wxFNCONV(file)); +#elif defined(__WXPALMOS__) + int res = 1; + // TODO with VFSFileDelete() #else - int res = unlink(OS_FILENAME(file)); + int res = unlink(OS_FILENAME(file)); #endif - return res == 0; + return res == 0; } bool wxMkdir(const wxString& dir, int perm) { -#if defined(__WXMAC__) && !defined(__UNIX__) - return (mkdir( wxFNCONV(dir) , 0 ) == 0); +#if defined(__WXPALMOS__) + return false; +#elif defined(__WXMAC__) && !defined(__UNIX__) + return (mkdir( wxFNCONV(dir) , 0 ) == 0); #else // !Mac 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)) { -#ifdef __VMS__ +#if defined(__VMS__) return false; //to be changed since rmdir exists in VMS7.x #elif defined(__OS2__) return (::DosDeleteDir((PSZ)dir.c_str()) == 0); -#else - -#ifdef __WXWINCE__ +#elif defined(__WXWINCE__) return (CreateDirectory(dir, NULL) != 0); +#elif defined(__WXPALMOS__) + // TODO with VFSFileRename() + return false; #else return (wxRmDir(OS_FILENAME(dir)) == 0); #endif - -#endif } // does the path exists? (may have or not '/' or '\\' at the end) @@ -1200,7 +1209,9 @@ bool wxPathExists(const wxChar *pszPathName) strPath << _T('.'); #endif -#if defined(__WIN32__) && !defined(__WXMICROWIN__) +#if defined(__WXPALMOS__) + return false; +#elif defined(__WIN32__) && !defined(__WXMICROWIN__) // stat() can't cope with network paths DWORD ret = ::GetFileAttributes(strPath); @@ -1221,6 +1232,7 @@ bool wxPathExists(const wxChar *pszPathName) // Get a temporary filename, opening and closing the file. wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf) { +#if wxUSE_FILE wxString filename = wxFileName::CreateTempFileName(prefix); if ( filename.empty() ) return NULL; @@ -1231,11 +1243,15 @@ wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf) buf = MYcopystring(filename); return buf; +#else + // wxFileName::CreateTempFileName needs wxFile class enabled + return NULL; +#endif } bool wxGetTempFileName(const wxString& prefix, wxString& buf) { - buf = wxFileName::CreateTempFileName(prefix); + buf = wxGetTempFileName(prefix); return !buf.empty(); } @@ -1304,7 +1320,10 @@ wxString wxFindNextFile() // copies into buf. wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) { -#ifdef __WXWINCE__ +#if defined(__WXPALMOS__) + // TODO ? + return NULL; +#elif defined(__WXWINCE__) return NULL; #else if ( !buf ) @@ -1556,7 +1575,9 @@ void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) { -#ifdef __WXWINCE__ +#if defined(__WXPALMOS__) + return 0; +#elif defined(__WXWINCE__) FILETIME creationTime, lastAccessTime, lastWriteTime; HANDLE fileHandle = ::CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, 0, FILE_ATTRIBUTE_NORMAL, 0); @@ -1860,14 +1881,16 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) // wxFileKind wxGetFileKind(int fd) { -#if !defined (__WXWINCE__) +#if !defined(__WXWINCE__) && !defined(__WXPALMOS__) if (isatty(fd)) return wxFILE_KIND_TERMINAL; #endif -#if defined __WXWINCE__ +#if defined(__WXPALMOS__) + return wxFILE_KIND_UNKNOWN; +#elif defined(__WXWINCE__) return wxFILE_KIND_UNKNOWN; -#elif defined __WXMSW__ +#elif defined(__WXMSW__) switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE) { case FILE_TYPE_DISK: @@ -1878,7 +1901,7 @@ wxFileKind wxGetFileKind(int fd) return wxFILE_KIND_UNKNOWN; -#elif defined __UNIX__ +#elif defined(__UNIX__) struct stat st; fstat(fd, &st); @@ -1887,7 +1910,7 @@ wxFileKind wxGetFileKind(int fd) if (!S_ISREG(st.st_mode)) return wxFILE_KIND_UNKNOWN; - #if defined __VMS__ + #if defined(__VMS__) if (st.st_fab_rfm != FAB$C_STMLF) return wxFILE_KIND_UNKNOWN; #endif diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 9553e92a27..cdf66a8c4a 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -573,6 +573,8 @@ wxString wxFileName::GetHomeDir() return ::wxGetHomeDir(); } +#if wxUSE_FILE + void wxFileName::AssignTempFileName(const wxString& prefix, wxFile *fileTemp) { wxString tempname = CreateTempFileName(prefix, fileTemp); @@ -604,7 +606,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) } path = dir + wxT("\\") + prefix; int i = 1; - while (wxFileExists(path)) + while (FileExists(path)) { path = dir + wxT("\\") + prefix ; path << i; @@ -720,7 +722,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) } #else // !HAVE_MKTEMP (includes __DOS__) // 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(); #endif @@ -731,7 +733,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) { // 3 hex digits is enough for numTries == 1000 < 4096 pathTry = path + wxString::Format(_T("%.03x"), (unsigned int) n); - if ( !wxFile::Exists(pathTry) ) + if ( !FileExists(pathTry) ) { break; } @@ -782,6 +784,8 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) return path; } +#endif // wxUSE_FILE + // ---------------------------------------------------------------------------- // directory operations // ----------------------------------------------------------------------------