#endif
#ifdef __WINDOWS__
- #include "wx/msw/wrapwin.h"
+ #include "wx/msw/private.h"
#include "wx/msw/mslu.h"
// sys/cygwin.h is needed for cygwin_conv_to_full_win32_path()
#include <sys/cygwin.h>
#endif
#endif // __GNUWIN32__
+
+ // io.h is needed for _get_osfhandle()
+ // Already included by filefn.h for many Windows compilers
+ #if defined __MWERKS__ || defined __CYGWIN__
+ #include <io.h>
+ #endif
#endif // __WINDOWS__
#if defined(__VMS__)
delete [] s;
}
-#endif
+#else // __WXWINCE__
+ wxUnusedVar(envVariable);
+#endif // !__WXWINCE__/__WXWINCE__
}
// Given a full filename (with path), ensure that that file can
const wxChar *val;
#ifndef __WXWINCE__
wxChar *tcp;
- if (envname != WXSTRINGCAST NULL && (val = wxGetenv (WXSTRINGCAST envname)) != NULL &&
+ if (!envname.empty() && (val = wxGetenv (WXSTRINGCAST envname)) != NULL &&
(tcp = wxStrstr (dest, val)) != NULL)
{
wxStrcpy (wxFileFunctionsBuffer, tcp + wxStrlen (val));
wxStrcat (tcp, wxT("}"));
wxStrcat (tcp, wxFileFunctionsBuffer);
}
+#else
+ wxUnusedVar(envname);
#endif
// Handle User's home (ignore root homes!)
}
// 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);
DWORD ret = ::GetFileAttributes(strPath);
return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY);
+#elif defined(__OS2__)
+ return (::DosSetCurrentDir(WXSTRINGCAST strPath));
#else // !__WIN32__
wxStructStat st;
// TODO ?
return NULL;
#elif defined(__WXWINCE__)
+ // TODO
+ wxUnusedVar(buf);
+ wxUnusedVar(sz);
return NULL;
#else
if ( !buf )
#ifdef __WIN32__
#ifdef __WXWINCE__
// No equivalent in WinCE
+ wxUnusedVar(d);
return false;
#else
return (bool)(SetCurrentDirectory(d) != 0);
// autocompletion
for( size_t j = 0 ; j < descriptions.GetCount() ; j++ )
{
- if ( descriptions[j] == wxEmptyString && filters[j] != wxEmptyString )
+ if ( descriptions[j].empty() && !filters[j].empty() )
{
descriptions[j].Printf(_("Files (%s)"), filters[j].c_str());
}
// Return the type of an open file
//
+// Some file types on some platforms seem seekable but in fact are not.
+// The main use of this function is to allow such cases to be detected
+// (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
+//
+// This is important for the archive streams, which benefit greatly from
+// being able to seek on a stream, but which will produce corrupt archives
+// if they unknowingly seek on a non-seekable stream.
+//
+// wxFILE_KIND_DISK is a good catch all return value, since other values
+// disable features of the archive streams. Some other value must be returned
+// for a file type that appears seekable but isn't.
+//
+// Known examples:
+// * Pipes on Windows
+// * Files on VMS with a record format other than StreamLF
+//
wxFileKind wxGetFileKind(int fd)
{
-#if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
- if (isatty(fd))
- return wxFILE_KIND_TERMINAL;
-#endif
-
-#if defined(__WXPALMOS__)
- return wxFILE_KIND_UNKNOWN;
-#elif defined(__WXWINCE__)
- return wxFILE_KIND_UNKNOWN;
-#elif defined(__WXMSW__)
+#if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
{
+ case FILE_TYPE_CHAR:
+ return wxFILE_KIND_TERMINAL;
case FILE_TYPE_DISK:
return wxFILE_KIND_DISK;
case FILE_TYPE_PIPE:
return wxFILE_KIND_UNKNOWN;
#elif defined(__UNIX__)
+ if (isatty(fd))
+ return wxFILE_KIND_TERMINAL;
+
struct stat st;
fstat(fd, &st);
return wxFILE_KIND_DISK;
#else
- if (lseek(fd, 0, SEEK_CUR) != -1)
- return wxFILE_KIND_DISK;
- else
- return wxFILE_KIND_UNKNOWN;
+ #define wxFILEKIND_STUB
+ (void)fd;
+ return wxFILE_KIND_DISK;
+#endif
+}
+
+wxFileKind wxGetFileKind(FILE *fp)
+{
+ // 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
}