1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/filefn.cpp
3 // Purpose: File- and directory-related functions
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/file.h" // This does include filefn.h
31 #include "wx/filename.h"
34 // there are just too many of those...
36 #pragma warning(disable:4706) // assignment within conditional expression
43 #if !wxONLY_WATCOM_EARLIER_THAN(1,4)
44 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
49 #if defined(__WXMAC__)
50 #include "wx/mac/private.h" // includes mac headers
56 #include "wx/msw/private.h"
57 #include "wx/msw/mslu.h"
59 // sys/cygwin.h is needed for cygwin_conv_to_full_win32_path()
61 // note that it must be included after <windows.h>
64 #include <sys/cygwin.h>
66 #endif // __GNUWIN32__
68 // io.h is needed for _get_osfhandle()
69 // Already included by filefn.h for many Windows compilers
70 #if defined __MWERKS__ || defined __CYGWIN__
79 // TODO: Borland probably has _wgetcwd as well?
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
89 #define _MAXPATHLEN 1024
93 # include "MoreFilesX.h"
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 // MT-FIXME: get rid of this horror and all code using it
101 static wxChar wxFileFunctionsBuffer
[4*_MAXPATHLEN
];
103 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
105 // VisualAge C++ V4.0 cannot have any external linkage const decs
106 // in headers included by more than one primary source
108 const int wxInvalidOffset
= -1;
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 // we need to translate Mac filenames before passing them to OS functions
116 #define OS_FILENAME(s) (s.fn_str())
118 // ============================================================================
120 // ============================================================================
122 #ifdef wxNEED_WX_UNISTD_H
124 WXDLLEXPORT
int wxStat( const wxChar
*file_name
, wxStructStat
*buf
)
126 return stat( wxConvFile
.cWX2MB( file_name
), buf
);
129 WXDLLEXPORT
int wxAccess( const wxChar
*pathname
, int mode
)
131 return access( wxConvFile
.cWX2MB( pathname
), mode
);
134 WXDLLEXPORT
int wxOpen( const wxChar
*pathname
, int flags
, mode_t mode
)
136 return open( wxConvFile
.cWX2MB( pathname
), flags
, mode
);
140 // wxNEED_WX_UNISTD_H
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 // IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
148 static inline wxChar
* MYcopystring(const wxString
& s
)
150 wxChar
* copy
= new wxChar
[s
.length() + 1];
151 return wxStrcpy(copy
, s
.c_str());
154 static inline wxChar
* MYcopystring(const wxChar
* s
)
156 wxChar
* copy
= new wxChar
[wxStrlen(s
) + 1];
157 return wxStrcpy(copy
, s
);
160 void wxPathList::Add (const wxString
& path
)
162 wxStringList::Add (WXSTRINGCAST path
);
165 // Add paths e.g. from the PATH environment variable
166 void wxPathList::AddEnvList (const wxString
& WXUNUSED_IN_WINCE(envVariable
))
168 // No environment variables on WinCE
170 static const wxChar PATH_TOKS
[] =
171 #if defined(__WINDOWS__) || defined(__OS2__)
173 The space has been removed from the tokenizers, otherwise a
174 path such as "C:\Program Files" would be split into 2 paths:
175 "C:\Program" and "Files"
177 // wxT(" ;"); // Don't separate with colon in DOS (used for drive)
178 wxT(";"); // Don't separate with colon in DOS (used for drive)
184 if (wxGetEnv (WXSTRINGCAST envVariable
, &val
))
186 wxChar
*s
= MYcopystring (val
);
187 wxChar
*save_ptr
, *token
= wxStrtok (s
, PATH_TOKS
, &save_ptr
);
194 if ( (token
= wxStrtok ((wxChar
*) NULL
, PATH_TOKS
, &save_ptr
))
202 // suppress warning about unused variable save_ptr when wxStrtok() is a
203 // macro which throws away its third argument
208 #endif // !__WXWINCE__
211 // Given a full filename (with path), ensure that that file can
212 // be accessed again USING FILENAME ONLY by adding the path
213 // to the list if not already there.
214 void wxPathList::EnsureFileAccessible (const wxString
& path
)
216 wxString
path_only(wxPathOnly(path
));
217 if ( !path_only
.empty() )
219 if ( !Member(path_only
) )
224 bool wxPathList::Member (const wxString
& path
)
226 for (wxStringList::compatibility_iterator node
= GetFirst(); node
; node
= node
->GetNext())
228 wxString
path2( node
->GetData() );
230 #if defined(__WINDOWS__) || defined(__OS2__) || defined(__VMS__) || defined(__WXMAC__)
232 path
.CompareTo (path2
, wxString::ignoreCase
) == 0
234 // Case sensitive File System
235 path
.CompareTo (path2
) == 0
243 wxString
wxPathList::FindValidPath (const wxString
& file
)
245 if (wxFileExists (wxExpandPath(wxFileFunctionsBuffer
, file
)))
246 return wxString(wxFileFunctionsBuffer
);
248 wxChar buf
[_MAXPATHLEN
];
249 wxStrcpy(buf
, wxFileFunctionsBuffer
);
251 wxChar
*filename
= wxIsAbsolutePath (buf
) ? wxFileNameFromPath (buf
) : (wxChar
*)buf
;
253 for (wxStringList::compatibility_iterator node
= GetFirst(); node
; node
= node
->GetNext())
255 const wxChar
*path
= node
->GetData();
256 wxStrcpy (wxFileFunctionsBuffer
, path
);
257 wxChar ch
= wxFileFunctionsBuffer
[wxStrlen(wxFileFunctionsBuffer
)-1];
258 if (ch
!= wxT('\\') && ch
!= wxT('/'))
259 wxStrcat (wxFileFunctionsBuffer
, wxT("/"));
260 wxStrcat (wxFileFunctionsBuffer
, filename
);
262 wxUnix2DosFilename (wxFileFunctionsBuffer
);
264 if (wxFileExists (wxFileFunctionsBuffer
))
266 return wxString(wxFileFunctionsBuffer
); // Found!
270 return wxEmptyString
; // Not found
273 wxString
wxPathList::FindAbsoluteValidPath (const wxString
& file
)
275 wxString f
= FindValidPath(file
);
276 if ( f
.empty() || wxIsAbsolutePath(f
) )
279 wxString buf
= ::wxGetCwd();
281 if ( !wxEndsWithPathSeparator(buf
) )
283 buf
+= wxFILE_SEP_PATH
;
291 wxFileExists (const wxString
& filename
)
293 #if defined(__WXPALMOS__)
295 #elif defined(__WIN32__) && !defined(__WXMICROWIN__)
296 // we must use GetFileAttributes() instead of the ANSI C functions because
297 // it can cope with network (UNC) paths unlike them
298 DWORD ret
= ::GetFileAttributes(filename
);
300 return (ret
!= (DWORD
)-1) && !(ret
& FILE_ATTRIBUTE_DIRECTORY
);
303 #ifndef wxNEED_WX_UNISTD_H
304 return (wxStat( filename
.fn_str() , &st
) == 0 && (st
.st_mode
& S_IFREG
))
306 || (errno
== EACCES
) // if access is denied something with that name
307 // exists and is opened in exclusive mode.
311 return wxStat( filename
, &st
) == 0 && (st
.st_mode
& S_IFREG
);
313 #endif // __WIN32__/!__WIN32__
317 wxIsAbsolutePath (const wxString
& filename
)
319 if (!filename
.empty())
321 #if defined(__WXMAC__) && !defined(__DARWIN__)
322 // Classic or Carbon CodeWarrior like
323 // Carbon with Apple DevTools is Unix like
325 // This seems wrong to me, but there is no fix. since
326 // "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
327 // is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
328 if (filename
.Find(':') != wxNOT_FOUND
&& filename
[0] != ':')
331 // Unix like or Windows
332 if (filename
[0] == wxT('/'))
336 if ((filename
[0] == wxT('[') && filename
[1] != wxT('.')))
339 #if defined(__WINDOWS__) || defined(__OS2__)
341 if (filename
[0] == wxT('\\') || (wxIsalpha (filename
[0]) && filename
[1] == wxT(':')))
349 * Strip off any extension (dot something) from end of file,
350 * IF one exists. Inserts zero into buffer.
354 void wxStripExtension(wxChar
*buffer
)
356 int len
= wxStrlen(buffer
);
360 if (buffer
[i
] == wxT('.'))
369 void wxStripExtension(wxString
& buffer
)
371 //RN: Be careful about the handling the case where
372 //buffer.length() == 0
373 for(size_t i
= buffer
.length() - 1; i
!= wxString::npos
; --i
)
375 if (buffer
.GetChar(i
) == wxT('.'))
377 buffer
= buffer
.Left(i
);
383 // Destructive removal of /./ and /../ stuff
384 wxChar
*wxRealPath (wxChar
*path
)
387 static const wxChar SEP
= wxT('\\');
388 wxUnix2DosFilename(path
);
390 static const wxChar SEP
= wxT('/');
392 if (path
[0] && path
[1]) {
393 /* MATTHEW: special case "/./x" */
395 if (path
[2] == SEP
&& path
[1] == wxT('.'))
403 if (p
[1] == wxT('.') && p
[2] == wxT('.') && (p
[3] == SEP
|| p
[3] == wxT('\0')))
406 for (q
= p
- 1; q
>= path
&& *q
!= SEP
; q
--)
411 if (q
[0] == SEP
&& (q
[1] != wxT('.') || q
[2] != wxT('.') || q
[3] != SEP
)
412 && (q
- 1 <= path
|| q
[-1] != SEP
))
415 if (path
[0] == wxT('\0'))
420 #if defined(__WXMSW__) || defined(__OS2__)
421 /* Check that path[2] is NULL! */
422 else if (path
[1] == wxT(':') && !path
[2])
431 else if (p
[1] == wxT('.') && (p
[2] == SEP
|| p
[2] == wxT('\0')))
439 wxString
wxRealPath(const wxString
& path
)
441 wxChar
*buf1
=MYcopystring(path
);
442 wxChar
*buf2
=wxRealPath(buf1
);
450 wxChar
*wxCopyAbsolutePath(const wxString
& filename
)
452 if (filename
.empty())
453 return (wxChar
*) NULL
;
455 if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer
, filename
)))
457 wxString buf
= ::wxGetCwd();
458 wxChar ch
= buf
.Last();
460 if (ch
!= wxT('\\') && ch
!= wxT('/'))
466 buf
<< wxFileFunctionsBuffer
;
467 buf
= wxRealPath( buf
);
468 return MYcopystring( buf
);
470 return MYcopystring( wxFileFunctionsBuffer
);
476 ~user/ => user's home dir
477 If the environment variable a = "foo" and b = "bar" then:
494 /* input name in name, pathname output to buf. */
496 wxChar
*wxExpandPath(wxChar
*buf
, const wxChar
*name
)
498 register wxChar
*d
, *s
, *nm
;
499 wxChar lnm
[_MAXPATHLEN
];
502 // Some compilers don't like this line.
503 // const wxChar trimchars[] = wxT("\n \t");
506 trimchars
[0] = wxT('\n');
507 trimchars
[1] = wxT(' ');
508 trimchars
[2] = wxT('\t');
512 const wxChar SEP
= wxT('\\');
514 const wxChar SEP
= wxT('/');
517 if (name
== NULL
|| *name
== wxT('\0'))
519 nm
= MYcopystring(name
); // Make a scratch copy
522 /* Skip leading whitespace and cr */
523 while (wxStrchr((wxChar
*)trimchars
, *nm
) != NULL
)
525 /* And strip off trailing whitespace and cr */
526 s
= nm
+ (q
= wxStrlen(nm
)) - 1;
527 while (q
-- && wxStrchr((wxChar
*)trimchars
, *s
) != NULL
)
535 q
= nm
[0] == wxT('\\') && nm
[1] == wxT('~');
538 /* Expand inline environment variables */
556 while ((*d
++ = *s
) != 0) {
558 if (*s
== wxT('\\')) {
559 if ((*(d
- 1) = *++s
)!=0) {
567 // No env variables on WinCE
570 if (*s
++ == wxT('$') && (*s
== wxT('{') || *s
== wxT(')')))
572 if (*s
++ == wxT('$'))
575 register wxChar
*start
= d
;
576 register int braces
= (*s
== wxT('{') || *s
== wxT('('));
577 register wxChar
*value
;
578 while ((*d
++ = *s
) != 0)
579 if (braces
? (*s
== wxT('}') || *s
== wxT(')')) : !(wxIsalnum(*s
) || *s
== wxT('_')) )
584 value
= wxGetenv(braces
? start
+ 1 : start
);
586 for ((d
= start
- 1); (*d
++ = *value
++) != 0;)
600 /* Expand ~ and ~user */
602 if (nm
[0] == wxT('~') && !q
)
605 if (nm
[1] == SEP
|| nm
[1] == 0)
607 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
608 if ((s
= WXSTRINGCAST
wxGetUserHome(wxEmptyString
)) != NULL
) {
613 { /* ~user/filename */
614 register wxChar
*nnm
;
615 register wxChar
*home
;
616 for (s
= nm
; *s
&& *s
!= SEP
; s
++)
620 int was_sep
; /* MATTHEW: Was there a separator, or NULL? */
621 was_sep
= (*s
== SEP
);
622 nnm
= *s
? s
+ 1 : s
;
624 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
625 if ((home
= WXSTRINGCAST
wxGetUserHome(wxString(nm
+ 1))) == NULL
)
627 if (was_sep
) /* replace only if it was there: */
640 if (s
&& *s
) { /* MATTHEW: s could be NULL if user '~' didn't exist */
642 while (wxT('\0') != (*d
++ = *s
++))
645 if (d
- 1 > buf
&& *(d
- 2) != SEP
)
649 while ((*d
++ = *s
++) != 0)
653 delete[] nm_tmp
; // clean up alloc
654 /* Now clean up the buffer */
655 return wxRealPath(buf
);
658 /* Contract Paths to be build upon an environment variable
661 example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib
663 The call wxExpandPath can convert these back!
666 wxContractPath (const wxString
& filename
,
667 const wxString
& WXUNUSED_IN_WINCE(envname
),
668 const wxString
& user
)
670 static wxChar dest
[_MAXPATHLEN
];
672 if (filename
.empty())
673 return (wxChar
*) NULL
;
675 wxStrcpy (dest
, WXSTRINGCAST filename
);
677 wxUnix2DosFilename(dest
);
680 // Handle environment
684 if (!envname
.empty() && (val
= wxGetenv (WXSTRINGCAST envname
)) != NULL
&&
685 (tcp
= wxStrstr (dest
, val
)) != NULL
)
687 wxStrcpy (wxFileFunctionsBuffer
, tcp
+ wxStrlen (val
));
690 wxStrcpy (tcp
, WXSTRINGCAST envname
);
691 wxStrcat (tcp
, wxT("}"));
692 wxStrcat (tcp
, wxFileFunctionsBuffer
);
696 // Handle User's home (ignore root homes!)
697 val
= wxGetUserHome (user
);
701 const size_t len
= wxStrlen(val
);
705 if (wxStrncmp(dest
, val
, len
) == 0)
707 wxStrcpy(wxFileFunctionsBuffer
, wxT("~"));
709 wxStrcat(wxFileFunctionsBuffer
, (const wxChar
*) user
);
710 wxStrcat(wxFileFunctionsBuffer
, dest
+ len
);
711 wxStrcpy (dest
, wxFileFunctionsBuffer
);
717 // Return just the filename, not the path (basename)
718 wxChar
*wxFileNameFromPath (wxChar
*path
)
721 wxString n
= wxFileNameFromPath(p
);
723 return path
+ p
.length() - n
.length();
726 wxString
wxFileNameFromPath (const wxString
& path
)
729 wxFileName::SplitPath(path
, NULL
, &name
, &ext
);
731 wxString fullname
= name
;
734 fullname
<< wxFILE_SEP_EXT
<< ext
;
740 // Return just the directory, or NULL if no directory
742 wxPathOnly (wxChar
*path
)
746 static wxChar buf
[_MAXPATHLEN
];
749 wxStrcpy (buf
, path
);
751 int l
= wxStrlen(path
);
754 // Search backward for a backward or forward slash
757 #if defined(__WXMAC__) && !defined(__DARWIN__)
758 // Classic or Carbon CodeWarrior like
759 // Carbon with Apple DevTools is Unix like
760 if (path
[i
] == wxT(':') )
766 // Unix like or Windows
767 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
774 if (path
[i
] == wxT(']'))
783 #if defined(__WXMSW__) || defined(__OS2__)
784 // Try Drive specifier
785 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
787 // A:junk --> A:. (since A:.\junk Not A:\junk)
794 return (wxChar
*) NULL
;
797 // Return just the directory, or NULL if no directory
798 wxString
wxPathOnly (const wxString
& path
)
802 wxChar buf
[_MAXPATHLEN
];
805 wxStrcpy (buf
, WXSTRINGCAST path
);
807 int l
= path
.length();
810 // Search backward for a backward or forward slash
813 #if defined(__WXMAC__) && !defined(__DARWIN__)
814 // Classic or Carbon CodeWarrior like
815 // Carbon with Apple DevTools is Unix like
816 if (path
[i
] == wxT(':') )
819 return wxString(buf
);
822 // Unix like or Windows
823 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
825 // Don't return an empty string
829 return wxString(buf
);
833 if (path
[i
] == wxT(']'))
836 return wxString(buf
);
842 #if defined(__WXMSW__) || defined(__OS2__)
843 // Try Drive specifier
844 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
846 // A:junk --> A:. (since A:.\junk Not A:\junk)
849 return wxString(buf
);
853 return wxEmptyString
;
856 // Utility for converting delimiters in DOS filenames to UNIX style
857 // and back again - or we get nasty problems with delimiters.
858 // Also, convert to lower case, since case is significant in UNIX.
860 #if defined(__WXMAC__)
862 #if TARGET_API_MAC_OSX
863 #define kDefaultPathStyle kCFURLPOSIXPathStyle
865 #define kDefaultPathStyle kCFURLHFSPathStyle
868 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
)
871 fullURLRef
= CFURLCreateFromFSRef(NULL
, fsRef
);
872 if ( additionalPathComponent
)
874 CFURLRef parentURLRef
= fullURLRef
;
875 fullURLRef
= CFURLCreateCopyAppendingPathComponent(NULL
, parentURLRef
,
876 additionalPathComponent
,false);
877 CFRelease( parentURLRef
) ;
879 CFStringRef cfString
= CFURLCopyFileSystemPath(fullURLRef
, kDefaultPathStyle
);
880 CFRelease( fullURLRef
) ;
881 return wxMacCFStringHolder(cfString
).AsString(wxLocale::GetSystemEncoding());
884 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
)
886 OSStatus err
= noErr
;
887 CFURLRef url
= CFURLCreateWithFileSystemPath(kCFAllocatorDefault
, wxMacCFStringHolder(path
,wxLocale::GetSystemEncoding() ) , kDefaultPathStyle
, false);
890 if ( CFURLGetFSRef(url
, fsRef
) == false )
901 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
)
903 CFStringRef cfname
= CFStringCreateWithCharacters( kCFAllocatorDefault
,
906 return wxMacCFStringHolder(cfname
).AsString() ;
909 wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
)
912 if ( FSpMakeFSRef( spec
, &fsRef
) == noErr
)
914 return wxMacFSRefToPath( &fsRef
) ;
916 return wxEmptyString
;
919 void wxMacFilename2FSSpec( const wxString
& path
, FSSpec
*spec
)
921 OSStatus err
= noErr
;
923 wxMacPathToFSRef( path
, &fsRef
) ;
924 err
= FSRefMakeFSSpec( &fsRef
, spec
) ;
930 wxDos2UnixFilename (wxChar
*s
)
939 *s
= (wxChar
)wxTolower (*s
); // Case INDEPENDENT
946 #if defined(__WXMSW__) || defined(__OS2__)
947 wxUnix2DosFilename (wxChar
*s
)
949 wxUnix2DosFilename (wxChar
*WXUNUSED(s
) )
952 // Yes, I really mean this to happen under DOS only! JACS
953 #if defined(__WXMSW__) || defined(__OS2__)
964 // Concatenate two files to form third
966 wxConcatFiles (const wxString
& file1
, const wxString
& file2
, const wxString
& file3
)
970 wxFile
in1(file1
), in2(file2
);
971 wxTempFile
out(file3
);
973 if ( !in1
.IsOpened() || !in2
.IsOpened() || !out
.IsOpened() )
977 unsigned char buf
[1024];
979 for( int i
=0; i
<2; i
++)
981 wxFile
*in
= i
==0 ? &in1
: &in2
;
983 if ( (ofs
= in
->Read(buf
,WXSIZEOF(buf
))) == wxInvalidOffset
) return false;
985 if ( !out
.Write(buf
,ofs
) )
987 } while ( ofs
== (ssize_t
)WXSIZEOF(buf
) );
1004 wxCopyFile (const wxString
& file1
, const wxString
& file2
, bool overwrite
)
1006 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
1007 // CopyFile() copies file attributes and modification time too, so use it
1008 // instead of our code if available
1010 // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
1011 if ( !::CopyFile(file1
, file2
, !overwrite
) )
1013 wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
1014 file1
.c_str(), file2
.c_str());
1018 #elif defined(__OS2__)
1019 if ( ::DosCopy((PSZ
)file1
.c_str(), (PSZ
)file2
.c_str(), overwrite
? DCPY_EXISTING
: 0) != 0 )
1021 #elif defined(__PALMOS__)
1022 // TODO with http://www.palmos.com/dev/support/docs/protein_books/Memory_Databases_Files/
1024 #elif wxUSE_FILE // !Win32
1027 // get permissions of file1
1028 if ( wxStat( file1
.c_str(), &fbuf
) != 0 )
1030 // the file probably doesn't exist or we haven't the rights to read
1032 wxLogSysError(_("Impossible to get permissions for file '%s'"),
1037 // open file1 for reading
1038 wxFile
fileIn(file1
, wxFile::read
);
1039 if ( !fileIn
.IsOpened() )
1042 // remove file2, if it exists. This is needed for creating
1043 // file2 with the correct permissions in the next step
1044 if ( wxFileExists(file2
) && (!overwrite
|| !wxRemoveFile(file2
)))
1046 wxLogSysError(_("Impossible to overwrite the file '%s'"),
1051 // reset the umask as we want to create the file with exactly the same
1052 // permissions as the original one
1055 // create file2 with the same permissions than file1 and open it for
1059 if ( !fileOut
.Create(file2
, overwrite
, fbuf
.st_mode
& 0777) )
1062 // copy contents of file1 to file2
1067 count
= fileIn
.Read(buf
, WXSIZEOF(buf
));
1068 if ( fileIn
.Error() )
1075 if ( fileOut
.Write(buf
, count
) < count
)
1079 // we can expect fileIn to be closed successfully, but we should ensure
1080 // that fileOut was closed as some write errors (disk full) might not be
1081 // detected before doing this
1082 if ( !fileIn
.Close() || !fileOut
.Close() )
1085 #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
1086 // no chmod in VA. Should be some permission API for HPFS386 partitions
1088 if ( chmod(OS_FILENAME(file2
), fbuf
.st_mode
) != 0 )
1090 wxLogSysError(_("Impossible to set permissions for the file '%s'"),
1094 #endif // OS/2 || Mac
1096 #else // !Win32 && ! wxUSE_FILE
1098 // impossible to simulate with wxWidgets API
1101 wxUnusedVar(overwrite
);
1104 #endif // __WXMSW__ && __WIN32__
1110 wxRenameFile (const wxString
& file1
, const wxString
& file2
)
1112 #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
1113 // Normal system call
1114 if ( wxRename (file1
, file2
) == 0 )
1119 if (wxCopyFile(file1
, file2
)) {
1120 wxRemoveFile(file1
);
1127 bool wxRemoveFile(const wxString
& file
)
1129 #if defined(__VISUALC__) \
1130 || defined(__BORLANDC__) \
1131 || defined(__WATCOMC__) \
1132 || defined(__DMC__) \
1133 || defined(__GNUWIN32__) \
1134 || (defined(__MWERKS__) && defined(__MSL__))
1135 int res
= wxRemove(file
);
1136 #elif defined(__WXMAC__)
1137 int res
= unlink(wxFNCONV(file
));
1138 #elif defined(__WXPALMOS__)
1140 // TODO with VFSFileDelete()
1142 int res
= unlink(OS_FILENAME(file
));
1148 bool wxMkdir(const wxString
& dir
, int perm
)
1150 #if defined(__WXPALMOS__)
1152 #elif defined(__WXMAC__) && !defined(__UNIX__)
1153 return (mkdir( wxFNCONV(dir
) , 0 ) == 0);
1155 const wxChar
*dirname
= dir
.c_str();
1157 // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
1158 // for the GNU compiler
1159 #if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
1162 if ( mkdir(wxFNCONV(dirname
)) != 0 )
1164 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1166 #elif defined(__OS2__)
1168 if (::DosCreateDir((PSZ
)dirname
, NULL
) != 0) // enhance for EAB's??
1169 #elif defined(__DOS__)
1170 #if defined(__WATCOMC__)
1172 if ( wxMkDir(wxFNSTRINGCAST
wxFNCONV(dirname
)) != 0 )
1173 #elif defined(__DJGPP__)
1174 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1176 #error "Unsupported DOS compiler!"
1178 #else // !MSW, !DOS and !OS/2 VAC++
1181 if ( !CreateDirectory(dirname
, NULL
) )
1183 if ( wxMkDir(dir
.fn_str()) != 0 )
1187 wxLogSysError(_("Directory '%s' couldn't be created"), dirname
);
1196 bool wxRmdir(const wxString
& dir
, int WXUNUSED(flags
))
1198 #if defined(__VMS__)
1199 return false; //to be changed since rmdir exists in VMS7.x
1200 #elif defined(__OS2__)
1201 return (::DosDeleteDir((PSZ
)dir
.c_str()) == 0);
1202 #elif defined(__WXWINCE__)
1203 return (CreateDirectory(dir
, NULL
) != 0);
1204 #elif defined(__WXPALMOS__)
1205 // TODO with VFSFileRename()
1208 return (wxRmDir(OS_FILENAME(dir
)) == 0);
1212 // does the path exists? (may have or not '/' or '\\' at the end)
1213 bool wxDirExists(const wxChar
*pszPathName
)
1215 wxString
strPath(pszPathName
);
1217 #if defined(__WINDOWS__) || defined(__OS2__)
1218 // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
1219 // so remove all trailing backslashes from the path - but don't do this for
1220 // the pathes "d:\" (which are different from "d:") nor for just "\"
1221 while ( wxEndsWithPathSeparator(strPath
) )
1223 size_t len
= strPath
.length();
1224 if ( len
== 1 || (len
== 3 && strPath
[len
- 2] == _T(':')) )
1227 strPath
.Truncate(len
- 1);
1229 #endif // __WINDOWS__
1232 // OS/2 can't handle "d:", it wants either "d:\" or "d:."
1233 if (strPath
.length() == 2 && strPath
[1u] == _T(':'))
1237 #if defined(__WXPALMOS__)
1239 #elif defined(__WIN32__) && !defined(__WXMICROWIN__)
1240 // stat() can't cope with network paths
1241 DWORD ret
= ::GetFileAttributes(strPath
);
1243 return (ret
!= (DWORD
)-1) && (ret
& FILE_ATTRIBUTE_DIRECTORY
);
1244 #elif defined(__OS2__)
1245 FILESTATUS3 Info
= {{0}};
1246 APIRET rc
= ::DosQueryPathInfo((PSZ
)(WXSTRINGCAST strPath
), FIL_STANDARD
,
1247 (void*) &Info
, sizeof(FILESTATUS3
));
1249 return ((rc
== NO_ERROR
) && (Info
.attrFile
& FILE_DIRECTORY
)) ||
1250 (rc
== ERROR_SHARING_VIOLATION
);
1251 // If we got a sharing violation, there must be something with this name.
1255 #ifndef __VISAGECPP__
1256 return wxStat(strPath
.c_str(), &st
) == 0 && ((st
.st_mode
& S_IFMT
) == S_IFDIR
);
1258 // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
1259 return wxStat(pszPathName
, &st
) == 0 && (st
.st_mode
== S_IFDIR
);
1262 #endif // __WIN32__/!__WIN32__
1265 // Get a temporary filename, opening and closing the file.
1266 wxChar
*wxGetTempFileName(const wxString
& prefix
, wxChar
*buf
)
1269 wxString filename
= wxFileName::CreateTempFileName(prefix
);
1270 if ( filename
.empty() )
1274 wxStrcpy(buf
, filename
);
1276 buf
= MYcopystring(filename
);
1280 wxUnusedVar(prefix
);
1282 // wxFileName::CreateTempFileName needs wxFile class enabled
1287 bool wxGetTempFileName(const wxString
& prefix
, wxString
& buf
)
1289 buf
= wxGetTempFileName(prefix
);
1291 return !buf
.empty();
1294 // Get first file name matching given wild card.
1296 static wxDir
*gs_dir
= NULL
;
1297 static wxString gs_dirPath
;
1299 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1301 wxSplitPath(spec
, &gs_dirPath
, NULL
, NULL
);
1302 if ( gs_dirPath
.empty() )
1303 gs_dirPath
= wxT(".");
1304 if ( !wxEndsWithPathSeparator(gs_dirPath
) )
1305 gs_dirPath
<< wxFILE_SEP_PATH
;
1309 gs_dir
= new wxDir(gs_dirPath
);
1311 if ( !gs_dir
->IsOpened() )
1313 wxLogSysError(_("Can not enumerate files '%s'"), spec
);
1314 return wxEmptyString
;
1320 case wxDIR
: dirFlags
= wxDIR_DIRS
; break;
1321 case wxFILE
: dirFlags
= wxDIR_FILES
; break;
1322 default: dirFlags
= wxDIR_DIRS
| wxDIR_FILES
; break;
1326 gs_dir
->GetFirst(&result
, wxFileNameFromPath(wxString(spec
)), dirFlags
);
1327 if ( result
.empty() )
1333 return gs_dirPath
+ result
;
1336 wxString
wxFindNextFile()
1338 wxASSERT_MSG( gs_dir
, wxT("You must call wxFindFirstFile before!") );
1341 gs_dir
->GetNext(&result
);
1343 if ( result
.empty() )
1349 return gs_dirPath
+ result
;
1353 // Get current working directory.
1354 // If buf is NULL, allocates space using new, else copies into buf.
1355 // wxGetWorkingDirectory() is obsolete, use wxGetCwd()
1356 // wxDoGetCwd() is their common core to be moved
1357 // to wxGetCwd() once wxGetWorkingDirectory() will be removed.
1358 // Do not expose wxDoGetCwd in headers!
1360 wxChar
*wxDoGetCwd(wxChar
*buf
, int sz
)
1362 #if defined(__WXPALMOS__)
1364 if(buf
&& sz
>0) buf
[0] = _T('\0');
1366 #elif defined(__WXWINCE__)
1368 if(buf
&& sz
>0) buf
[0] = _T('\0');
1373 buf
= new wxChar
[sz
+ 1];
1376 bool ok
wxDUMMY_INITIALIZE(false);
1378 // for the compilers which have Unicode version of _getcwd(), call it
1379 // directly, for the others call the ANSI version and do the translation
1382 #else // wxUSE_UNICODE
1383 bool needsANSI
= true;
1385 #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
1386 char cbuf
[_MAXPATHLEN
];
1390 #if wxUSE_UNICODE_MSLU
1391 if ( wxGetOsVersion() != wxWIN95
)
1393 char *cbuf
= NULL
; // never really used because needsANSI will always be false
1396 ok
= _wgetcwd(buf
, sz
) != NULL
;
1402 #endif // wxUSE_UNICODE
1404 #if defined(_MSC_VER) || defined(__MINGW32__)
1405 ok
= _getcwd(cbuf
, sz
) != NULL
;
1406 #elif defined(__WXMAC__) && !defined(__DARWIN__)
1408 if ( getcwd( lbuf
, sizeof( lbuf
) ) )
1410 wxString
res( lbuf
, *wxConvCurrent
) ;
1411 wxStrcpy( buf
, res
) ;
1416 #elif defined(__OS2__)
1418 ULONG ulDriveNum
= 0;
1419 ULONG ulDriveMap
= 0;
1420 rc
= ::DosQueryCurrentDisk(&ulDriveNum
, &ulDriveMap
);
1425 rc
= ::DosQueryCurrentDir( 0 // current drive
1429 cbuf
[0] = char('A' + (ulDriveNum
- 1));
1434 #else // !Win32/VC++ !Mac !OS2
1435 ok
= getcwd(cbuf
, sz
) != NULL
;
1438 #if wxUSE_UNICODE && !(defined(__WXMAC__) && !defined(__DARWIN__))
1439 // finally convert the result to Unicode if needed
1440 wxConvFile
.MB2WC(buf
, cbuf
, sz
);
1441 #endif // wxUSE_UNICODE
1446 wxLogSysError(_("Failed to get the working directory"));
1448 // VZ: the old code used to return "." on error which didn't make any
1449 // sense at all to me - empty string is a better error indicator
1450 // (NULL might be even better but I'm afraid this could lead to
1451 // problems with the old code assuming the return is never NULL)
1454 else // ok, but we might need to massage the path into the right format
1457 // VS: DJGPP is a strange mix of DOS and UNIX API and returns paths
1458 // with / deliminers. We don't like that.
1459 for (wxChar
*ch
= buf
; *ch
; ch
++)
1461 if (*ch
== wxT('/'))
1466 // MBN: we hope that in the case the user is compiling a GTK+/Motif app,
1467 // he needs Unix as opposed to Win32 pathnames
1468 #if defined( __CYGWIN__ ) && defined( __WINDOWS__ )
1469 // another example of DOS/Unix mix (Cygwin)
1470 wxString pathUnix
= buf
;
1472 char bufA
[_MAXPATHLEN
];
1473 cygwin_conv_to_full_win32_path(pathUnix
.mb_str(wxConvFile
), bufA
);
1474 wxConvFile
.MB2WC(buf
, bufA
, sz
);
1476 cygwin_conv_to_full_win32_path(pathUnix
, buf
);
1477 #endif // wxUSE_UNICODE
1478 #endif // __CYGWIN__
1491 #if WXWIN_COMPATIBILITY_2_6
1492 wxChar
*wxGetWorkingDirectory(wxChar
*buf
, int sz
)
1494 return wxDoGetCwd(buf
,sz
);
1496 #endif // WXWIN_COMPATIBILITY_2_6
1501 wxDoGetCwd(wxStringBuffer(str
, _MAXPATHLEN
), _MAXPATHLEN
);
1505 bool wxSetWorkingDirectory(const wxString
& d
)
1507 #if defined(__OS2__)
1508 return (::DosSetCurrentDir((PSZ
)d
.c_str()) == 0);
1509 #elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
1510 return (chdir(wxFNSTRINGCAST d
.fn_str()) == 0);
1511 #elif defined(__WINDOWS__)
1515 // No equivalent in WinCE
1519 return (bool)(SetCurrentDirectory(d
) != 0);
1522 // Must change drive, too.
1523 bool isDriveSpec
= ((strlen(d
) > 1) && (d
[1] == ':'));
1526 wxChar firstChar
= d
[0];
1530 firstChar
= firstChar
- 32;
1532 // To a drive number
1533 unsigned int driveNo
= firstChar
- 64;
1536 unsigned int noDrives
;
1537 _dos_setdrive(driveNo
, &noDrives
);
1540 bool success
= (chdir(WXSTRINGCAST d
) == 0);
1548 // Get the OS directory if appropriate (such as the Windows directory).
1549 // On non-Windows platform, probably just return the empty string.
1550 wxString
wxGetOSDirectory()
1553 return wxString(wxT("\\Windows"));
1554 #elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
1556 GetWindowsDirectory(buf
, 256);
1557 return wxString(buf
);
1558 #elif defined(__WXMAC__)
1559 return wxMacFindFolder(kOnSystemDisk
, 'macs', false);
1561 return wxEmptyString
;
1565 bool wxEndsWithPathSeparator(const wxChar
*pszFileName
)
1567 size_t len
= wxStrlen(pszFileName
);
1569 return len
&& wxIsPathSeparator(pszFileName
[len
- 1]);
1572 // find a file in a list of directories, returns false if not found
1573 bool wxFindFileInPath(wxString
*pStr
, const wxChar
*pszPath
, const wxChar
*pszFile
)
1575 // we assume that it's not empty
1576 wxCHECK_MSG( !wxIsEmpty(pszFile
), false,
1577 _T("empty file name in wxFindFileInPath"));
1579 // skip path separator in the beginning of the file name if present
1580 if ( wxIsPathSeparator(*pszFile
) )
1583 // copy the path (strtok will modify it)
1584 wxChar
*szPath
= new wxChar
[wxStrlen(pszPath
) + 1];
1585 wxStrcpy(szPath
, pszPath
);
1588 wxChar
*pc
, *save_ptr
;
1589 for ( pc
= wxStrtok(szPath
, wxPATH_SEP
, &save_ptr
);
1591 pc
= wxStrtok((wxChar
*) NULL
, wxPATH_SEP
, &save_ptr
) )
1593 // search for the file in this directory
1595 if ( !wxEndsWithPathSeparator(pc
) )
1596 strFile
+= wxFILE_SEP_PATH
;
1599 if ( wxFileExists(strFile
) ) {
1605 // suppress warning about unused variable save_ptr when wxStrtok() is a
1606 // macro which throws away its third argument
1611 return pc
!= NULL
; // if true => we breaked from the loop
1614 void WXDLLEXPORT
wxSplitPath(const wxChar
*pszFileName
,
1619 // it can be empty, but it shouldn't be NULL
1620 wxCHECK_RET( pszFileName
, wxT("NULL file name in wxSplitPath") );
1622 wxFileName::SplitPath(pszFileName
, pstrPath
, pstrName
, pstrExt
);
1625 time_t WXDLLEXPORT
wxFileModificationTime(const wxString
& filename
)
1627 #if defined(__WXPALMOS__)
1629 #elif defined(__WXWINCE__)
1630 FILETIME ftLastWrite
;
1631 AutoHANDLE
hFile(::CreateFile(filename
, GENERIC_READ
, FILE_SHARE_READ
,
1632 NULL
, 0, FILE_ATTRIBUTE_NORMAL
, 0));
1634 if ( !hFile
.IsOk() )
1637 if ( !::GetFileTime(hFile
, NULL
, NULL
, &ftLastWrite
) )
1640 // sure we want to translate to local time here?
1642 if ( !::FileTimeToLocalFileTime(&ftLastWrite
, &ftLocal
) )
1644 wxLogLastError(_T("FileTimeToLocalFileTime"));
1647 // FILETIME is a counted in 100-ns since 1601-01-01, convert it to
1648 // number of seconds since 1970-01-01
1650 uli
.LowPart
= ftLocal
.dwLowDateTime
;
1651 uli
.HighPart
= ftLocal
.dwHighDateTime
;
1653 ULONGLONG ull
= uli
.QuadPart
;
1654 ull
/= wxULL(10000000); // number of 100ns intervals in 1s
1655 ull
-= wxULL(11644473600); // 1970-01-01 - 1601-01-01 in seconds
1657 return wx_static_cast(time_t, ull
);
1660 if ( wxStat( filename
, &buf
) != 0 )
1663 return buf
.st_mtime
;
1668 // Parses the filterStr, returning the number of filters.
1669 // Returns 0 if none or if there's a problem.
1670 // filterStr is in the form: "All files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpeg"
1672 int WXDLLEXPORT
wxParseCommonDialogsFilter(const wxString
& filterStr
,
1673 wxArrayString
& descriptions
,
1674 wxArrayString
& filters
)
1676 descriptions
.Clear();
1679 wxString
str(filterStr
);
1681 wxString description
, filter
;
1683 while( pos
!= wxNOT_FOUND
)
1685 pos
= str
.Find(wxT('|'));
1686 if ( pos
== wxNOT_FOUND
)
1688 // if there are no '|'s at all in the string just take the entire
1689 // string as filter and make description empty for later autocompletion
1690 if ( filters
.IsEmpty() )
1692 descriptions
.Add(wxEmptyString
);
1693 filters
.Add(filterStr
);
1697 wxFAIL_MSG( _T("missing '|' in the wildcard string!") );
1703 description
= str
.Left(pos
);
1704 str
= str
.Mid(pos
+ 1);
1705 pos
= str
.Find(wxT('|'));
1706 if ( pos
== wxNOT_FOUND
)
1712 filter
= str
.Left(pos
);
1713 str
= str
.Mid(pos
+ 1);
1716 descriptions
.Add(description
);
1717 filters
.Add(filter
);
1720 #if defined(__WXMOTIF__)
1721 // split it so there is one wildcard per entry
1722 for( size_t i
= 0 ; i
< descriptions
.GetCount() ; i
++ )
1724 pos
= filters
[i
].Find(wxT(';'));
1725 if (pos
!= wxNOT_FOUND
)
1727 // first split only filters
1728 descriptions
.Insert(descriptions
[i
],i
+1);
1729 filters
.Insert(filters
[i
].Mid(pos
+1),i
+1);
1730 filters
[i
]=filters
[i
].Left(pos
);
1732 // autoreplace new filter in description with pattern:
1733 // C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
1734 // cause split into:
1735 // C/C++ Files(*.cpp)|*.cpp
1736 // C/C++ Files(*.c;*.h)|*.c;*.h
1737 // and next iteration cause another split into:
1738 // C/C++ Files(*.cpp)|*.cpp
1739 // C/C++ Files(*.c)|*.c
1740 // C/C++ Files(*.h)|*.h
1741 for ( size_t k
=i
;k
<i
+2;k
++ )
1743 pos
= descriptions
[k
].Find(filters
[k
]);
1744 if (pos
!= wxNOT_FOUND
)
1746 wxString before
= descriptions
[k
].Left(pos
);
1747 wxString after
= descriptions
[k
].Mid(pos
+filters
[k
].Len());
1748 pos
= before
.Find(_T('('),true);
1749 if (pos
>before
.Find(_T(')'),true))
1751 before
= before
.Left(pos
+1);
1752 before
<< filters
[k
];
1753 pos
= after
.Find(_T(')'));
1754 int pos1
= after
.Find(_T('('));
1755 if (pos
!= wxNOT_FOUND
&& (pos
<pos1
|| pos1
==wxNOT_FOUND
))
1757 before
<< after
.Mid(pos
);
1758 descriptions
[k
] = before
;
1768 for( size_t j
= 0 ; j
< descriptions
.GetCount() ; j
++ )
1770 if ( descriptions
[j
].empty() && !filters
[j
].empty() )
1772 descriptions
[j
].Printf(_("Files (%s)"), filters
[j
].c_str());
1776 return filters
.GetCount();
1780 //------------------------------------------------------------------------
1781 // wild character routines
1782 //------------------------------------------------------------------------
1784 bool wxIsWild( const wxString
& pattern
)
1786 wxString tmp
= pattern
;
1787 wxChar
*pat
= WXSTRINGCAST(tmp
);
1792 case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
1803 * Written By Douglas A. Lewis <dalewis@cs.Buffalo.EDU>
1805 * The match procedure is public domain code (from ircII's reg.c)
1808 bool wxMatchWild( const wxString
& pat
, const wxString
& text
, bool dot_special
)
1812 /* Match if both are empty. */
1816 const wxChar
*m
= pat
.c_str(),
1827 if (dot_special
&& (*n
== wxT('.')))
1829 /* Never match so that hidden Unix files
1830 * are never found. */
1844 else if (*m
== wxT('?'))
1852 if (*m
== wxT('\\'))
1855 /* Quoting "nothing" is a bad thing */
1862 * If we are out of both strings or we just
1863 * saw a wildcard, then we can say we have a
1874 * We could check for *n == NULL at this point, but
1875 * since it's more common to have a character there,
1876 * check to see if they match first (m and n) and
1877 * then if they don't match, THEN we can check for
1895 * If there are no more characters in the
1896 * string, but we still need to find another
1897 * character (*m != NULL), then it will be
1898 * impossible to match it
1905 if (*np
== wxT(' '))
1929 // Return the type of an open file
1931 // Some file types on some platforms seem seekable but in fact are not.
1932 // The main use of this function is to allow such cases to be detected
1933 // (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
1935 // This is important for the archive streams, which benefit greatly from
1936 // being able to seek on a stream, but which will produce corrupt archives
1937 // if they unknowingly seek on a non-seekable stream.
1939 // wxFILE_KIND_DISK is a good catch all return value, since other values
1940 // disable features of the archive streams. Some other value must be returned
1941 // for a file type that appears seekable but isn't.
1944 // * Pipes on Windows
1945 // * Files on VMS with a record format other than StreamLF
1947 wxFileKind
wxGetFileKind(int fd
)
1949 #if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
1950 switch (::GetFileType(wxGetOSFHandle(fd
)) & ~FILE_TYPE_REMOTE
)
1952 case FILE_TYPE_CHAR
:
1953 return wxFILE_KIND_TERMINAL
;
1954 case FILE_TYPE_DISK
:
1955 return wxFILE_KIND_DISK
;
1956 case FILE_TYPE_PIPE
:
1957 return wxFILE_KIND_PIPE
;
1960 return wxFILE_KIND_UNKNOWN
;
1962 #elif defined(__UNIX__)
1964 return wxFILE_KIND_TERMINAL
;
1969 if (S_ISFIFO(st
.st_mode
))
1970 return wxFILE_KIND_PIPE
;
1971 if (!S_ISREG(st
.st_mode
))
1972 return wxFILE_KIND_UNKNOWN
;
1974 #if defined(__VMS__)
1975 if (st
.st_fab_rfm
!= FAB$C_STMLF
)
1976 return wxFILE_KIND_UNKNOWN
;
1979 return wxFILE_KIND_DISK
;
1982 #define wxFILEKIND_STUB
1984 return wxFILE_KIND_DISK
;
1988 wxFileKind
wxGetFileKind(FILE *fp
)
1990 // Note: The watcom rtl dll doesn't have fileno (the static lib does).
1991 // Should be fixed in version 1.4.
1992 #if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4)
1994 return wxFILE_KIND_DISK
;
1996 return fp
? wxGetFileKind(fileno(fp
)) : wxFILE_KIND_UNKNOWN
;
2001 #pragma warning(default:4706) // assignment within conditional expression