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 wxExpandPath(wxFileFunctionsBuffer
, file
);
247 wxChar buf
[_MAXPATHLEN
];
248 wxStrcpy(buf
, wxFileFunctionsBuffer
);
250 wxChar
*filename
= wxIsAbsolutePath (buf
) ? wxFileNameFromPath (buf
) : (wxChar
*)buf
;
252 for (wxStringList::compatibility_iterator node
= GetFirst(); node
; node
= node
->GetNext())
254 const wxString
path(node
->GetData());
255 wxStrcpy (wxFileFunctionsBuffer
, path
);
256 wxChar ch
= wxFileFunctionsBuffer
[wxStrlen(wxFileFunctionsBuffer
)-1];
257 if (ch
!= wxT('\\') && ch
!= wxT('/'))
258 wxStrcat (wxFileFunctionsBuffer
, wxT("/"));
259 wxStrcat (wxFileFunctionsBuffer
, filename
);
261 wxUnix2DosFilename (wxFileFunctionsBuffer
);
263 if (wxFileExists (wxFileFunctionsBuffer
))
265 return wxString(wxFileFunctionsBuffer
); // Found!
269 return wxEmptyString
; // Not found
272 wxString
wxPathList::FindAbsoluteValidPath (const wxString
& file
)
274 wxString f
= FindValidPath(file
);
275 if ( f
.empty() || wxIsAbsolutePath(f
) )
278 wxString buf
= ::wxGetCwd();
280 if ( !wxEndsWithPathSeparator(buf
) )
282 buf
+= wxFILE_SEP_PATH
;
290 wxFileExists (const wxString
& filename
)
292 #if defined(__WXPALMOS__)
294 #elif defined(__WIN32__) && !defined(__WXMICROWIN__)
295 // we must use GetFileAttributes() instead of the ANSI C functions because
296 // it can cope with network (UNC) paths unlike them
297 DWORD ret
= ::GetFileAttributes(filename
);
299 return (ret
!= (DWORD
)-1) && !(ret
& FILE_ATTRIBUTE_DIRECTORY
);
302 #ifndef wxNEED_WX_UNISTD_H
303 return (wxStat( filename
.fn_str() , &st
) == 0 && (st
.st_mode
& S_IFREG
))
305 || (errno
== EACCES
) // if access is denied something with that name
306 // exists and is opened in exclusive mode.
310 return wxStat( filename
, &st
) == 0 && (st
.st_mode
& S_IFREG
);
312 #endif // __WIN32__/!__WIN32__
316 wxIsAbsolutePath (const wxString
& filename
)
318 if (!filename
.empty())
320 #if defined(__WXMAC__) && !defined(__DARWIN__)
321 // Classic or Carbon CodeWarrior like
322 // Carbon with Apple DevTools is Unix like
324 // This seems wrong to me, but there is no fix. since
325 // "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
326 // is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
327 if (filename
.Find(':') != wxNOT_FOUND
&& filename
[0] != ':')
330 // Unix like or Windows
331 if (filename
[0] == wxT('/'))
335 if ((filename
[0] == wxT('[') && filename
[1] != wxT('.')))
338 #if defined(__WINDOWS__) || defined(__OS2__)
340 if (filename
[0] == wxT('\\') || (wxIsalpha (filename
[0]) && filename
[1] == wxT(':')))
348 * Strip off any extension (dot something) from end of file,
349 * IF one exists. Inserts zero into buffer.
353 void wxStripExtension(wxChar
*buffer
)
355 int len
= wxStrlen(buffer
);
359 if (buffer
[i
] == wxT('.'))
368 void wxStripExtension(wxString
& buffer
)
370 //RN: Be careful about the handling the case where
371 //buffer.length() == 0
372 for(size_t i
= buffer
.length() - 1; i
!= wxString::npos
; --i
)
374 if (buffer
.GetChar(i
) == wxT('.'))
376 buffer
= buffer
.Left(i
);
382 // Destructive removal of /./ and /../ stuff
383 wxChar
*wxRealPath (wxChar
*path
)
386 static const wxChar SEP
= wxT('\\');
387 wxUnix2DosFilename(path
);
389 static const wxChar SEP
= wxT('/');
391 if (path
[0] && path
[1]) {
392 /* MATTHEW: special case "/./x" */
394 if (path
[2] == SEP
&& path
[1] == wxT('.'))
402 if (p
[1] == wxT('.') && p
[2] == wxT('.') && (p
[3] == SEP
|| p
[3] == wxT('\0')))
405 for (q
= p
- 1; q
>= path
&& *q
!= SEP
; q
--)
410 if (q
[0] == SEP
&& (q
[1] != wxT('.') || q
[2] != wxT('.') || q
[3] != SEP
)
411 && (q
- 1 <= path
|| q
[-1] != SEP
))
414 if (path
[0] == wxT('\0'))
419 #if defined(__WXMSW__) || defined(__OS2__)
420 /* Check that path[2] is NULL! */
421 else if (path
[1] == wxT(':') && !path
[2])
430 else if (p
[1] == wxT('.') && (p
[2] == SEP
|| p
[2] == wxT('\0')))
438 wxString
wxRealPath(const wxString
& path
)
440 wxChar
*buf1
=MYcopystring(path
);
441 wxChar
*buf2
=wxRealPath(buf1
);
449 wxChar
*wxCopyAbsolutePath(const wxString
& filename
)
451 if (filename
.empty())
452 return (wxChar
*) NULL
;
454 if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer
, filename
)))
456 wxString buf
= ::wxGetCwd();
457 wxChar ch
= buf
.Last();
459 if (ch
!= wxT('\\') && ch
!= wxT('/'))
465 buf
<< wxFileFunctionsBuffer
;
466 buf
= wxRealPath( buf
);
467 return MYcopystring( buf
);
469 return MYcopystring( wxFileFunctionsBuffer
);
475 ~user/ => user's home dir
476 If the environment variable a = "foo" and b = "bar" then:
493 /* input name in name, pathname output to buf. */
495 wxChar
*wxExpandPath(wxChar
*buf
, const wxChar
*name
)
497 register wxChar
*d
, *s
, *nm
;
498 wxChar lnm
[_MAXPATHLEN
];
501 // Some compilers don't like this line.
502 // const wxChar trimchars[] = wxT("\n \t");
505 trimchars
[0] = wxT('\n');
506 trimchars
[1] = wxT(' ');
507 trimchars
[2] = wxT('\t');
511 const wxChar SEP
= wxT('\\');
513 const wxChar SEP
= wxT('/');
516 if (name
== NULL
|| *name
== wxT('\0'))
518 nm
= MYcopystring(name
); // Make a scratch copy
521 /* Skip leading whitespace and cr */
522 while (wxStrchr((wxChar
*)trimchars
, *nm
) != NULL
)
524 /* And strip off trailing whitespace and cr */
525 s
= nm
+ (q
= wxStrlen(nm
)) - 1;
526 while (q
-- && wxStrchr((wxChar
*)trimchars
, *s
) != NULL
)
534 q
= nm
[0] == wxT('\\') && nm
[1] == wxT('~');
537 /* Expand inline environment variables */
555 while ((*d
++ = *s
) != 0) {
557 if (*s
== wxT('\\')) {
558 if ((*(d
- 1) = *++s
)!=0) {
566 // No env variables on WinCE
569 if (*s
++ == wxT('$') && (*s
== wxT('{') || *s
== wxT(')')))
571 if (*s
++ == wxT('$'))
574 register wxChar
*start
= d
;
575 register int braces
= (*s
== wxT('{') || *s
== wxT('('));
576 register wxChar
*value
;
577 while ((*d
++ = *s
) != 0)
578 if (braces
? (*s
== wxT('}') || *s
== wxT(')')) : !(wxIsalnum(*s
) || *s
== wxT('_')) )
583 value
= wxGetenv(braces
? start
+ 1 : start
);
585 for ((d
= start
- 1); (*d
++ = *value
++) != 0;)
599 /* Expand ~ and ~user */
601 if (nm
[0] == wxT('~') && !q
)
604 if (nm
[1] == SEP
|| nm
[1] == 0)
606 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
607 if ((s
= WXSTRINGCAST
wxGetUserHome(wxEmptyString
)) != NULL
) {
612 { /* ~user/filename */
613 register wxChar
*nnm
;
614 register wxChar
*home
;
615 for (s
= nm
; *s
&& *s
!= SEP
; s
++)
619 int was_sep
; /* MATTHEW: Was there a separator, or NULL? */
620 was_sep
= (*s
== SEP
);
621 nnm
= *s
? s
+ 1 : s
;
623 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
624 if ((home
= WXSTRINGCAST
wxGetUserHome(wxString(nm
+ 1))) == NULL
)
626 if (was_sep
) /* replace only if it was there: */
639 if (s
&& *s
) { /* MATTHEW: s could be NULL if user '~' didn't exist */
641 while (wxT('\0') != (*d
++ = *s
++))
644 if (d
- 1 > buf
&& *(d
- 2) != SEP
)
648 while ((*d
++ = *s
++) != 0)
652 delete[] nm_tmp
; // clean up alloc
653 /* Now clean up the buffer */
654 return wxRealPath(buf
);
657 /* Contract Paths to be build upon an environment variable
660 example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib
662 The call wxExpandPath can convert these back!
665 wxContractPath (const wxString
& filename
,
666 const wxString
& WXUNUSED_IN_WINCE(envname
),
667 const wxString
& user
)
669 static wxChar dest
[_MAXPATHLEN
];
671 if (filename
.empty())
672 return (wxChar
*) NULL
;
674 wxStrcpy (dest
, WXSTRINGCAST filename
);
676 wxUnix2DosFilename(dest
);
679 // Handle environment
683 if (!envname
.empty() && (val
= wxGetenv (WXSTRINGCAST envname
)) != NULL
&&
684 (tcp
= wxStrstr (dest
, val
)) != NULL
)
686 wxStrcpy (wxFileFunctionsBuffer
, tcp
+ wxStrlen (val
));
689 wxStrcpy (tcp
, WXSTRINGCAST envname
);
690 wxStrcat (tcp
, wxT("}"));
691 wxStrcat (tcp
, wxFileFunctionsBuffer
);
695 // Handle User's home (ignore root homes!)
696 val
= wxGetUserHome (user
);
700 const size_t len
= wxStrlen(val
);
704 if (wxStrncmp(dest
, val
, len
) == 0)
706 wxStrcpy(wxFileFunctionsBuffer
, wxT("~"));
708 wxStrcat(wxFileFunctionsBuffer
, (const wxChar
*) user
);
709 wxStrcat(wxFileFunctionsBuffer
, dest
+ len
);
710 wxStrcpy (dest
, wxFileFunctionsBuffer
);
716 // Return just the filename, not the path (basename)
717 wxChar
*wxFileNameFromPath (wxChar
*path
)
720 wxString n
= wxFileNameFromPath(p
);
722 return path
+ p
.length() - n
.length();
725 wxString
wxFileNameFromPath (const wxString
& path
)
728 wxFileName::SplitPath(path
, NULL
, &name
, &ext
);
730 wxString fullname
= name
;
733 fullname
<< wxFILE_SEP_EXT
<< ext
;
739 // Return just the directory, or NULL if no directory
741 wxPathOnly (wxChar
*path
)
745 static wxChar buf
[_MAXPATHLEN
];
748 wxStrcpy (buf
, path
);
750 int l
= wxStrlen(path
);
753 // Search backward for a backward or forward slash
756 #if defined(__WXMAC__) && !defined(__DARWIN__)
757 // Classic or Carbon CodeWarrior like
758 // Carbon with Apple DevTools is Unix like
759 if (path
[i
] == wxT(':') )
765 // Unix like or Windows
766 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
773 if (path
[i
] == wxT(']'))
782 #if defined(__WXMSW__) || defined(__OS2__)
783 // Try Drive specifier
784 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
786 // A:junk --> A:. (since A:.\junk Not A:\junk)
793 return (wxChar
*) NULL
;
796 // Return just the directory, or NULL if no directory
797 wxString
wxPathOnly (const wxString
& path
)
801 wxChar buf
[_MAXPATHLEN
];
804 wxStrcpy (buf
, WXSTRINGCAST path
);
806 int l
= path
.length();
809 // Search backward for a backward or forward slash
812 #if defined(__WXMAC__) && !defined(__DARWIN__)
813 // Classic or Carbon CodeWarrior like
814 // Carbon with Apple DevTools is Unix like
815 if (path
[i
] == wxT(':') )
818 return wxString(buf
);
821 // Unix like or Windows
822 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
824 // Don't return an empty string
828 return wxString(buf
);
832 if (path
[i
] == wxT(']'))
835 return wxString(buf
);
841 #if defined(__WXMSW__) || defined(__OS2__)
842 // Try Drive specifier
843 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
845 // A:junk --> A:. (since A:.\junk Not A:\junk)
848 return wxString(buf
);
852 return wxEmptyString
;
855 // Utility for converting delimiters in DOS filenames to UNIX style
856 // and back again - or we get nasty problems with delimiters.
857 // Also, convert to lower case, since case is significant in UNIX.
859 #if defined(__WXMAC__)
861 #if TARGET_API_MAC_OSX
862 #define kDefaultPathStyle kCFURLPOSIXPathStyle
864 #define kDefaultPathStyle kCFURLHFSPathStyle
867 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
)
870 fullURLRef
= CFURLCreateFromFSRef(NULL
, fsRef
);
871 if ( additionalPathComponent
)
873 CFURLRef parentURLRef
= fullURLRef
;
874 fullURLRef
= CFURLCreateCopyAppendingPathComponent(NULL
, parentURLRef
,
875 additionalPathComponent
,false);
876 CFRelease( parentURLRef
) ;
878 CFStringRef cfString
= CFURLCopyFileSystemPath(fullURLRef
, kDefaultPathStyle
);
879 CFRelease( fullURLRef
) ;
880 return wxMacCFStringHolder(cfString
).AsString(wxLocale::GetSystemEncoding());
883 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
)
885 OSStatus err
= noErr
;
886 CFURLRef url
= CFURLCreateWithFileSystemPath(kCFAllocatorDefault
, wxMacCFStringHolder(path
,wxLocale::GetSystemEncoding() ) , kDefaultPathStyle
, false);
889 if ( CFURLGetFSRef(url
, fsRef
) == false )
900 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
)
902 CFStringRef cfname
= CFStringCreateWithCharacters( kCFAllocatorDefault
,
905 return wxMacCFStringHolder(cfname
).AsString() ;
908 wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
)
911 if ( FSpMakeFSRef( spec
, &fsRef
) == noErr
)
913 return wxMacFSRefToPath( &fsRef
) ;
915 return wxEmptyString
;
918 void wxMacFilename2FSSpec( const wxString
& path
, FSSpec
*spec
)
920 OSStatus err
= noErr
;
922 wxMacPathToFSRef( path
, &fsRef
) ;
923 err
= FSRefMakeFSSpec( &fsRef
, spec
) ;
929 wxDos2UnixFilename (wxChar
*s
)
938 *s
= (wxChar
)wxTolower (*s
); // Case INDEPENDENT
945 #if defined(__WXMSW__) || defined(__OS2__)
946 wxUnix2DosFilename (wxChar
*s
)
948 wxUnix2DosFilename (wxChar
*WXUNUSED(s
) )
951 // Yes, I really mean this to happen under DOS only! JACS
952 #if defined(__WXMSW__) || defined(__OS2__)
963 // Concatenate two files to form third
965 wxConcatFiles (const wxString
& file1
, const wxString
& file2
, const wxString
& file3
)
969 wxFile
in1(file1
), in2(file2
);
970 wxTempFile
out(file3
);
972 if ( !in1
.IsOpened() || !in2
.IsOpened() || !out
.IsOpened() )
976 unsigned char buf
[1024];
978 for( int i
=0; i
<2; i
++)
980 wxFile
*in
= i
==0 ? &in1
: &in2
;
982 if ( (ofs
= in
->Read(buf
,WXSIZEOF(buf
))) == wxInvalidOffset
) return false;
984 if ( !out
.Write(buf
,ofs
) )
986 } while ( ofs
== (ssize_t
)WXSIZEOF(buf
) );
1003 wxCopyFile (const wxString
& file1
, const wxString
& file2
, bool overwrite
)
1005 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
1006 // CopyFile() copies file attributes and modification time too, so use it
1007 // instead of our code if available
1009 // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
1010 if ( !::CopyFile(file1
, file2
, !overwrite
) )
1012 wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
1013 file1
.c_str(), file2
.c_str());
1017 #elif defined(__OS2__)
1018 if ( ::DosCopy((PSZ
)file1
.c_str(), (PSZ
)file2
.c_str(), overwrite
? DCPY_EXISTING
: 0) != 0 )
1020 #elif defined(__PALMOS__)
1021 // TODO with http://www.palmos.com/dev/support/docs/protein_books/Memory_Databases_Files/
1023 #elif wxUSE_FILE // !Win32
1026 // get permissions of file1
1027 if ( wxStat( file1
.c_str(), &fbuf
) != 0 )
1029 // the file probably doesn't exist or we haven't the rights to read
1031 wxLogSysError(_("Impossible to get permissions for file '%s'"),
1036 // open file1 for reading
1037 wxFile
fileIn(file1
, wxFile::read
);
1038 if ( !fileIn
.IsOpened() )
1041 // remove file2, if it exists. This is needed for creating
1042 // file2 with the correct permissions in the next step
1043 if ( wxFileExists(file2
) && (!overwrite
|| !wxRemoveFile(file2
)))
1045 wxLogSysError(_("Impossible to overwrite the file '%s'"),
1050 // reset the umask as we want to create the file with exactly the same
1051 // permissions as the original one
1054 // create file2 with the same permissions than file1 and open it for
1058 if ( !fileOut
.Create(file2
, overwrite
, fbuf
.st_mode
& 0777) )
1061 // copy contents of file1 to file2
1066 count
= fileIn
.Read(buf
, WXSIZEOF(buf
));
1067 if ( fileIn
.Error() )
1074 if ( fileOut
.Write(buf
, count
) < count
)
1078 // we can expect fileIn to be closed successfully, but we should ensure
1079 // that fileOut was closed as some write errors (disk full) might not be
1080 // detected before doing this
1081 if ( !fileIn
.Close() || !fileOut
.Close() )
1084 #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
1085 // no chmod in VA. Should be some permission API for HPFS386 partitions
1087 if ( chmod(OS_FILENAME(file2
), fbuf
.st_mode
) != 0 )
1089 wxLogSysError(_("Impossible to set permissions for the file '%s'"),
1093 #endif // OS/2 || Mac
1095 #else // !Win32 && ! wxUSE_FILE
1097 // impossible to simulate with wxWidgets API
1100 wxUnusedVar(overwrite
);
1103 #endif // __WXMSW__ && __WIN32__
1109 wxRenameFile (const wxString
& file1
, const wxString
& file2
)
1111 #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
1112 // Normal system call
1113 if ( wxRename (file1
, file2
) == 0 )
1118 if (wxCopyFile(file1
, file2
)) {
1119 wxRemoveFile(file1
);
1126 bool wxRemoveFile(const wxString
& file
)
1128 #if defined(__VISUALC__) \
1129 || defined(__BORLANDC__) \
1130 || defined(__WATCOMC__) \
1131 || defined(__DMC__) \
1132 || defined(__GNUWIN32__) \
1133 || (defined(__MWERKS__) && defined(__MSL__))
1134 int res
= wxRemove(file
);
1135 #elif defined(__WXMAC__)
1136 int res
= unlink(wxFNCONV(file
));
1137 #elif defined(__WXPALMOS__)
1139 // TODO with VFSFileDelete()
1141 int res
= unlink(OS_FILENAME(file
));
1147 bool wxMkdir(const wxString
& dir
, int perm
)
1149 #if defined(__WXPALMOS__)
1151 #elif defined(__WXMAC__) && !defined(__UNIX__)
1152 return (mkdir( wxFNCONV(dir
) , 0 ) == 0);
1154 const wxChar
*dirname
= dir
.c_str();
1156 // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
1157 // for the GNU compiler
1158 #if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
1161 if ( mkdir(wxFNCONV(dirname
)) != 0 )
1163 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1165 #elif defined(__OS2__)
1167 if (::DosCreateDir((PSZ
)dirname
, NULL
) != 0) // enhance for EAB's??
1168 #elif defined(__DOS__)
1169 #if defined(__WATCOMC__)
1171 if ( wxMkDir(wxFNSTRINGCAST
wxFNCONV(dirname
)) != 0 )
1172 #elif defined(__DJGPP__)
1173 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1175 #error "Unsupported DOS compiler!"
1177 #else // !MSW, !DOS and !OS/2 VAC++
1180 if ( !CreateDirectory(dirname
, NULL
) )
1182 if ( wxMkDir(dir
.fn_str()) != 0 )
1186 wxLogSysError(_("Directory '%s' couldn't be created"), dirname
);
1195 bool wxRmdir(const wxString
& dir
, int WXUNUSED(flags
))
1197 #if defined(__VMS__)
1198 return false; //to be changed since rmdir exists in VMS7.x
1199 #elif defined(__OS2__)
1200 return (::DosDeleteDir((PSZ
)dir
.c_str()) == 0);
1201 #elif defined(__WXWINCE__)
1202 return (CreateDirectory(dir
, NULL
) != 0);
1203 #elif defined(__WXPALMOS__)
1204 // TODO with VFSFileRename()
1207 return (wxRmDir(OS_FILENAME(dir
)) == 0);
1211 // does the path exists? (may have or not '/' or '\\' at the end)
1212 bool wxDirExists(const wxChar
*pszPathName
)
1214 wxString
strPath(pszPathName
);
1216 #if defined(__WINDOWS__) || defined(__OS2__)
1217 // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
1218 // so remove all trailing backslashes from the path - but don't do this for
1219 // the pathes "d:\" (which are different from "d:") nor for just "\"
1220 while ( wxEndsWithPathSeparator(strPath
) )
1222 size_t len
= strPath
.length();
1223 if ( len
== 1 || (len
== 3 && strPath
[len
- 2] == _T(':')) )
1226 strPath
.Truncate(len
- 1);
1228 #endif // __WINDOWS__
1231 // OS/2 can't handle "d:", it wants either "d:\" or "d:."
1232 if (strPath
.length() == 2 && strPath
[1u] == _T(':'))
1236 #if defined(__WXPALMOS__)
1238 #elif defined(__WIN32__) && !defined(__WXMICROWIN__)
1239 // stat() can't cope with network paths
1240 DWORD ret
= ::GetFileAttributes(strPath
);
1242 return (ret
!= (DWORD
)-1) && (ret
& FILE_ATTRIBUTE_DIRECTORY
);
1243 #elif defined(__OS2__)
1244 FILESTATUS3 Info
= {{0}};
1245 APIRET rc
= ::DosQueryPathInfo((PSZ
)(WXSTRINGCAST strPath
), FIL_STANDARD
,
1246 (void*) &Info
, sizeof(FILESTATUS3
));
1248 return ((rc
== NO_ERROR
) && (Info
.attrFile
& FILE_DIRECTORY
)) ||
1249 (rc
== ERROR_SHARING_VIOLATION
);
1250 // If we got a sharing violation, there must be something with this name.
1254 #ifndef __VISAGECPP__
1255 return wxStat(strPath
.c_str(), &st
) == 0 && ((st
.st_mode
& S_IFMT
) == S_IFDIR
);
1257 // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
1258 return wxStat(pszPathName
, &st
) == 0 && (st
.st_mode
== S_IFDIR
);
1261 #endif // __WIN32__/!__WIN32__
1264 // Get a temporary filename, opening and closing the file.
1265 wxChar
*wxGetTempFileName(const wxString
& prefix
, wxChar
*buf
)
1268 wxString filename
= wxFileName::CreateTempFileName(prefix
);
1269 if ( filename
.empty() )
1273 wxStrcpy(buf
, filename
);
1275 buf
= MYcopystring(filename
);
1279 wxUnusedVar(prefix
);
1281 // wxFileName::CreateTempFileName needs wxFile class enabled
1286 bool wxGetTempFileName(const wxString
& prefix
, wxString
& buf
)
1288 buf
= wxGetTempFileName(prefix
);
1290 return !buf
.empty();
1293 // Get first file name matching given wild card.
1295 static wxDir
*gs_dir
= NULL
;
1296 static wxString gs_dirPath
;
1298 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1300 wxSplitPath(spec
, &gs_dirPath
, NULL
, NULL
);
1301 if ( gs_dirPath
.empty() )
1302 gs_dirPath
= wxT(".");
1303 if ( !wxEndsWithPathSeparator(gs_dirPath
) )
1304 gs_dirPath
<< wxFILE_SEP_PATH
;
1308 gs_dir
= new wxDir(gs_dirPath
);
1310 if ( !gs_dir
->IsOpened() )
1312 wxLogSysError(_("Can not enumerate files '%s'"), spec
);
1313 return wxEmptyString
;
1319 case wxDIR
: dirFlags
= wxDIR_DIRS
; break;
1320 case wxFILE
: dirFlags
= wxDIR_FILES
; break;
1321 default: dirFlags
= wxDIR_DIRS
| wxDIR_FILES
; break;
1325 gs_dir
->GetFirst(&result
, wxFileNameFromPath(wxString(spec
)), dirFlags
);
1326 if ( result
.empty() )
1332 return gs_dirPath
+ result
;
1335 wxString
wxFindNextFile()
1337 wxASSERT_MSG( gs_dir
, wxT("You must call wxFindFirstFile before!") );
1340 gs_dir
->GetNext(&result
);
1342 if ( result
.empty() )
1348 return gs_dirPath
+ result
;
1352 // Get current working directory.
1353 // If buf is NULL, allocates space using new, else copies into buf.
1354 // wxGetWorkingDirectory() is obsolete, use wxGetCwd()
1355 // wxDoGetCwd() is their common core to be moved
1356 // to wxGetCwd() once wxGetWorkingDirectory() will be removed.
1357 // Do not expose wxDoGetCwd in headers!
1359 wxChar
*wxDoGetCwd(wxChar
*buf
, int sz
)
1361 #if defined(__WXPALMOS__)
1363 if(buf
&& sz
>0) buf
[0] = _T('\0');
1365 #elif defined(__WXWINCE__)
1367 if(buf
&& sz
>0) buf
[0] = _T('\0');
1372 buf
= new wxChar
[sz
+ 1];
1375 bool ok
wxDUMMY_INITIALIZE(false);
1377 // for the compilers which have Unicode version of _getcwd(), call it
1378 // directly, for the others call the ANSI version and do the translation
1381 #else // wxUSE_UNICODE
1382 bool needsANSI
= true;
1384 #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
1385 char cbuf
[_MAXPATHLEN
];
1389 #if wxUSE_UNICODE_MSLU
1390 if ( wxGetOsVersion() != wxWIN95
)
1392 char *cbuf
= NULL
; // never really used because needsANSI will always be false
1395 ok
= _wgetcwd(buf
, sz
) != NULL
;
1401 #endif // wxUSE_UNICODE
1403 #if defined(_MSC_VER) || defined(__MINGW32__)
1404 ok
= _getcwd(cbuf
, sz
) != NULL
;
1405 #elif defined(__WXMAC__) && !defined(__DARWIN__)
1407 if ( getcwd( lbuf
, sizeof( lbuf
) ) )
1409 wxString
res( lbuf
, *wxConvCurrent
) ;
1410 wxStrcpy( buf
, res
) ;
1415 #elif defined(__OS2__)
1417 ULONG ulDriveNum
= 0;
1418 ULONG ulDriveMap
= 0;
1419 rc
= ::DosQueryCurrentDisk(&ulDriveNum
, &ulDriveMap
);
1424 rc
= ::DosQueryCurrentDir( 0 // current drive
1428 cbuf
[0] = char('A' + (ulDriveNum
- 1));
1433 #else // !Win32/VC++ !Mac !OS2
1434 ok
= getcwd(cbuf
, sz
) != NULL
;
1437 #if wxUSE_UNICODE && !(defined(__WXMAC__) && !defined(__DARWIN__))
1438 // finally convert the result to Unicode if needed
1439 wxConvFile
.MB2WC(buf
, cbuf
, sz
);
1440 #endif // wxUSE_UNICODE
1445 wxLogSysError(_("Failed to get the working directory"));
1447 // VZ: the old code used to return "." on error which didn't make any
1448 // sense at all to me - empty string is a better error indicator
1449 // (NULL might be even better but I'm afraid this could lead to
1450 // problems with the old code assuming the return is never NULL)
1453 else // ok, but we might need to massage the path into the right format
1456 // VS: DJGPP is a strange mix of DOS and UNIX API and returns paths
1457 // with / deliminers. We don't like that.
1458 for (wxChar
*ch
= buf
; *ch
; ch
++)
1460 if (*ch
== wxT('/'))
1465 // MBN: we hope that in the case the user is compiling a GTK+/Motif app,
1466 // he needs Unix as opposed to Win32 pathnames
1467 #if defined( __CYGWIN__ ) && defined( __WINDOWS__ )
1468 // another example of DOS/Unix mix (Cygwin)
1469 wxString pathUnix
= buf
;
1471 char bufA
[_MAXPATHLEN
];
1472 cygwin_conv_to_full_win32_path(pathUnix
.mb_str(wxConvFile
), bufA
);
1473 wxConvFile
.MB2WC(buf
, bufA
, sz
);
1475 cygwin_conv_to_full_win32_path(pathUnix
, buf
);
1476 #endif // wxUSE_UNICODE
1477 #endif // __CYGWIN__
1490 #if WXWIN_COMPATIBILITY_2_6
1491 wxChar
*wxGetWorkingDirectory(wxChar
*buf
, int sz
)
1493 return wxDoGetCwd(buf
,sz
);
1495 #endif // WXWIN_COMPATIBILITY_2_6
1500 wxDoGetCwd(wxStringBuffer(str
, _MAXPATHLEN
), _MAXPATHLEN
);
1504 bool wxSetWorkingDirectory(const wxString
& d
)
1506 #if defined(__OS2__)
1507 return (::DosSetCurrentDir((PSZ
)d
.c_str()) == 0);
1508 #elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
1509 return (chdir(wxFNSTRINGCAST d
.fn_str()) == 0);
1510 #elif defined(__WINDOWS__)
1514 // No equivalent in WinCE
1518 return (bool)(SetCurrentDirectory(d
) != 0);
1521 // Must change drive, too.
1522 bool isDriveSpec
= ((strlen(d
) > 1) && (d
[1] == ':'));
1525 wxChar firstChar
= d
[0];
1529 firstChar
= firstChar
- 32;
1531 // To a drive number
1532 unsigned int driveNo
= firstChar
- 64;
1535 unsigned int noDrives
;
1536 _dos_setdrive(driveNo
, &noDrives
);
1539 bool success
= (chdir(WXSTRINGCAST d
) == 0);
1547 // Get the OS directory if appropriate (such as the Windows directory).
1548 // On non-Windows platform, probably just return the empty string.
1549 wxString
wxGetOSDirectory()
1552 return wxString(wxT("\\Windows"));
1553 #elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
1555 GetWindowsDirectory(buf
, 256);
1556 return wxString(buf
);
1557 #elif defined(__WXMAC__)
1558 return wxMacFindFolder(kOnSystemDisk
, 'macs', false);
1560 return wxEmptyString
;
1564 bool wxEndsWithPathSeparator(const wxChar
*pszFileName
)
1566 size_t len
= wxStrlen(pszFileName
);
1568 return len
&& wxIsPathSeparator(pszFileName
[len
- 1]);
1571 // find a file in a list of directories, returns false if not found
1572 bool wxFindFileInPath(wxString
*pStr
, const wxChar
*pszPath
, const wxChar
*pszFile
)
1574 // we assume that it's not empty
1575 wxCHECK_MSG( !wxIsEmpty(pszFile
), false,
1576 _T("empty file name in wxFindFileInPath"));
1578 // skip path separator in the beginning of the file name if present
1579 if ( wxIsPathSeparator(*pszFile
) )
1582 // copy the path (strtok will modify it)
1583 wxChar
*szPath
= new wxChar
[wxStrlen(pszPath
) + 1];
1584 wxStrcpy(szPath
, pszPath
);
1587 wxChar
*pc
, *save_ptr
;
1588 for ( pc
= wxStrtok(szPath
, wxPATH_SEP
, &save_ptr
);
1590 pc
= wxStrtok((wxChar
*) NULL
, wxPATH_SEP
, &save_ptr
) )
1592 // search for the file in this directory
1594 if ( !wxEndsWithPathSeparator(pc
) )
1595 strFile
+= wxFILE_SEP_PATH
;
1598 if ( wxFileExists(strFile
) ) {
1604 // suppress warning about unused variable save_ptr when wxStrtok() is a
1605 // macro which throws away its third argument
1610 return pc
!= NULL
; // if true => we breaked from the loop
1613 void WXDLLEXPORT
wxSplitPath(const wxChar
*pszFileName
,
1618 // it can be empty, but it shouldn't be NULL
1619 wxCHECK_RET( pszFileName
, wxT("NULL file name in wxSplitPath") );
1621 wxFileName::SplitPath(pszFileName
, pstrPath
, pstrName
, pstrExt
);
1624 time_t WXDLLEXPORT
wxFileModificationTime(const wxString
& filename
)
1626 #if defined(__WXPALMOS__)
1628 #elif defined(__WXWINCE__)
1629 FILETIME ftLastWrite
;
1630 AutoHANDLE
hFile(::CreateFile(filename
, GENERIC_READ
, FILE_SHARE_READ
,
1631 NULL
, 0, FILE_ATTRIBUTE_NORMAL
, 0));
1633 if ( !hFile
.IsOk() )
1636 if ( !::GetFileTime(hFile
, NULL
, NULL
, &ftLastWrite
) )
1639 // sure we want to translate to local time here?
1641 if ( !::FileTimeToLocalFileTime(&ftLastWrite
, &ftLocal
) )
1643 wxLogLastError(_T("FileTimeToLocalFileTime"));
1646 // FILETIME is a counted in 100-ns since 1601-01-01, convert it to
1647 // number of seconds since 1970-01-01
1649 uli
.LowPart
= ftLocal
.dwLowDateTime
;
1650 uli
.HighPart
= ftLocal
.dwHighDateTime
;
1652 ULONGLONG ull
= uli
.QuadPart
;
1653 ull
/= wxULL(10000000); // number of 100ns intervals in 1s
1654 ull
-= wxULL(11644473600); // 1970-01-01 - 1601-01-01 in seconds
1656 return wx_static_cast(time_t, ull
);
1659 if ( wxStat( filename
, &buf
) != 0 )
1662 return buf
.st_mtime
;
1667 // Parses the filterStr, returning the number of filters.
1668 // Returns 0 if none or if there's a problem.
1669 // filterStr is in the form: "All files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpeg"
1671 int WXDLLEXPORT
wxParseCommonDialogsFilter(const wxString
& filterStr
,
1672 wxArrayString
& descriptions
,
1673 wxArrayString
& filters
)
1675 descriptions
.Clear();
1678 wxString
str(filterStr
);
1680 wxString description
, filter
;
1682 while( pos
!= wxNOT_FOUND
)
1684 pos
= str
.Find(wxT('|'));
1685 if ( pos
== wxNOT_FOUND
)
1687 // if there are no '|'s at all in the string just take the entire
1688 // string as filter and make description empty for later autocompletion
1689 if ( filters
.IsEmpty() )
1691 descriptions
.Add(wxEmptyString
);
1692 filters
.Add(filterStr
);
1696 wxFAIL_MSG( _T("missing '|' in the wildcard string!") );
1702 description
= str
.Left(pos
);
1703 str
= str
.Mid(pos
+ 1);
1704 pos
= str
.Find(wxT('|'));
1705 if ( pos
== wxNOT_FOUND
)
1711 filter
= str
.Left(pos
);
1712 str
= str
.Mid(pos
+ 1);
1715 descriptions
.Add(description
);
1716 filters
.Add(filter
);
1719 #if defined(__WXMOTIF__)
1720 // split it so there is one wildcard per entry
1721 for( size_t i
= 0 ; i
< descriptions
.GetCount() ; i
++ )
1723 pos
= filters
[i
].Find(wxT(';'));
1724 if (pos
!= wxNOT_FOUND
)
1726 // first split only filters
1727 descriptions
.Insert(descriptions
[i
],i
+1);
1728 filters
.Insert(filters
[i
].Mid(pos
+1),i
+1);
1729 filters
[i
]=filters
[i
].Left(pos
);
1731 // autoreplace new filter in description with pattern:
1732 // C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
1733 // cause split into:
1734 // C/C++ Files(*.cpp)|*.cpp
1735 // C/C++ Files(*.c;*.h)|*.c;*.h
1736 // and next iteration cause another split into:
1737 // C/C++ Files(*.cpp)|*.cpp
1738 // C/C++ Files(*.c)|*.c
1739 // C/C++ Files(*.h)|*.h
1740 for ( size_t k
=i
;k
<i
+2;k
++ )
1742 pos
= descriptions
[k
].Find(filters
[k
]);
1743 if (pos
!= wxNOT_FOUND
)
1745 wxString before
= descriptions
[k
].Left(pos
);
1746 wxString after
= descriptions
[k
].Mid(pos
+filters
[k
].Len());
1747 pos
= before
.Find(_T('('),true);
1748 if (pos
>before
.Find(_T(')'),true))
1750 before
= before
.Left(pos
+1);
1751 before
<< filters
[k
];
1752 pos
= after
.Find(_T(')'));
1753 int pos1
= after
.Find(_T('('));
1754 if (pos
!= wxNOT_FOUND
&& (pos
<pos1
|| pos1
==wxNOT_FOUND
))
1756 before
<< after
.Mid(pos
);
1757 descriptions
[k
] = before
;
1767 for( size_t j
= 0 ; j
< descriptions
.GetCount() ; j
++ )
1769 if ( descriptions
[j
].empty() && !filters
[j
].empty() )
1771 descriptions
[j
].Printf(_("Files (%s)"), filters
[j
].c_str());
1775 return filters
.GetCount();
1779 //------------------------------------------------------------------------
1780 // wild character routines
1781 //------------------------------------------------------------------------
1783 bool wxIsWild( const wxString
& pattern
)
1785 wxString tmp
= pattern
;
1786 wxChar
*pat
= WXSTRINGCAST(tmp
);
1791 case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
1802 * Written By Douglas A. Lewis <dalewis@cs.Buffalo.EDU>
1804 * The match procedure is public domain code (from ircII's reg.c)
1805 * but modified to suit our tastes (RN: No "%" syntax I guess)
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(),
1824 if (dot_special
&& (*n
== wxT('.')))
1826 /* Never match so that hidden Unix files
1827 * are never found. */
1840 else if (*m
== wxT('?'))
1848 if (*m
== wxT('\\'))
1851 /* Quoting "nothing" is a bad thing */
1858 * If we are out of both strings or we just
1859 * saw a wildcard, then we can say we have a
1870 * We could check for *n == NULL at this point, but
1871 * since it's more common to have a character there,
1872 * check to see if they match first (m and n) and
1873 * then if they don't match, THEN we can check for
1889 * If there are no more characters in the
1890 * string, but we still need to find another
1891 * character (*m != NULL), then it will be
1892 * impossible to match it
1910 // Return the type of an open file
1912 // Some file types on some platforms seem seekable but in fact are not.
1913 // The main use of this function is to allow such cases to be detected
1914 // (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
1916 // This is important for the archive streams, which benefit greatly from
1917 // being able to seek on a stream, but which will produce corrupt archives
1918 // if they unknowingly seek on a non-seekable stream.
1920 // wxFILE_KIND_DISK is a good catch all return value, since other values
1921 // disable features of the archive streams. Some other value must be returned
1922 // for a file type that appears seekable but isn't.
1925 // * Pipes on Windows
1926 // * Files on VMS with a record format other than StreamLF
1928 wxFileKind
wxGetFileKind(int fd
)
1930 #if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
1931 switch (::GetFileType(wxGetOSFHandle(fd
)) & ~FILE_TYPE_REMOTE
)
1933 case FILE_TYPE_CHAR
:
1934 return wxFILE_KIND_TERMINAL
;
1935 case FILE_TYPE_DISK
:
1936 return wxFILE_KIND_DISK
;
1937 case FILE_TYPE_PIPE
:
1938 return wxFILE_KIND_PIPE
;
1941 return wxFILE_KIND_UNKNOWN
;
1943 #elif defined(__UNIX__)
1945 return wxFILE_KIND_TERMINAL
;
1950 if (S_ISFIFO(st
.st_mode
))
1951 return wxFILE_KIND_PIPE
;
1952 if (!S_ISREG(st
.st_mode
))
1953 return wxFILE_KIND_UNKNOWN
;
1955 #if defined(__VMS__)
1956 if (st
.st_fab_rfm
!= FAB$C_STMLF
)
1957 return wxFILE_KIND_UNKNOWN
;
1960 return wxFILE_KIND_DISK
;
1963 #define wxFILEKIND_STUB
1965 return wxFILE_KIND_DISK
;
1969 wxFileKind
wxGetFileKind(FILE *fp
)
1971 // Note: The watcom rtl dll doesn't have fileno (the static lib does).
1972 // Should be fixed in version 1.4.
1973 #if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4)
1975 return wxFILE_KIND_DISK
;
1977 return fp
? wxGetFileKind(fileno(fp
)) : wxFILE_KIND_UNKNOWN
;
1982 #pragma warning(default:4706) // assignment within conditional expression