#endif // __GNUWIN32__
#endif // __WINDOWS__
+#if defined __VMS__
+ #include <fab.h>
+#endif
+
// TODO: Borland probably has _wgetcwd as well?
#ifdef _MSC_VER
#define HAVE_WGETCWD
bool
wxIsAbsolutePath (const wxString& filename)
{
- if (filename != wxT(""))
+ if (!filename.empty())
{
#if defined(__WXMAC__) && !defined(__DARWIN__)
// Classic or Carbon CodeWarrior like
// Must be destroyed
wxChar *wxCopyAbsolutePath(const wxString& filename)
{
- if (filename == wxT(""))
+ if (filename.empty())
return (wxChar *) NULL;
if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer, filename))) {
if (nm[1] == SEP || nm[1] == 0)
{ /* ~/filename */
// FIXME: wxGetUserHome could return temporary storage in Unicode mode
- if ((s = WXSTRINGCAST wxGetUserHome(wxT(""))) != NULL) {
+ if ((s = WXSTRINGCAST wxGetUserHome(wxEmptyString)) != NULL) {
if (*++nm)
nm++;
}
{
static wxChar dest[_MAXPATHLEN];
- if (filename == wxT(""))
+ if (filename.empty())
return (wxChar *) NULL;
wxStrcpy (dest, WXSTRINGCAST filename);
if (wxStrncmp(dest, val, len) == 0)
{
wxStrcpy(wxFileFunctionsBuffer, wxT("~"));
- if (user != wxT(""))
+ if (!user.empty())
wxStrcat(wxFileFunctionsBuffer, (const wxChar*) user);
wxStrcat(wxFileFunctionsBuffer, dest + len);
wxStrcpy (dest, wxFileFunctionsBuffer);
// Return just the directory, or NULL if no directory
wxString wxPathOnly (const wxString& path)
{
- if (path != wxT(""))
+ if (!path.empty())
{
wxChar buf[_MAXPATHLEN];
}
#endif
}
- return wxString(wxT(""));
+ return wxEmptyString;
}
// Utility for converting delimiters in DOS filenames to UNIX style
FILE *fp2 = NULL;
FILE *fp3 = NULL;
// Open the inputs and outputs
- if ((fp1 = wxFopen ( file1.fn_str(), wxT("rb"))) == NULL ||
- (fp2 = wxFopen ( file2.fn_str(), wxT("rb"))) == NULL ||
- (fp3 = wxFopen ( outfile.fn_str(), wxT("wb"))) == NULL)
+ if ((fp1 = wxFopen ( file1, wxT("rb"))) == NULL ||
+ (fp2 = wxFopen ( file2, wxT("rb"))) == NULL ||
+ (fp3 = wxFopen ( outfile, wxT("wb"))) == NULL)
{
if (fp1)
fclose (fp1);
}
}
+// Return the type of an open file
+//
+wxFileTypeEnum wxGetFileType(int fd)
+{
+ if (isatty(fd))
+ return wxFILE_TYPE_TERMINAL;
+
+#if defined __WXMSW__
+ switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
+ {
+ case FILE_TYPE_DISK:
+ return wxFILE_TYPE_DISK;
+ case FILE_TYPE_PIPE:
+ return wxFILE_TYPE_PIPE;
+ }
+
+ return wxFILE_TYPE_UNKNOWN;
+
+#elif defined __UNIX__
+ struct stat st;
+ fstat(fd, &st);
+
+ if (S_ISFIFO(st.st_mode))
+ return wxFILE_TYPE_PIPE;
+ if (!S_ISREG(st.st_mode))
+ return wxFILE_TYPE_UNKNOWN;
+
+ #if defined __VMS__
+ if (st.st_fab_rfm != FAB$C_STMLF)
+ return wxFILE_TYPE_UNKNOWN;
+ #endif
+
+ return wxFILE_TYPE_DISK;
+
+#else
+ if (lseek(fd, 0, SEEK_CUR) != -1)
+ return wxFILE_TYPE_DISK;
+ else
+ return wxFILE_TYPE_UNKNOWN;
+#endif
+}
#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression