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 !defined(__WATCOMC__)
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 return wxStat( filename
, &st
) == 0 && (st
.st_mode
& S_IFREG
);
308 #endif // __WIN32__/!__WIN32__
312 wxIsAbsolutePath (const wxString
& filename
)
314 if (!filename
.empty())
316 #if defined(__WXMAC__) && !defined(__DARWIN__)
317 // Classic or Carbon CodeWarrior like
318 // Carbon with Apple DevTools is Unix like
320 // This seems wrong to me, but there is no fix. since
321 // "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
322 // is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
323 if (filename
.Find(':') != wxNOT_FOUND
&& filename
[0] != ':')
326 // Unix like or Windows
327 if (filename
[0] == wxT('/'))
331 if ((filename
[0] == wxT('[') && filename
[1] != wxT('.')))
334 #if defined(__WINDOWS__) || defined(__OS2__)
336 if (filename
[0] == wxT('\\') || (wxIsalpha (filename
[0]) && filename
[1] == wxT(':')))
344 * Strip off any extension (dot something) from end of file,
345 * IF one exists. Inserts zero into buffer.
349 void wxStripExtension(wxChar
*buffer
)
351 int len
= wxStrlen(buffer
);
355 if (buffer
[i
] == wxT('.'))
364 void wxStripExtension(wxString
& buffer
)
366 //RN: Be careful about the handling the case where
367 //buffer.length() == 0
368 for(size_t i
= buffer
.length() - 1; i
!= wxString::npos
; --i
)
370 if (buffer
.GetChar(i
) == wxT('.'))
372 buffer
= buffer
.Left(i
);
378 // Destructive removal of /./ and /../ stuff
379 wxChar
*wxRealPath (wxChar
*path
)
382 static const wxChar SEP
= wxT('\\');
383 wxUnix2DosFilename(path
);
385 static const wxChar SEP
= wxT('/');
387 if (path
[0] && path
[1]) {
388 /* MATTHEW: special case "/./x" */
390 if (path
[2] == SEP
&& path
[1] == wxT('.'))
398 if (p
[1] == wxT('.') && p
[2] == wxT('.') && (p
[3] == SEP
|| p
[3] == wxT('\0')))
401 for (q
= p
- 1; q
>= path
&& *q
!= SEP
; q
--)
406 if (q
[0] == SEP
&& (q
[1] != wxT('.') || q
[2] != wxT('.') || q
[3] != SEP
)
407 && (q
- 1 <= path
|| q
[-1] != SEP
))
410 if (path
[0] == wxT('\0'))
415 #if defined(__WXMSW__) || defined(__OS2__)
416 /* Check that path[2] is NULL! */
417 else if (path
[1] == wxT(':') && !path
[2])
426 else if (p
[1] == wxT('.') && (p
[2] == SEP
|| p
[2] == wxT('\0')))
434 wxString
wxRealPath(const wxString
& path
)
436 wxChar
*buf1
=MYcopystring(path
);
437 wxChar
*buf2
=wxRealPath(buf1
);
445 wxChar
*wxCopyAbsolutePath(const wxString
& filename
)
447 if (filename
.empty())
448 return (wxChar
*) NULL
;
450 if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer
, filename
)))
452 wxString buf
= ::wxGetCwd();
453 wxChar ch
= buf
.Last();
455 if (ch
!= wxT('\\') && ch
!= wxT('/'))
461 buf
<< wxFileFunctionsBuffer
;
462 buf
= wxRealPath( buf
);
463 return MYcopystring( buf
);
465 return MYcopystring( wxFileFunctionsBuffer
);
471 ~user/ => user's home dir
472 If the environment variable a = "foo" and b = "bar" then:
489 /* input name in name, pathname output to buf. */
491 wxChar
*wxExpandPath(wxChar
*buf
, const wxChar
*name
)
493 register wxChar
*d
, *s
, *nm
;
494 wxChar lnm
[_MAXPATHLEN
];
497 // Some compilers don't like this line.
498 // const wxChar trimchars[] = wxT("\n \t");
501 trimchars
[0] = wxT('\n');
502 trimchars
[1] = wxT(' ');
503 trimchars
[2] = wxT('\t');
507 const wxChar SEP
= wxT('\\');
509 const wxChar SEP
= wxT('/');
512 if (name
== NULL
|| *name
== wxT('\0'))
514 nm
= MYcopystring(name
); // Make a scratch copy
517 /* Skip leading whitespace and cr */
518 while (wxStrchr((wxChar
*)trimchars
, *nm
) != NULL
)
520 /* And strip off trailing whitespace and cr */
521 s
= nm
+ (q
= wxStrlen(nm
)) - 1;
522 while (q
-- && wxStrchr((wxChar
*)trimchars
, *s
) != NULL
)
530 q
= nm
[0] == wxT('\\') && nm
[1] == wxT('~');
533 /* Expand inline environment variables */
551 while ((*d
++ = *s
) != 0) {
553 if (*s
== wxT('\\')) {
554 if ((*(d
- 1) = *++s
)!=0) {
562 // No env variables on WinCE
565 if (*s
++ == wxT('$') && (*s
== wxT('{') || *s
== wxT(')')))
567 if (*s
++ == wxT('$'))
570 register wxChar
*start
= d
;
571 register int braces
= (*s
== wxT('{') || *s
== wxT('('));
572 register wxChar
*value
;
573 while ((*d
++ = *s
) != 0)
574 if (braces
? (*s
== wxT('}') || *s
== wxT(')')) : !(wxIsalnum(*s
) || *s
== wxT('_')) )
579 value
= wxGetenv(braces
? start
+ 1 : start
);
581 for ((d
= start
- 1); (*d
++ = *value
++) != 0;)
595 /* Expand ~ and ~user */
597 if (nm
[0] == wxT('~') && !q
)
600 if (nm
[1] == SEP
|| nm
[1] == 0)
602 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
603 if ((s
= WXSTRINGCAST
wxGetUserHome(wxEmptyString
)) != NULL
) {
608 { /* ~user/filename */
609 register wxChar
*nnm
;
610 register wxChar
*home
;
611 for (s
= nm
; *s
&& *s
!= SEP
; s
++)
615 int was_sep
; /* MATTHEW: Was there a separator, or NULL? */
616 was_sep
= (*s
== SEP
);
617 nnm
= *s
? s
+ 1 : s
;
619 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
620 if ((home
= WXSTRINGCAST
wxGetUserHome(wxString(nm
+ 1))) == NULL
)
622 if (was_sep
) /* replace only if it was there: */
635 if (s
&& *s
) { /* MATTHEW: s could be NULL if user '~' didn't exist */
637 while (wxT('\0') != (*d
++ = *s
++))
640 if (d
- 1 > buf
&& *(d
- 2) != SEP
)
644 while ((*d
++ = *s
++) != 0)
648 delete[] nm_tmp
; // clean up alloc
649 /* Now clean up the buffer */
650 return wxRealPath(buf
);
653 /* Contract Paths to be build upon an environment variable
656 example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib
658 The call wxExpandPath can convert these back!
661 wxContractPath (const wxString
& filename
,
662 const wxString
& WXUNUSED_IN_WINCE(envname
),
663 const wxString
& user
)
665 static wxChar dest
[_MAXPATHLEN
];
667 if (filename
.empty())
668 return (wxChar
*) NULL
;
670 wxStrcpy (dest
, WXSTRINGCAST filename
);
672 wxUnix2DosFilename(dest
);
675 // Handle environment
679 if (!envname
.empty() && (val
= wxGetenv (WXSTRINGCAST envname
)) != NULL
&&
680 (tcp
= wxStrstr (dest
, val
)) != NULL
)
682 wxStrcpy (wxFileFunctionsBuffer
, tcp
+ wxStrlen (val
));
685 wxStrcpy (tcp
, WXSTRINGCAST envname
);
686 wxStrcat (tcp
, wxT("}"));
687 wxStrcat (tcp
, wxFileFunctionsBuffer
);
691 // Handle User's home (ignore root homes!)
692 val
= wxGetUserHome (user
);
696 const size_t len
= wxStrlen(val
);
700 if (wxStrncmp(dest
, val
, len
) == 0)
702 wxStrcpy(wxFileFunctionsBuffer
, wxT("~"));
704 wxStrcat(wxFileFunctionsBuffer
, (const wxChar
*) user
);
705 wxStrcat(wxFileFunctionsBuffer
, dest
+ len
);
706 wxStrcpy (dest
, wxFileFunctionsBuffer
);
712 // Return just the filename, not the path (basename)
713 wxChar
*wxFileNameFromPath (wxChar
*path
)
716 wxString n
= wxFileNameFromPath(p
);
718 return path
+ p
.length() - n
.length();
721 wxString
wxFileNameFromPath (const wxString
& path
)
724 wxFileName::SplitPath(path
, NULL
, &name
, &ext
);
726 wxString fullname
= name
;
729 fullname
<< wxFILE_SEP_EXT
<< ext
;
735 // Return just the directory, or NULL if no directory
737 wxPathOnly (wxChar
*path
)
741 static wxChar buf
[_MAXPATHLEN
];
744 wxStrcpy (buf
, path
);
746 int l
= wxStrlen(path
);
749 // Search backward for a backward or forward slash
752 #if defined(__WXMAC__) && !defined(__DARWIN__)
753 // Classic or Carbon CodeWarrior like
754 // Carbon with Apple DevTools is Unix like
755 if (path
[i
] == wxT(':') )
761 // Unix like or Windows
762 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
769 if (path
[i
] == wxT(']'))
778 #if defined(__WXMSW__) || defined(__OS2__)
779 // Try Drive specifier
780 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
782 // A:junk --> A:. (since A:.\junk Not A:\junk)
789 return (wxChar
*) NULL
;
792 // Return just the directory, or NULL if no directory
793 wxString
wxPathOnly (const wxString
& path
)
797 wxChar buf
[_MAXPATHLEN
];
800 wxStrcpy (buf
, WXSTRINGCAST path
);
802 int l
= path
.length();
805 // Search backward for a backward or forward slash
808 #if defined(__WXMAC__) && !defined(__DARWIN__)
809 // Classic or Carbon CodeWarrior like
810 // Carbon with Apple DevTools is Unix like
811 if (path
[i
] == wxT(':') )
814 return wxString(buf
);
817 // Unix like or Windows
818 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\'))
820 // Don't return an empty string
824 return wxString(buf
);
828 if (path
[i
] == wxT(']'))
831 return wxString(buf
);
837 #if defined(__WXMSW__) || defined(__OS2__)
838 // Try Drive specifier
839 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
841 // A:junk --> A:. (since A:.\junk Not A:\junk)
844 return wxString(buf
);
848 return wxEmptyString
;
851 // Utility for converting delimiters in DOS filenames to UNIX style
852 // and back again - or we get nasty problems with delimiters.
853 // Also, convert to lower case, since case is significant in UNIX.
855 #if defined(__WXMAC__)
857 #if TARGET_API_MAC_OSX
858 #define kDefaultPathStyle kCFURLPOSIXPathStyle
860 #define kDefaultPathStyle kCFURLHFSPathStyle
863 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
)
866 fullURLRef
= CFURLCreateFromFSRef(NULL
, fsRef
);
867 if ( additionalPathComponent
)
869 CFURLRef parentURLRef
= fullURLRef
;
870 fullURLRef
= CFURLCreateCopyAppendingPathComponent(NULL
, parentURLRef
,
871 additionalPathComponent
,false);
872 CFRelease( parentURLRef
) ;
874 CFStringRef cfString
= CFURLCopyFileSystemPath(fullURLRef
, kDefaultPathStyle
);
875 CFRelease( fullURLRef
) ;
876 return wxMacCFStringHolder(cfString
).AsString(wxLocale::GetSystemEncoding());
879 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
)
881 OSStatus err
= noErr
;
882 CFURLRef url
= CFURLCreateWithFileSystemPath(kCFAllocatorDefault
, wxMacCFStringHolder(path
,wxLocale::GetSystemEncoding() ) , kDefaultPathStyle
, false);
885 if ( CFURLGetFSRef(url
, fsRef
) == false )
896 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
)
898 CFStringRef cfname
= CFStringCreateWithCharacters( kCFAllocatorDefault
,
901 return wxMacCFStringHolder(cfname
).AsString() ;
904 wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
)
907 if ( FSpMakeFSRef( spec
, &fsRef
) == noErr
)
909 return wxMacFSRefToPath( &fsRef
) ;
911 return wxEmptyString
;
914 void wxMacFilename2FSSpec( const wxString
& path
, FSSpec
*spec
)
916 OSStatus err
= noErr
;
918 wxMacPathToFSRef( path
, &fsRef
) ;
919 err
= FSRefMakeFSSpec( &fsRef
, spec
) ;
925 wxDos2UnixFilename (wxChar
*s
)
934 *s
= (wxChar
)wxTolower (*s
); // Case INDEPENDENT
941 #if defined(__WXMSW__) || defined(__OS2__)
942 wxUnix2DosFilename (wxChar
*s
)
944 wxUnix2DosFilename (wxChar
*WXUNUSED(s
) )
947 // Yes, I really mean this to happen under DOS only! JACS
948 #if defined(__WXMSW__) || defined(__OS2__)
959 // Concatenate two files to form third
961 wxConcatFiles (const wxString
& file1
, const wxString
& file2
, const wxString
& file3
)
965 wxFile
in1(file1
), in2(file2
);
966 wxTempFile
out(file3
);
968 if ( !in1
.IsOpened() || !in2
.IsOpened() || !out
.IsOpened() )
972 unsigned char buf
[1024];
974 for( int i
=0; i
<2; i
++)
976 wxFile
*in
= i
==0 ? &in1
: &in2
;
978 if ( (ofs
= in
->Read(buf
,WXSIZEOF(buf
))) == wxInvalidOffset
) return false;
980 if ( !out
.Write(buf
,ofs
) )
982 } while ( ofs
== (ssize_t
)WXSIZEOF(buf
) );
999 wxCopyFile (const wxString
& file1
, const wxString
& file2
, bool overwrite
)
1001 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
1002 // CopyFile() copies file attributes and modification time too, so use it
1003 // instead of our code if available
1005 // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
1006 if ( !::CopyFile(file1
, file2
, !overwrite
) )
1008 wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
1009 file1
.c_str(), file2
.c_str());
1013 #elif defined(__OS2__)
1014 if ( ::DosCopy((PSZ
)file1
.c_str(), (PSZ
)file2
.c_str(), overwrite
? DCPY_EXISTING
: 0) != 0 )
1016 #elif defined(__PALMOS__)
1017 // TODO with http://www.palmos.com/dev/support/docs/protein_books/Memory_Databases_Files/
1019 #elif wxUSE_FILE // !Win32
1022 // get permissions of file1
1023 if ( wxStat( file1
.c_str(), &fbuf
) != 0 )
1025 // the file probably doesn't exist or we haven't the rights to read
1027 wxLogSysError(_("Impossible to get permissions for file '%s'"),
1032 // open file1 for reading
1033 wxFile
fileIn(file1
, wxFile::read
);
1034 if ( !fileIn
.IsOpened() )
1037 // remove file2, if it exists. This is needed for creating
1038 // file2 with the correct permissions in the next step
1039 if ( wxFileExists(file2
) && (!overwrite
|| !wxRemoveFile(file2
)))
1041 wxLogSysError(_("Impossible to overwrite the file '%s'"),
1046 // reset the umask as we want to create the file with exactly the same
1047 // permissions as the original one
1050 // create file2 with the same permissions than file1 and open it for
1054 if ( !fileOut
.Create(file2
, overwrite
, fbuf
.st_mode
& 0777) )
1057 // copy contents of file1 to file2
1062 count
= fileIn
.Read(buf
, WXSIZEOF(buf
));
1063 if ( fileIn
.Error() )
1070 if ( fileOut
.Write(buf
, count
) < count
)
1074 // we can expect fileIn to be closed successfully, but we should ensure
1075 // that fileOut was closed as some write errors (disk full) might not be
1076 // detected before doing this
1077 if ( !fileIn
.Close() || !fileOut
.Close() )
1080 #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
1081 // no chmod in VA. Should be some permission API for HPFS386 partitions
1083 if ( chmod(OS_FILENAME(file2
), fbuf
.st_mode
) != 0 )
1085 wxLogSysError(_("Impossible to set permissions for the file '%s'"),
1089 #endif // OS/2 || Mac
1091 #else // !Win32 && ! wxUSE_FILE
1093 // impossible to simulate with wxWidgets API
1096 wxUnusedVar(overwrite
);
1099 #endif // __WXMSW__ && __WIN32__
1105 wxRenameFile (const wxString
& file1
, const wxString
& file2
)
1107 #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
1108 // Normal system call
1109 if ( wxRename (file1
, file2
) == 0 )
1114 if (wxCopyFile(file1
, file2
)) {
1115 wxRemoveFile(file1
);
1122 bool wxRemoveFile(const wxString
& file
)
1124 #if defined(__VISUALC__) \
1125 || defined(__BORLANDC__) \
1126 || defined(__WATCOMC__) \
1127 || defined(__DMC__) \
1128 || defined(__GNUWIN32__) \
1129 || (defined(__MWERKS__) && defined(__MSL__))
1130 int res
= wxRemove(file
);
1131 #elif defined(__WXMAC__)
1132 int res
= unlink(wxFNCONV(file
));
1133 #elif defined(__WXPALMOS__)
1135 // TODO with VFSFileDelete()
1137 int res
= unlink(OS_FILENAME(file
));
1143 bool wxMkdir(const wxString
& dir
, int perm
)
1145 #if defined(__WXPALMOS__)
1147 #elif defined(__WXMAC__) && !defined(__UNIX__)
1148 return (mkdir( wxFNCONV(dir
) , 0 ) == 0);
1150 const wxChar
*dirname
= dir
.c_str();
1152 // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
1153 // for the GNU compiler
1154 #if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
1157 if ( mkdir(wxFNCONV(dirname
)) != 0 )
1159 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1161 #elif defined(__OS2__)
1163 if (::DosCreateDir((PSZ
)dirname
, NULL
) != 0) // enhance for EAB's??
1164 #elif defined(__DOS__)
1165 #if defined(__WATCOMC__)
1167 if ( wxMkDir(wxFNSTRINGCAST
wxFNCONV(dirname
)) != 0 )
1168 #elif defined(__DJGPP__)
1169 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1171 #error "Unsupported DOS compiler!"
1173 #else // !MSW, !DOS and !OS/2 VAC++
1176 if ( !CreateDirectory(dirname
, NULL
) )
1178 if ( wxMkDir(dir
.fn_str()) != 0 )
1182 wxLogSysError(_("Directory '%s' couldn't be created"), dirname
);
1191 bool wxRmdir(const wxString
& dir
, int WXUNUSED(flags
))
1193 #if defined(__VMS__)
1194 return false; //to be changed since rmdir exists in VMS7.x
1195 #elif defined(__OS2__)
1196 return (::DosDeleteDir((PSZ
)dir
.c_str()) == 0);
1197 #elif defined(__WXWINCE__)
1198 return (CreateDirectory(dir
, NULL
) != 0);
1199 #elif defined(__WXPALMOS__)
1200 // TODO with VFSFileRename()
1203 return (wxRmDir(OS_FILENAME(dir
)) == 0);
1207 // does the path exists? (may have or not '/' or '\\' at the end)
1208 bool wxDirExists(const wxChar
*pszPathName
)
1210 wxString
strPath(pszPathName
);
1212 #if defined(__WINDOWS__) || defined(__OS2__)
1213 // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
1214 // so remove all trailing backslashes from the path - but don't do this for
1215 // the pathes "d:\" (which are different from "d:") nor for just "\"
1216 while ( wxEndsWithPathSeparator(strPath
) )
1218 size_t len
= strPath
.length();
1219 if ( len
== 1 || (len
== 3 && strPath
[len
- 2] == _T(':')) )
1222 strPath
.Truncate(len
- 1);
1224 #endif // __WINDOWS__
1227 // OS/2 can't handle "d:", it wants either "d:\" or "d:."
1228 if (strPath
.length() == 2 && strPath
[1u] == _T(':'))
1232 #if defined(__WXPALMOS__)
1234 #elif defined(__WIN32__) && !defined(__WXMICROWIN__)
1235 // stat() can't cope with network paths
1236 DWORD ret
= ::GetFileAttributes(strPath
);
1238 return (ret
!= (DWORD
)-1) && (ret
& FILE_ATTRIBUTE_DIRECTORY
);
1239 #elif defined(__OS2__)
1240 FILESTATUS3 Info
= {{0}};
1241 APIRET rc
= ::DosQueryPathInfo((PSZ
)(WXSTRINGCAST strPath
), FIL_STANDARD
,
1242 (void*) &Info
, sizeof(FILESTATUS3
));
1244 return ((rc
== NO_ERROR
) && (Info
.attrFile
& FILE_DIRECTORY
)) ||
1245 (rc
== ERROR_SHARING_VIOLATION
);
1246 // If we got a sharing violation, there must be something with this name.
1250 #ifndef __VISAGECPP__
1251 return wxStat(strPath
.c_str(), &st
) == 0 && ((st
.st_mode
& S_IFMT
) == S_IFDIR
);
1253 // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
1254 return wxStat(pszPathName
, &st
) == 0 && (st
.st_mode
== S_IFDIR
);
1257 #endif // __WIN32__/!__WIN32__
1260 // Get a temporary filename, opening and closing the file.
1261 wxChar
*wxGetTempFileName(const wxString
& prefix
, wxChar
*buf
)
1264 wxString filename
= wxFileName::CreateTempFileName(prefix
);
1265 if ( filename
.empty() )
1269 wxStrcpy(buf
, filename
);
1271 buf
= MYcopystring(filename
);
1275 wxUnusedVar(prefix
);
1277 // wxFileName::CreateTempFileName needs wxFile class enabled
1282 bool wxGetTempFileName(const wxString
& prefix
, wxString
& buf
)
1284 buf
= wxGetTempFileName(prefix
);
1286 return !buf
.empty();
1289 // Get first file name matching given wild card.
1291 static wxDir
*gs_dir
= NULL
;
1292 static wxString gs_dirPath
;
1294 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1296 wxSplitPath(spec
, &gs_dirPath
, NULL
, NULL
);
1297 if ( gs_dirPath
.empty() )
1298 gs_dirPath
= wxT(".");
1299 if ( !wxEndsWithPathSeparator(gs_dirPath
) )
1300 gs_dirPath
<< wxFILE_SEP_PATH
;
1304 gs_dir
= new wxDir(gs_dirPath
);
1306 if ( !gs_dir
->IsOpened() )
1308 wxLogSysError(_("Can not enumerate files '%s'"), spec
);
1309 return wxEmptyString
;
1315 case wxDIR
: dirFlags
= wxDIR_DIRS
; break;
1316 case wxFILE
: dirFlags
= wxDIR_FILES
; break;
1317 default: dirFlags
= wxDIR_DIRS
| wxDIR_FILES
; break;
1321 gs_dir
->GetFirst(&result
, wxFileNameFromPath(wxString(spec
)), dirFlags
);
1322 if ( result
.empty() )
1328 return gs_dirPath
+ result
;
1331 wxString
wxFindNextFile()
1333 wxASSERT_MSG( gs_dir
, wxT("You must call wxFindFirstFile before!") );
1336 gs_dir
->GetNext(&result
);
1338 if ( result
.empty() )
1344 return gs_dirPath
+ result
;
1348 // Get current working directory.
1349 // If buf is NULL, allocates space using new, else copies into buf.
1350 // wxGetWorkingDirectory() is obsolete, use wxGetCwd()
1351 // wxDoGetCwd() is their common core to be moved
1352 // to wxGetCwd() once wxGetWorkingDirectory() will be removed.
1353 // Do not expose wxDoGetCwd in headers!
1355 wxChar
*wxDoGetCwd(wxChar
*buf
, int sz
)
1357 #if defined(__WXPALMOS__)
1359 if(buf
&& sz
>0) buf
[0] = _T('\0');
1361 #elif defined(__WXWINCE__)
1363 if(buf
&& sz
>0) buf
[0] = _T('\0');
1368 buf
= new wxChar
[sz
+ 1];
1371 bool ok
wxDUMMY_INITIALIZE(false);
1373 // for the compilers which have Unicode version of _getcwd(), call it
1374 // directly, for the others call the ANSI version and do the translation
1377 #else // wxUSE_UNICODE
1378 bool needsANSI
= true;
1380 #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
1381 char cbuf
[_MAXPATHLEN
];
1385 #if wxUSE_UNICODE_MSLU
1386 if ( wxGetOsVersion() != wxWIN95
)
1388 char *cbuf
= NULL
; // never really used because needsANSI will always be false
1391 ok
= _wgetcwd(buf
, sz
) != NULL
;
1397 #endif // wxUSE_UNICODE
1399 #if defined(_MSC_VER) || defined(__MINGW32__)
1400 ok
= _getcwd(cbuf
, sz
) != NULL
;
1401 #elif defined(__WXMAC__) && !defined(__DARWIN__)
1403 if ( getcwd( lbuf
, sizeof( lbuf
) ) )
1405 wxString
res( lbuf
, *wxConvCurrent
) ;
1406 wxStrcpy( buf
, res
) ;
1411 #elif defined(__OS2__)
1413 ULONG ulDriveNum
= 0;
1414 ULONG ulDriveMap
= 0;
1415 rc
= ::DosQueryCurrentDisk(&ulDriveNum
, &ulDriveMap
);
1420 rc
= ::DosQueryCurrentDir( 0 // current drive
1424 cbuf
[0] = char('A' + (ulDriveNum
- 1));
1429 #else // !Win32/VC++ !Mac !OS2
1430 ok
= getcwd(cbuf
, sz
) != NULL
;
1433 #if wxUSE_UNICODE && !(defined(__WXMAC__) && !defined(__DARWIN__))
1434 // finally convert the result to Unicode if needed
1435 wxConvFile
.MB2WC(buf
, cbuf
, sz
);
1436 #endif // wxUSE_UNICODE
1441 wxLogSysError(_("Failed to get the working directory"));
1443 // VZ: the old code used to return "." on error which didn't make any
1444 // sense at all to me - empty string is a better error indicator
1445 // (NULL might be even better but I'm afraid this could lead to
1446 // problems with the old code assuming the return is never NULL)
1449 else // ok, but we might need to massage the path into the right format
1452 // VS: DJGPP is a strange mix of DOS and UNIX API and returns paths
1453 // with / deliminers. We don't like that.
1454 for (wxChar
*ch
= buf
; *ch
; ch
++)
1456 if (*ch
== wxT('/'))
1461 // MBN: we hope that in the case the user is compiling a GTK+/Motif app,
1462 // he needs Unix as opposed to Win32 pathnames
1463 #if defined( __CYGWIN__ ) && defined( __WINDOWS__ )
1464 // another example of DOS/Unix mix (Cygwin)
1465 wxString pathUnix
= buf
;
1467 char bufA
[_MAXPATHLEN
];
1468 cygwin_conv_to_full_win32_path(pathUnix
.mb_str(wxConvFile
), bufA
);
1469 wxConvFile
.MB2WC(buf
, bufA
, sz
);
1471 cygwin_conv_to_full_win32_path(pathUnix
, buf
);
1472 #endif // wxUSE_UNICODE
1473 #endif // __CYGWIN__
1486 #if WXWIN_COMPATIBILITY_2_6
1487 wxChar
*wxGetWorkingDirectory(wxChar
*buf
, int sz
)
1489 return wxDoGetCwd(buf
,sz
);
1491 #endif // WXWIN_COMPATIBILITY_2_6
1496 wxDoGetCwd(wxStringBuffer(str
, _MAXPATHLEN
), _MAXPATHLEN
);
1500 bool wxSetWorkingDirectory(const wxString
& d
)
1502 #if defined(__OS2__)
1503 return (::DosSetCurrentDir((PSZ
)d
.c_str()) == 0);
1504 #elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
1505 return (chdir(wxFNSTRINGCAST d
.fn_str()) == 0);
1506 #elif defined(__WINDOWS__)
1510 // No equivalent in WinCE
1514 return (bool)(SetCurrentDirectory(d
) != 0);
1517 // Must change drive, too.
1518 bool isDriveSpec
= ((strlen(d
) > 1) && (d
[1] == ':'));
1521 wxChar firstChar
= d
[0];
1525 firstChar
= firstChar
- 32;
1527 // To a drive number
1528 unsigned int driveNo
= firstChar
- 64;
1531 unsigned int noDrives
;
1532 _dos_setdrive(driveNo
, &noDrives
);
1535 bool success
= (chdir(WXSTRINGCAST d
) == 0);
1543 // Get the OS directory if appropriate (such as the Windows directory).
1544 // On non-Windows platform, probably just return the empty string.
1545 wxString
wxGetOSDirectory()
1548 return wxString(wxT("\\Windows"));
1549 #elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
1551 GetWindowsDirectory(buf
, 256);
1552 return wxString(buf
);
1553 #elif defined(__WXMAC__)
1554 return wxMacFindFolder(kOnSystemDisk
, 'macs', false);
1556 return wxEmptyString
;
1560 bool wxEndsWithPathSeparator(const wxChar
*pszFileName
)
1562 size_t len
= wxStrlen(pszFileName
);
1564 return len
&& wxIsPathSeparator(pszFileName
[len
- 1]);
1567 // find a file in a list of directories, returns false if not found
1568 bool wxFindFileInPath(wxString
*pStr
, const wxChar
*pszPath
, const wxChar
*pszFile
)
1570 // we assume that it's not empty
1571 wxCHECK_MSG( !wxIsEmpty(pszFile
), false,
1572 _T("empty file name in wxFindFileInPath"));
1574 // skip path separator in the beginning of the file name if present
1575 if ( wxIsPathSeparator(*pszFile
) )
1578 // copy the path (strtok will modify it)
1579 wxChar
*szPath
= new wxChar
[wxStrlen(pszPath
) + 1];
1580 wxStrcpy(szPath
, pszPath
);
1583 wxChar
*pc
, *save_ptr
;
1584 for ( pc
= wxStrtok(szPath
, wxPATH_SEP
, &save_ptr
);
1586 pc
= wxStrtok((wxChar
*) NULL
, wxPATH_SEP
, &save_ptr
) )
1588 // search for the file in this directory
1590 if ( !wxEndsWithPathSeparator(pc
) )
1591 strFile
+= wxFILE_SEP_PATH
;
1594 if ( wxFileExists(strFile
) ) {
1600 // suppress warning about unused variable save_ptr when wxStrtok() is a
1601 // macro which throws away its third argument
1606 return pc
!= NULL
; // if true => we breaked from the loop
1609 void WXDLLEXPORT
wxSplitPath(const wxChar
*pszFileName
,
1614 // it can be empty, but it shouldn't be NULL
1615 wxCHECK_RET( pszFileName
, wxT("NULL file name in wxSplitPath") );
1617 wxFileName::SplitPath(pszFileName
, pstrPath
, pstrName
, pstrExt
);
1620 time_t WXDLLEXPORT
wxFileModificationTime(const wxString
& filename
)
1622 #if defined(__WXPALMOS__)
1624 #elif defined(__WXWINCE__)
1625 FILETIME ftLastWrite
;
1626 AutoHANDLE
hFile(::CreateFile(filename
, GENERIC_READ
, FILE_SHARE_READ
,
1627 NULL
, 0, FILE_ATTRIBUTE_NORMAL
, 0));
1629 if ( !hFile
.IsOk() )
1632 if ( !::GetFileTime(hFile
, NULL
, NULL
, &ftLastWrite
) )
1635 // sure we want to translate to local time here?
1637 if ( !::FileTimeToLocalFileTime(&ftLastWrite
, &ftLocal
) )
1639 wxLogLastError(_T("FileTimeToLocalFileTime"));
1642 // FILETIME is a counted in 100-ns since 1601-01-01, convert it to
1643 // number of seconds since 1970-01-01
1645 uli
.LowPart
= ftLocal
.dwLowDateTime
;
1646 uli
.HighPart
= ftLocal
.dwHighDateTime
;
1648 ULONGLONG ull
= uli
.QuadPart
;
1649 ull
/= wxULL(10000000); // number of 100ns intervals in 1s
1650 ull
-= wxULL(11644473600); // 1970-01-01 - 1601-01-01 in seconds
1652 return wx_static_cast(time_t, ull
);
1655 if ( wxStat( filename
, &buf
) != 0 )
1658 return buf
.st_mtime
;
1663 // Parses the filterStr, returning the number of filters.
1664 // Returns 0 if none or if there's a problem.
1665 // filterStr is in the form: "All files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpeg"
1667 int WXDLLEXPORT
wxParseCommonDialogsFilter(const wxString
& filterStr
,
1668 wxArrayString
& descriptions
,
1669 wxArrayString
& filters
)
1671 descriptions
.Clear();
1674 wxString
str(filterStr
);
1676 wxString description
, filter
;
1678 while( pos
!= wxNOT_FOUND
)
1680 pos
= str
.Find(wxT('|'));
1681 if ( pos
== wxNOT_FOUND
)
1683 // if there are no '|'s at all in the string just take the entire
1684 // string as filter and make description empty for later autocompletion
1685 if ( filters
.IsEmpty() )
1687 descriptions
.Add(wxEmptyString
);
1688 filters
.Add(filterStr
);
1692 wxFAIL_MSG( _T("missing '|' in the wildcard string!") );
1698 description
= str
.Left(pos
);
1699 str
= str
.Mid(pos
+ 1);
1700 pos
= str
.Find(wxT('|'));
1701 if ( pos
== wxNOT_FOUND
)
1707 filter
= str
.Left(pos
);
1708 str
= str
.Mid(pos
+ 1);
1711 descriptions
.Add(description
);
1712 filters
.Add(filter
);
1715 #if defined(__WXMOTIF__)
1716 // split it so there is one wildcard per entry
1717 for( size_t i
= 0 ; i
< descriptions
.GetCount() ; i
++ )
1719 pos
= filters
[i
].Find(wxT(';'));
1720 if (pos
!= wxNOT_FOUND
)
1722 // first split only filters
1723 descriptions
.Insert(descriptions
[i
],i
+1);
1724 filters
.Insert(filters
[i
].Mid(pos
+1),i
+1);
1725 filters
[i
]=filters
[i
].Left(pos
);
1727 // autoreplace new filter in description with pattern:
1728 // C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
1729 // cause split into:
1730 // C/C++ Files(*.cpp)|*.cpp
1731 // C/C++ Files(*.c;*.h)|*.c;*.h
1732 // and next iteration cause another split into:
1733 // C/C++ Files(*.cpp)|*.cpp
1734 // C/C++ Files(*.c)|*.c
1735 // C/C++ Files(*.h)|*.h
1736 for ( size_t k
=i
;k
<i
+2;k
++ )
1738 pos
= descriptions
[k
].Find(filters
[k
]);
1739 if (pos
!= wxNOT_FOUND
)
1741 wxString before
= descriptions
[k
].Left(pos
);
1742 wxString after
= descriptions
[k
].Mid(pos
+filters
[k
].Len());
1743 pos
= before
.Find(_T('('),true);
1744 if (pos
>before
.Find(_T(')'),true))
1746 before
= before
.Left(pos
+1);
1747 before
<< filters
[k
];
1748 pos
= after
.Find(_T(')'));
1749 int pos1
= after
.Find(_T('('));
1750 if (pos
!= wxNOT_FOUND
&& (pos
<pos1
|| pos1
==wxNOT_FOUND
))
1752 before
<< after
.Mid(pos
);
1753 descriptions
[k
] = before
;
1763 for( size_t j
= 0 ; j
< descriptions
.GetCount() ; j
++ )
1765 if ( descriptions
[j
].empty() && !filters
[j
].empty() )
1767 descriptions
[j
].Printf(_("Files (%s)"), filters
[j
].c_str());
1771 return filters
.GetCount();
1775 //------------------------------------------------------------------------
1776 // wild character routines
1777 //------------------------------------------------------------------------
1779 bool wxIsWild( const wxString
& pattern
)
1781 wxString tmp
= pattern
;
1782 wxChar
*pat
= WXSTRINGCAST(tmp
);
1787 case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
1798 * Written By Douglas A. Lewis <dalewis@cs.Buffalo.EDU>
1800 * The match procedure is public domain code (from ircII's reg.c)
1803 bool wxMatchWild( const wxString
& pat
, const wxString
& text
, bool dot_special
)
1807 /* Match if both are empty. */
1811 const wxChar
*m
= pat
.c_str(),
1822 if (dot_special
&& (*n
== wxT('.')))
1824 /* Never match so that hidden Unix files
1825 * are never found. */
1839 else if (*m
== wxT('?'))
1847 if (*m
== wxT('\\'))
1850 /* Quoting "nothing" is a bad thing */
1857 * If we are out of both strings or we just
1858 * saw a wildcard, then we can say we have a
1869 * We could check for *n == NULL at this point, but
1870 * since it's more common to have a character there,
1871 * check to see if they match first (m and n) and
1872 * then if they don't match, THEN we can check for
1890 * If there are no more characters in the
1891 * string, but we still need to find another
1892 * character (*m != NULL), then it will be
1893 * impossible to match it
1900 if (*np
== wxT(' '))
1924 // Return the type of an open file
1926 // Some file types on some platforms seem seekable but in fact are not.
1927 // The main use of this function is to allow such cases to be detected
1928 // (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
1930 // This is important for the archive streams, which benefit greatly from
1931 // being able to seek on a stream, but which will produce corrupt archives
1932 // if they unknowingly seek on a non-seekable stream.
1934 // wxFILE_KIND_DISK is a good catch all return value, since other values
1935 // disable features of the archive streams. Some other value must be returned
1936 // for a file type that appears seekable but isn't.
1939 // * Pipes on Windows
1940 // * Files on VMS with a record format other than StreamLF
1942 wxFileKind
wxGetFileKind(int fd
)
1944 #if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
1945 switch (::GetFileType(wxGetOSFHandle(fd
)) & ~FILE_TYPE_REMOTE
)
1947 case FILE_TYPE_CHAR
:
1948 return wxFILE_KIND_TERMINAL
;
1949 case FILE_TYPE_DISK
:
1950 return wxFILE_KIND_DISK
;
1951 case FILE_TYPE_PIPE
:
1952 return wxFILE_KIND_PIPE
;
1955 return wxFILE_KIND_UNKNOWN
;
1957 #elif defined(__UNIX__)
1959 return wxFILE_KIND_TERMINAL
;
1964 if (S_ISFIFO(st
.st_mode
))
1965 return wxFILE_KIND_PIPE
;
1966 if (!S_ISREG(st
.st_mode
))
1967 return wxFILE_KIND_UNKNOWN
;
1969 #if defined(__VMS__)
1970 if (st
.st_fab_rfm
!= FAB$C_STMLF
)
1971 return wxFILE_KIND_UNKNOWN
;
1974 return wxFILE_KIND_DISK
;
1977 #define wxFILEKIND_STUB
1979 return wxFILE_KIND_DISK
;
1983 wxFileKind
wxGetFileKind(FILE *fp
)
1985 // Note: The watcom rtl dll doesn't have fileno (the static lib does).
1986 // Should be fixed in version 1.4.
1987 #if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4)
1989 return wxFILE_KIND_DISK
;
1991 return fp
? wxGetFileKind(fileno(fp
)) : wxFILE_KIND_UNKNOWN
;
1996 #pragma warning(default:4706) // assignment within conditional expression