1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: File- and directory-related functions
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "filefn.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/filename.h"
37 // there are just too many of those...
39 #pragma warning(disable:4706) // assignment within conditional expression
46 #if !defined(__WATCOMC__)
47 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
55 #include <sys/types.h>
70 #include "wx/os2/private.h"
73 #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
78 #endif // native Win compiler
83 #include <sys/unistd.h>
87 #ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
88 // this (3.1 I believe) and how to test for it.
89 // If this works for Borland 4.0 as well, then no worries.
101 // No, Cygwin doesn't appear to have fnmatch.h after all.
102 #if defined(HAVE_FNMATCH_H)
110 // ----------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------
114 #define _MAXPATHLEN 500
116 extern wxChar
*wxBuffer
;
119 # include "MoreFiles.h"
120 # include "MoreFilesExtras.h"
121 # include "FullPath.h"
122 # include "FSpCompat.h"
125 IMPLEMENT_DYNAMIC_CLASS(wxPathList
, wxStringList
)
127 // ----------------------------------------------------------------------------
129 // ----------------------------------------------------------------------------
131 static wxChar wxFileFunctionsBuffer
[4*_MAXPATHLEN
];
133 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
135 // VisualAge C++ V4.0 cannot have any external linkage const decs
136 // in headers included by more than one primary source
138 const off_t wxInvalidOffset
= (off_t
)-1;
141 // ----------------------------------------------------------------------------
143 // ----------------------------------------------------------------------------
145 // we need to translate Mac filenames before passing them to OS functions
146 #if defined(__WXMAC__) && defined(__DARWIN__)
147 #define OS_FILENAME(s) wxMac2UnixFilename(s.fn_str())
149 #define OS_FILENAME(s) (s.fn_str())
152 // ============================================================================
154 // ============================================================================
156 void wxPathList::Add (const wxString
& path
)
158 wxStringList::Add (WXSTRINGCAST path
);
161 // Add paths e.g. from the PATH environment variable
162 void wxPathList::AddEnvList (const wxString
& envVariable
)
164 static const wxChar PATH_TOKS
[] =
166 wxT(" ;"); // Don't seperate with colon in DOS (used for drive)
171 wxChar
*val
= wxGetenv (WXSTRINGCAST envVariable
);
174 wxChar
*s
= copystring (val
);
175 wxChar
*save_ptr
, *token
= wxStrtok (s
, PATH_TOKS
, &save_ptr
);
179 Add (copystring (token
));
182 if ((token
= wxStrtok ((wxChar
*) NULL
, PATH_TOKS
, &save_ptr
)) != NULL
)
183 Add (wxString(token
));
187 // suppress warning about unused variable save_ptr when wxStrtok() is a
188 // macro which throws away its third argument
195 // Given a full filename (with path), ensure that that file can
196 // be accessed again USING FILENAME ONLY by adding the path
197 // to the list if not already there.
198 void wxPathList::EnsureFileAccessible (const wxString
& path
)
200 wxString
path_only(wxPathOnly(path
));
201 if ( !path_only
.IsEmpty() )
203 if ( !Member(path_only
) )
208 bool wxPathList::Member (const wxString
& path
)
210 for (wxNode
* node
= First (); node
!= NULL
; node
= node
->Next ())
212 wxString
path2((wxChar
*) node
->Data ());
214 #if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__)
216 path
.CompareTo (path2
, wxString::ignoreCase
) == 0
218 // Case sensitive File System
219 path
.CompareTo (path2
) == 0
227 wxString
wxPathList::FindValidPath (const wxString
& file
)
229 if (wxFileExists (wxExpandPath(wxFileFunctionsBuffer
, file
)))
230 return wxString(wxFileFunctionsBuffer
);
232 wxChar buf
[_MAXPATHLEN
];
233 wxStrcpy(buf
, wxFileFunctionsBuffer
);
235 wxChar
*filename
= (wxChar
*) NULL
; /* shut up buggy egcs warning */
236 filename
= IsAbsolutePath (buf
) ? wxFileNameFromPath (buf
) : (wxChar
*)buf
;
238 for (wxNode
* node
= First (); node
; node
= node
->Next ())
240 wxChar
*path
= (wxChar
*) node
->Data ();
241 wxStrcpy (wxFileFunctionsBuffer
, path
);
242 wxChar ch
= wxFileFunctionsBuffer
[wxStrlen(wxFileFunctionsBuffer
)-1];
243 if (ch
!= wxT('\\') && ch
!= wxT('/'))
244 wxStrcat (wxFileFunctionsBuffer
, wxT("/"));
245 wxStrcat (wxFileFunctionsBuffer
, filename
);
247 Unix2DosFilename (wxFileFunctionsBuffer
);
249 if (wxFileExists (wxFileFunctionsBuffer
))
251 return wxString(wxFileFunctionsBuffer
); // Found!
255 return wxString(wxT("")); // Not found
258 wxString
wxPathList::FindAbsoluteValidPath (const wxString
& file
)
260 wxString f
= FindValidPath(file
);
261 if ( wxIsAbsolutePath(f
) )
265 wxGetWorkingDirectory(buf
.GetWriteBuf(_MAXPATHLEN
), _MAXPATHLEN
- 1);
267 if ( !wxEndsWithPathSeparator(buf
) )
269 buf
+= wxFILE_SEP_PATH
;
277 wxFileExists (const wxString
& filename
)
280 // GetFileAttributes can copy with network paths
281 DWORD ret
= GetFileAttributes(filename
);
282 DWORD isDir
= (ret
& FILE_ATTRIBUTE_DIRECTORY
);
283 return ((ret
!= 0xffffffff) && (isDir
== 0));
286 if ( !filename
.empty() && wxStat (OS_FILENAME(filename
), &stbuf
) == 0 )
294 wxIsAbsolutePath (const wxString
& filename
)
297 if (filename
!= wxT(""))
299 // This seems wrong to me, but there is no fix. since
300 // "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
301 // is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
303 if (filename
.Find(':') != wxNOT_FOUND
&& filename
[0] != ':')
308 if (filename
!= wxT(""))
310 if (filename
[0] == wxT('/')
312 || (filename
[0] == wxT('[') && filename
[1] != wxT('.'))
316 || filename
[0] == wxT('\\') || (wxIsalpha (filename
[0]) && filename
[1] == wxT(':'))
326 * Strip off any extension (dot something) from end of file,
327 * IF one exists. Inserts zero into buffer.
331 void wxStripExtension(wxChar
*buffer
)
333 int len
= wxStrlen(buffer
);
337 if (buffer
[i
] == wxT('.'))
346 void wxStripExtension(wxString
& buffer
)
348 size_t len
= buffer
.Length();
352 if (buffer
.GetChar(i
) == wxT('.'))
354 buffer
= buffer
.Left(i
);
361 // Destructive removal of /./ and /../ stuff
362 wxChar
*wxRealPath (wxChar
*path
)
365 static const wxChar SEP
= wxT('\\');
366 Unix2DosFilename(path
);
368 static const wxChar SEP
= wxT('/');
370 if (path
[0] && path
[1]) {
371 /* MATTHEW: special case "/./x" */
373 if (path
[2] == SEP
&& path
[1] == wxT('.'))
381 if (p
[1] == wxT('.') && p
[2] == wxT('.') && (p
[3] == SEP
|| p
[3] == wxT('\0')))
384 for (q
= p
- 1; q
>= path
&& *q
!= SEP
; q
--);
385 if (q
[0] == SEP
&& (q
[1] != wxT('.') || q
[2] != wxT('.') || q
[3] != SEP
)
386 && (q
- 1 <= path
|| q
[-1] != SEP
))
389 if (path
[0] == wxT('\0'))
395 /* Check that path[2] is NULL! */
396 else if (path
[1] == wxT(':') && !path
[2])
405 else if (p
[1] == wxT('.') && (p
[2] == SEP
|| p
[2] == wxT('\0')))
414 wxChar
*wxCopyAbsolutePath(const wxString
& filename
)
416 if (filename
== wxT(""))
417 return (wxChar
*) NULL
;
419 if (! IsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer
, filename
))) {
420 wxChar buf
[_MAXPATHLEN
];
422 wxGetWorkingDirectory(buf
, WXSIZEOF(buf
));
423 wxChar ch
= buf
[wxStrlen(buf
) - 1];
425 if (ch
!= wxT('\\') && ch
!= wxT('/'))
426 wxStrcat(buf
, wxT("\\"));
429 wxStrcat(buf
, wxT("/"));
431 wxStrcat(buf
, wxFileFunctionsBuffer
);
432 return copystring( wxRealPath(buf
) );
434 return copystring( wxFileFunctionsBuffer
);
440 ~user/ => user's home dir
441 If the environment variable a = "foo" and b = "bar" then:
458 /* input name in name, pathname output to buf. */
460 wxChar
*wxExpandPath(wxChar
*buf
, const wxChar
*name
)
462 register wxChar
*d
, *s
, *nm
;
463 wxChar lnm
[_MAXPATHLEN
];
466 // Some compilers don't like this line.
467 // const wxChar trimchars[] = wxT("\n \t");
470 trimchars
[0] = wxT('\n');
471 trimchars
[1] = wxT(' ');
472 trimchars
[2] = wxT('\t');
476 const wxChar SEP
= wxT('\\');
478 const wxChar SEP
= wxT('/');
481 if (name
== NULL
|| *name
== wxT('\0'))
483 nm
= copystring(name
); // Make a scratch copy
486 /* Skip leading whitespace and cr */
487 while (wxStrchr((wxChar
*)trimchars
, *nm
) != NULL
)
489 /* And strip off trailing whitespace and cr */
490 s
= nm
+ (q
= wxStrlen(nm
)) - 1;
491 while (q
-- && wxStrchr((wxChar
*)trimchars
, *s
) != NULL
)
499 q
= nm
[0] == wxT('\\') && nm
[1] == wxT('~');
502 /* Expand inline environment variables */
520 while ((*d
++ = *s
) != 0) {
522 if (*s
== wxT('\\')) {
523 if ((*(d
- 1) = *++s
)) {
532 if (*s
++ == wxT('$') && (*s
== wxT('{') || *s
== wxT(')')))
534 if (*s
++ == wxT('$'))
537 register wxChar
*start
= d
;
538 register int braces
= (*s
== wxT('{') || *s
== wxT('('));
539 register wxChar
*value
;
540 while ((*d
++ = *s
) != 0)
541 if (braces
? (*s
== wxT('}') || *s
== wxT(')')) : !(wxIsalnum(*s
) || *s
== wxT('_')) )
546 value
= wxGetenv(braces
? start
+ 1 : start
);
548 for ((d
= start
- 1); (*d
++ = *value
++) != 0;);
556 /* Expand ~ and ~user */
559 if (nm
[0] == wxT('~') && !q
)
562 if (nm
[1] == SEP
|| nm
[1] == 0)
564 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
565 if ((s
= WXSTRINGCAST
wxGetUserHome(wxT(""))) != NULL
) {
570 { /* ~user/filename */
571 register wxChar
*nnm
;
572 register wxChar
*home
;
573 for (s
= nm
; *s
&& *s
!= SEP
; s
++);
574 int was_sep
; /* MATTHEW: Was there a separator, or NULL? */
575 was_sep
= (*s
== SEP
);
576 nnm
= *s
? s
+ 1 : s
;
578 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
579 if ((home
= WXSTRINGCAST
wxGetUserHome(wxString(nm
+ 1))) == NULL
) {
580 if (was_sep
) /* replace only if it was there: */
591 if (s
&& *s
) { /* MATTHEW: s could be NULL if user '~' didn't exist */
593 while (wxT('\0') != (*d
++ = *s
++))
596 if (d
- 1 > buf
&& *(d
- 2) != SEP
)
600 while ((*d
++ = *s
++) != 0);
601 delete[] nm_tmp
; // clean up alloc
602 /* Now clean up the buffer */
603 return wxRealPath(buf
);
606 /* Contract Paths to be build upon an environment variable
609 example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib
611 The call wxExpandPath can convert these back!
614 wxContractPath (const wxString
& filename
, const wxString
& envname
, const wxString
& user
)
616 static wxChar dest
[_MAXPATHLEN
];
618 if (filename
== wxT(""))
619 return (wxChar
*) NULL
;
621 wxStrcpy (dest
, WXSTRINGCAST filename
);
623 Unix2DosFilename(dest
);
626 // Handle environment
627 const wxChar
*val
= (const wxChar
*) NULL
;
628 wxChar
*tcp
= (wxChar
*) NULL
;
629 if (envname
!= WXSTRINGCAST NULL
&& (val
= wxGetenv (WXSTRINGCAST envname
)) != NULL
&&
630 (tcp
= wxStrstr (dest
, val
)) != NULL
)
632 wxStrcpy (wxFileFunctionsBuffer
, tcp
+ wxStrlen (val
));
635 wxStrcpy (tcp
, WXSTRINGCAST envname
);
636 wxStrcat (tcp
, wxT("}"));
637 wxStrcat (tcp
, wxFileFunctionsBuffer
);
640 // Handle User's home (ignore root homes!)
642 if ((val
= wxGetUserHome (user
)) != NULL
&&
643 (len
= wxStrlen(val
)) > 2 &&
644 wxStrncmp(dest
, val
, len
) == 0)
646 wxStrcpy(wxFileFunctionsBuffer
, wxT("~"));
648 wxStrcat(wxFileFunctionsBuffer
, (const wxChar
*) user
);
650 // strcat(wxFileFunctionsBuffer, "\\");
652 // strcat(wxFileFunctionsBuffer, "/");
654 wxStrcat(wxFileFunctionsBuffer
, dest
+ len
);
655 wxStrcpy (dest
, wxFileFunctionsBuffer
);
661 // Return just the filename, not the path
663 wxChar
*wxFileNameFromPath (wxChar
*path
)
667 register wxChar
*tcp
;
669 tcp
= path
+ wxStrlen (path
);
670 while (--tcp
>= path
)
673 if (*tcp
== wxT(':') )
675 if (*tcp
== wxT('/') || *tcp
== wxT('\\')
677 || *tcp
== wxT(':') || *tcp
== wxT(']'))
684 #if defined(__WXMSW__) || defined(__WXPM__)
685 if (wxIsalpha (*path
) && *(path
+ 1) == wxT(':'))
692 wxString
wxFileNameFromPath (const wxString
& path1
)
694 if (path1
!= wxT(""))
697 wxChar
*path
= WXSTRINGCAST path1
;
698 register wxChar
*tcp
;
700 tcp
= path
+ wxStrlen (path
);
701 while (--tcp
>= path
)
704 if (*tcp
== wxT(':') )
706 if (*tcp
== wxT('/') || *tcp
== wxT('\\')
708 || *tcp
== wxT(':') || *tcp
== wxT(']'))
713 return wxString(tcp
+ 1);
715 #if defined(__WXMSW__) || defined(__WXPM__)
716 if (wxIsalpha (*path
) && *(path
+ 1) == wxT(':'))
717 return wxString(path
+ 2);
720 // Yes, this should return the path, not an empty string, otherwise
721 // we get "thing.txt" -> "".
725 // Return just the directory, or NULL if no directory
727 wxPathOnly (wxChar
*path
)
731 static wxChar buf
[_MAXPATHLEN
];
734 wxStrcpy (buf
, path
);
736 int l
= wxStrlen(path
);
741 // Search backward for a backward or forward slash
742 while (!done
&& i
> -1)
746 if (path
[i
] == wxT(':') )
748 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\') || path
[i
] == wxT(']'))
753 if ( path
[i
] == wxT(']') )
764 #if defined(__WXMSW__) || defined(__WXPM__)
765 // Try Drive specifier
766 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
768 // A:junk --> A:. (since A:.\junk Not A:\junk)
776 return (wxChar
*) NULL
;
779 // Return just the directory, or NULL if no directory
780 wxString
wxPathOnly (const wxString
& path
)
784 wxChar buf
[_MAXPATHLEN
];
787 wxStrcpy (buf
, WXSTRINGCAST path
);
789 int l
= path
.Length();
794 // Search backward for a backward or forward slash
795 while (!done
&& i
> -1)
799 if (path
[i
] == wxT(':') )
801 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\') || path
[i
] == wxT(']'))
806 if ( path
[i
] == wxT(']') )
812 return wxString(buf
);
817 #if defined(__WXMSW__) || defined(__WXPM__)
818 // Try Drive specifier
819 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
821 // A:junk --> A:. (since A:.\junk Not A:\junk)
824 return wxString(buf
);
829 return wxString(wxT(""));
832 // Utility for converting delimiters in DOS filenames to UNIX style
833 // and back again - or we get nasty problems with delimiters.
834 // Also, convert to lower case, since case is significant in UNIX.
836 #if defined(__WXMAC__)
837 wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
)
842 FSpGetFullPath( spec
, &length
, &myPath
) ;
843 ::SetHandleSize( myPath
, length
+ 1 ) ;
845 (*myPath
)[length
] = 0 ;
846 if ( length
> 0 && (*myPath
)[length
-1] ==':' )
847 (*myPath
)[length
-1] = 0 ;
849 wxString
result( (char*) *myPath
) ;
850 ::HUnlock( myPath
) ;
851 ::DisposeHandle( myPath
) ;
855 void wxMacFilename2FSSpec( const char *path
, FSSpec
*spec
)
857 FSpLocationFromFullPath( strlen(path
) , path
, spec
) ;
860 static char sMacFileNameConversion
[ 1000 ] ;
862 wxString
wxMac2UnixFilename (const char *str
)
864 char *s
= sMacFileNameConversion
;
868 memmove( s
+1 , s
,strlen( s
) + 1) ;
879 *s
= wxTolower (*s
); // Case INDEPENDENT
883 return wxString (sMacFileNameConversion
) ;
886 wxString
wxUnix2MacFilename (const char *str
)
888 char *s
= sMacFileNameConversion
;
894 // relative path , since it goes on with slash which is translated to a :
895 memmove( s
, s
+1 ,strlen( s
) ) ;
897 else if ( *s
== '/' )
899 // absolute path -> on mac just start with the drive name
900 memmove( s
, s
+1 ,strlen( s
) ) ;
904 wxASSERT_MSG( 1 , "unkown path beginning" ) ;
908 if (*s
== '/' || *s
== '\\')
910 // convert any back-directory situations
911 if ( *(s
+1) == '.' && *(s
+2) == '.' && ( (*(s
+3) == '/' || *(s
+3) == '\\') ) )
914 memmove( s
+1 , s
+3 ,strlen( s
+3 ) + 1 ) ;
923 return wxString (sMacFileNameConversion
) ;
926 wxString
wxMacFSSpec2UnixFilename( const FSSpec
*spec
)
928 return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec
) ) ;
931 void wxUnixFilename2FSSpec( const char *path
, FSSpec
*spec
)
933 wxString var
= wxUnix2MacFilename( path
) ;
934 wxMacFilename2FSSpec( var
, spec
) ;
939 wxDos2UnixFilename (char *s
)
948 *s
= wxTolower (*s
); // Case INDEPENDENT
955 #if defined(__WXMSW__) || defined(__WXPM__)
956 wxUnix2DosFilename (wxChar
*s
)
958 wxUnix2DosFilename (wxChar
*WXUNUSED(s
) )
961 // Yes, I really mean this to happen under DOS only! JACS
962 #if defined(__WXMSW__) || defined(__WXPM__)
973 // Concatenate two files to form third
975 wxConcatFiles (const wxString
& file1
, const wxString
& file2
, const wxString
& file3
)
978 if ( !wxGetTempFileName("cat", outfile
) )
981 FILE *fp1
= (FILE *) NULL
;
982 FILE *fp2
= (FILE *) NULL
;
983 FILE *fp3
= (FILE *) NULL
;
984 // Open the inputs and outputs
985 if ((fp1
= wxFopen (OS_FILENAME( file1
), wxT("rb"))) == NULL
||
986 (fp2
= wxFopen (OS_FILENAME( file2
), wxT("rb"))) == NULL
||
987 (fp3
= wxFopen (OS_FILENAME( outfile
), wxT("wb"))) == NULL
)
999 while ((ch
= getc (fp1
)) != EOF
)
1000 (void) putc (ch
, fp3
);
1003 while ((ch
= getc (fp2
)) != EOF
)
1004 (void) putc (ch
, fp3
);
1008 bool result
= wxRenameFile(outfile
, file3
);
1014 wxCopyFile (const wxString
& file1
, const wxString
& file2
, bool overwrite
)
1016 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
1017 // CopyFile() copies file attributes and modification time too, so use it
1018 // instead of our code if available
1020 // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
1021 return ::CopyFile(file1
, file2
, !overwrite
) != 0;
1022 #elif defined(__WXPM__)
1023 if (::DosCopy(file2
, file2
, overwrite
? DCPY_EXISTING
: 0) == 0)
1030 // get permissions of file1
1031 if ( wxStat(OS_FILENAME(file1
), &fbuf
) != 0 )
1033 // the file probably doesn't exist or we haven't the rights to read
1035 wxLogSysError(_("Impossible to get permissions for file '%s'"),
1040 // open file1 for reading
1041 wxFile
fileIn(file1
, wxFile::read
);
1042 if ( !fileIn
.IsOpened() )
1045 // remove file2, if it exists. This is needed for creating
1046 // file2 with the correct permissions in the next step
1047 if ( wxFileExists(file2
) && (!overwrite
|| !wxRemoveFile(file2
)))
1049 wxLogSysError(_("Impossible to overwrite the file '%s'"),
1055 // reset the umask as we want to create the file with exactly the same
1056 // permissions as the original one
1057 mode_t oldUmask
= umask( 0 );
1060 // create file2 with the same permissions than file1 and open it for
1063 if ( !fileOut
.Create(file2
, overwrite
, fbuf
.st_mode
& 0777) )
1067 /// restore the old umask
1071 // copy contents of file1 to file2
1076 count
= fileIn
.Read(buf
, WXSIZEOF(buf
));
1077 if ( fileIn
.Error() )
1084 if ( fileOut
.Write(buf
, count
) < count
)
1088 // we can expect fileIn to be closed successfully, but we should ensure
1089 // that fileOut was closed as some write errors (disk full) might not be
1090 // detected before doing this
1091 if ( !fileIn
.Close() || !fileOut
.Close() )
1094 #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
1095 // no chmod in VA. Should be some permission API for HPFS386 partitions
1097 if ( chmod(OS_FILENAME(file2
), fbuf
.st_mode
) != 0 )
1099 wxLogSysError(_("Impossible to set permissions for the file '%s'"),
1103 #endif // OS/2 || Mac
1106 #endif // __WXMSW__ && __WIN32__
1110 wxRenameFile (const wxString
& file1
, const wxString
& file2
)
1112 // Normal system call
1113 if ( wxRename (file1
, file2
) == 0 )
1117 if (wxCopyFile(file1
, file2
)) {
1118 wxRemoveFile(file1
);
1125 bool wxRemoveFile(const wxString
& file
)
1127 #if defined(__VISUALC__) \
1128 || defined(__BORLANDC__) \
1129 || defined(__WATCOMC__) \
1130 || defined(__GNUWIN32__)
1131 int res
= wxRemove(file
);
1133 int res
= unlink(OS_FILENAME(file
));
1139 bool wxMkdir(const wxString
& dir
, int perm
)
1141 #if defined(__WXMAC__) && !defined(__UNIX__)
1142 return (mkdir( dir
, 0 ) == 0);
1144 const wxChar
*dirname
= dir
.c_str();
1146 // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
1147 // for the GNU compiler
1148 #if (!(defined(__WXMSW__) || defined(__WXPM__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__) || defined(__WXMICROWIN__)
1149 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1150 #elif defined(__WXPM__)
1151 if (::DosCreateDir((PSZ
)dirname
, NULL
) != 0) // enhance for EAB's??
1152 #else // !MSW and !OS/2 VAC++
1154 if ( wxMkDir(wxFNSTRINGCAST
wxFNCONV(dirname
)) != 0 )
1157 wxLogSysError(_("Directory '%s' couldn't be created"), dirname
);
1166 bool wxRmdir(const wxString
& dir
, int WXUNUSED(flags
))
1169 return FALSE
; //to be changed since rmdir exists in VMS7.x
1170 #elif defined(__WXPM__)
1171 return (::DosDeleteDir((PSZ
)dir
.c_str()) == 0);
1175 return FALSE
; // What to do?
1177 return (wxRmDir(OS_FILENAME(dir
)) == 0);
1183 // does the path exists? (may have or not '/' or '\\' at the end)
1184 bool wxPathExists(const wxChar
*pszPathName
)
1186 wxString
strPath(pszPathName
);
1188 // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
1189 // so remove all trailing backslashes from the path - but don't do this for
1190 // the pathes "d:\" (which are different from "d:") nor for just "\"
1191 while ( wxEndsWithPathSeparator(strPath
) )
1193 size_t len
= strPath
.length();
1194 if ( len
== 1 || (len
== 3 && strPath
[len
- 2] == _T(':')) )
1197 strPath
.Truncate(len
- 1);
1199 #endif // __WINDOWS__
1202 // Stat can't cope with network paths
1203 DWORD ret
= GetFileAttributes(strPath
.c_str());
1204 DWORD isDir
= (ret
& FILE_ATTRIBUTE_DIRECTORY
);
1205 return ((ret
!= 0xffffffff) && (isDir
!= 0));
1209 #ifndef __VISAGECPP__
1210 return wxStat(wxFNSTRINGCAST strPath
.fn_str(), &st
) == 0 &&
1211 ((st
.st_mode
& S_IFMT
) == S_IFDIR
);
1213 // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
1214 return wxStat(wxFNSTRINGCAST strPath
.fn_str(), &st
) == 0 &&
1215 (st
.st_mode
== S_IFDIR
);
1221 // Get a temporary filename, opening and closing the file.
1222 wxChar
*wxGetTempFileName(const wxString
& prefix
, wxChar
*buf
)
1224 #if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
1228 ::GetTempFileName(0, WXSTRINGCAST prefix
, 0, tmp
);
1230 wxChar tmp
[MAX_PATH
];
1231 wxChar tmpPath
[MAX_PATH
];
1232 ::GetTempPath(MAX_PATH
, tmpPath
);
1233 ::GetTempFileName(tmpPath
, WXSTRINGCAST prefix
, 0, tmp
);
1235 if (buf
) wxStrcpy(buf
, tmp
);
1236 else buf
= copystring(tmp
);
1240 static short last_temp
= 0; // cache last to speed things a bit
1241 // At most 1000 temp files to a process! We use a ring count.
1242 wxChar tmp
[100]; // FIXME static buffer
1244 for (short suffix
= last_temp
+ 1; suffix
!= last_temp
; ++suffix
%= 1000)
1246 wxSprintf (tmp
, wxT("/tmp/%s%d.%03x"), WXSTRINGCAST prefix
, (int) getpid (), (int) suffix
);
1247 if (!wxFileExists( tmp
))
1249 // Touch the file to create it (reserve name)
1250 FILE *fd
= fopen (wxFNCONV(tmp
), "w");
1255 wxStrcpy( buf
, tmp
);
1257 buf
= copystring( tmp
);
1261 wxLogError( _("wxWindows: error finding temporary file name.\n") );
1262 if (buf
) buf
[0] = 0;
1263 return (wxChar
*) NULL
;
1267 bool wxGetTempFileName(const wxString
& prefix
, wxString
& buf
)
1270 if (wxGetTempFileName(prefix
, buf2
) != (wxChar
*) NULL
)
1279 // Get first file name matching given wild card.
1283 // Get first file name matching given wild card.
1284 // Flags are reserved for future use.
1286 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1287 static DIR *gs_dirStream
= (DIR *) NULL
;
1288 static wxString gs_strFileSpec
;
1289 static int gs_findFlags
= 0;
1292 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1296 wxChar
*specvms
= NULL
;
1299 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1301 closedir(gs_dirStream
); // edz 941103: better housekeping
1303 gs_findFlags
= flags
;
1305 gs_strFileSpec
= spec
;
1307 // Find path only so we can concatenate
1308 // found file onto path
1309 wxString
path(wxPathOnly(gs_strFileSpec
));
1311 // special case: path is really "/"
1312 if ( !path
&& gs_strFileSpec
[0u] == wxT('/') )
1315 wxStrcpy( specvms
, wxT( "[000000]" ) );
1316 gs_strFileSpec
= specvms
;
1317 wxString
path_vms(wxPathOnly(gs_strFileSpec
));
1323 // path is empty => Local directory
1327 wxStrcpy( specvms
, wxT( "[]" ) );
1328 gs_strFileSpec
= specvms
;
1329 wxString
path_vms1(wxPathOnly(gs_strFileSpec
));
1336 gs_dirStream
= opendir(path
.fn_str());
1337 if ( !gs_dirStream
)
1339 wxLogSysError(_("Can not enumerate files in directory '%s'"),
1344 result
= wxFindNextFile();
1346 #endif // !VMS6.x or earlier
1351 wxString
wxFindNextFile()
1355 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1356 wxCHECK_MSG( gs_dirStream
, result
, wxT("must call wxFindFirstFile first") );
1358 // Find path only so we can concatenate
1359 // found file onto path
1360 wxString
path(wxPathOnly(gs_strFileSpec
));
1361 wxString
name(wxFileNameFromPath(gs_strFileSpec
));
1363 /* MATTHEW: special case: path is really "/" */
1364 if ( !path
&& gs_strFileSpec
[0u] == wxT('/'))
1368 struct dirent
*nextDir
;
1369 for ( nextDir
= readdir(gs_dirStream
);
1371 nextDir
= readdir(gs_dirStream
) )
1373 if (wxMatchWild(name
, nextDir
->d_name
, FALSE
) && // RR: added FALSE to find hidden files
1374 strcmp(nextDir
->d_name
, ".") &&
1375 strcmp(nextDir
->d_name
, "..") )
1378 if ( !path
.IsEmpty() )
1381 if ( path
!= wxT('/') )
1385 result
+= nextDir
->d_name
;
1387 // Only return "." and ".." when they match
1389 if ( (strcmp(nextDir
->d_name
, ".") == 0) ||
1390 (strcmp(nextDir
->d_name
, "..") == 0))
1392 if ( (gs_findFlags
& wxDIR
) != 0 )
1398 isdir
= wxDirExists(result
);
1400 // and only return directories when flags & wxDIR
1401 if ( !gs_findFlags
||
1402 ((gs_findFlags
& wxDIR
) && isdir
) ||
1403 ((gs_findFlags
& wxFILE
) && !isdir
) )
1410 result
.Empty(); // not found
1412 closedir(gs_dirStream
);
1413 gs_dirStream
= (DIR *) NULL
;
1414 #endif // !VMS6.2 or earlier
1419 #elif defined(__WXMAC__)
1421 struct MacDirectoryIterator
1429 static int g_iter_flags
;
1431 static MacDirectoryIterator g_iter
;
1433 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1437 g_iter_flags
= flags
; /* MATTHEW: [5] Remember flags */
1439 // Find path only so we can concatenate found file onto path
1440 wxString
path(wxPathOnly(spec
));
1441 if ( !path
.IsEmpty() )
1442 result
<< path
<< wxT('\\');
1446 wxMacFilename2FSSpec( result
, &fsspec
) ;
1447 g_iter
.m_CPB
.hFileInfo
.ioVRefNum
= fsspec
.vRefNum
;
1448 g_iter
.m_CPB
.hFileInfo
.ioNamePtr
= g_iter
.m_name
;
1449 g_iter
.m_index
= 0 ;
1452 FSpGetDirectoryID( &fsspec
, &g_iter
.m_dirId
, &isDir
) ;
1454 return wxEmptyString
;
1456 return wxFindNextFile( ) ;
1459 wxString
wxFindNextFile()
1465 while ( err
== noErr
)
1468 g_iter
.m_CPB
.dirInfo
.ioFDirIndex
= g_iter
.m_index
;
1469 g_iter
.m_CPB
.dirInfo
.ioDrDirID
= g_iter
.m_dirId
; /* we need to do this every time */
1470 err
= PBGetCatInfoSync((CInfoPBPtr
)&g_iter
.m_CPB
);
1474 if ( ( g_iter
.m_CPB
.dirInfo
.ioFlAttrib
& ioDirMask
) != 0 && (g_iter_flags
& wxDIR
) ) // we have a directory
1477 if ( ( g_iter
.m_CPB
.dirInfo
.ioFlAttrib
& ioDirMask
) == 0 && !(g_iter_flags
& wxFILE
) )
1485 return wxEmptyString
;
1489 FSMakeFSSpecCompat(g_iter
.m_CPB
.hFileInfo
.ioVRefNum
,
1494 return wxMacFSSpec2MacFilename( &spec
) ;
1497 #elif defined(__WXMSW__)
1500 static HANDLE gs_hFileStruct
= INVALID_HANDLE_VALUE
;
1501 static WIN32_FIND_DATA gs_findDataStruct
;
1504 static struct ffblk gs_findDataStruct
;
1506 static struct _find_t gs_findDataStruct
;
1510 static wxString gs_strFileSpec
;
1511 static int gs_findFlags
= 0;
1513 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1517 gs_strFileSpec
= spec
;
1518 gs_findFlags
= flags
; /* MATTHEW: [5] Remember flags */
1520 // Find path only so we can concatenate found file onto path
1521 wxString
path(wxPathOnly(gs_strFileSpec
));
1522 if ( !path
.IsEmpty() )
1523 result
<< path
<< wxT('\\');
1526 if ( gs_hFileStruct
!= INVALID_HANDLE_VALUE
)
1527 FindClose(gs_hFileStruct
);
1529 gs_hFileStruct
= ::FindFirstFile(WXSTRINGCAST spec
, &gs_findDataStruct
);
1531 if ( gs_hFileStruct
== INVALID_HANDLE_VALUE
)
1538 bool isdir
= !!(gs_findDataStruct
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
);
1540 if (isdir
&& !(flags
& wxDIR
))
1541 return wxFindNextFile();
1542 else if (!isdir
&& flags
&& !(flags
& wxFILE
))
1543 return wxFindNextFile();
1545 result
+= gs_findDataStruct
.cFileName
;
1549 int flag
= _A_NORMAL
;
1554 if (findfirst(WXSTRINGCAST spec
, &gs_findDataStruct
, flag
) == 0)
1556 if (_dos_findfirst(WXSTRINGCAST spec
, flag
, &gs_findDataStruct
) == 0)
1562 attrib
= gs_findDataStruct
.ff_attrib
;
1564 attrib
= gs_findDataStruct
.attrib
;
1567 if (attrib
& _A_SUBDIR
) {
1568 if (!(gs_findFlags
& wxDIR
))
1569 return wxFindNextFile();
1570 } else if (gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1571 return wxFindNextFile();
1575 gs_findDataStruct
.ff_name
1577 gs_findDataStruct
.name
1587 wxString
wxFindNextFile()
1591 // Find path only so we can concatenate found file onto path
1592 wxString
path(wxPathOnly(gs_strFileSpec
));
1597 if (gs_hFileStruct
== INVALID_HANDLE_VALUE
)
1600 bool success
= (FindNextFile(gs_hFileStruct
, &gs_findDataStruct
) != 0);
1603 FindClose(gs_hFileStruct
);
1604 gs_hFileStruct
= INVALID_HANDLE_VALUE
;
1608 bool isdir
= !!(gs_findDataStruct
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
);
1610 if (isdir
&& !(gs_findFlags
& wxDIR
))
1612 else if (!isdir
&& gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1615 if ( !path
.IsEmpty() )
1616 result
<< path
<< wxT('\\');
1617 result
<< gs_findDataStruct
.cFileName
;
1624 if (findnext(&gs_findDataStruct
) == 0)
1626 if (_dos_findnext(&gs_findDataStruct
) == 0)
1629 /* MATTHEW: [5] Check directory flag */
1633 attrib
= gs_findDataStruct
.ff_attrib
;
1635 attrib
= gs_findDataStruct
.attrib
;
1638 if (attrib
& _A_SUBDIR
) {
1639 if (!(gs_findFlags
& wxDIR
))
1641 } else if (gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1647 gs_findDataStruct
.ff_name
1649 gs_findDataStruct
.name
1658 #elif defined(__WXPM__)
1660 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1665 // TODO: figure something out here for OS/2
1666 gs_strFileSpec = spec;
1667 gs_findFlags = flags;
1669 // Find path only so we can concatenate found file onto path
1670 wxString path(wxPathOnly(gs_strFileSpec));
1671 if ( !path.IsEmpty() )
1672 result << path << wxT('\\');
1674 int flag = _A_NORMAL;
1678 if (_dos_findfirst(WXSTRINGCAST spec, flag, &gs_findDataStruct) == 0)
1681 attrib = gs_findDataStruct.attrib;
1683 if (attrib & _A_SUBDIR) {
1684 if (!(gs_findFlags & wxDIR))
1685 return wxFindNextFile();
1686 } else if (gs_findFlags && !(gs_findFlags & wxFILE))
1687 return wxFindNextFile();
1689 result += gs_findDataStruct.name;
1695 wxString
wxFindNextFile()
1702 #endif // Unix/Windows/OS/2
1704 // Get current working directory.
1705 // If buf is NULL, allocates space using new, else
1707 wxChar
*wxGetWorkingDirectory(wxChar
*buf
, int sz
)
1710 buf
= new wxChar
[sz
+1];
1712 char *cbuf
= new char[sz
+1];
1714 if (_getcwd(cbuf
, sz
) == NULL
) {
1715 #elif defined(__WXMAC__)
1718 SFSaveDisk
= 0x214, CurDirStore
= 0x398
1722 FSMakeFSSpec( - *(short *) SFSaveDisk
, *(long *) CurDirStore
, NULL
, &cwdSpec
) ;
1723 wxString res
= wxMacFSSpec2UnixFilename( &cwdSpec
) ;
1724 strcpy( buf
, res
) ;
1727 if (getcwd(cbuf
, sz
) == NULL
) {
1732 if (_getcwd(buf
, sz
) == NULL
) {
1733 #elif defined(__WXMAC__) && !defined(__UNIX__)
1738 pb
.ioNamePtr
= (StringPtr
) &fileName
;
1740 pb
.ioRefNum
= LMGetCurApRefNum();
1742 error
= PBGetFCBInfoSync(&pb
);
1743 if ( error
== noErr
)
1745 cwdSpec
.vRefNum
= pb
.ioFCBVRefNum
;
1746 cwdSpec
.parID
= pb
.ioFCBParID
;
1747 cwdSpec
.name
[0] = 0 ;
1748 wxString res
= wxMacFSSpec2MacFilename( &cwdSpec
) ;
1750 strcpy( buf
, res
) ;
1751 buf
[res
.length()]=0 ;
1756 this version will not always give back the application directory on mac
1759 SFSaveDisk = 0x214, CurDirStore = 0x398
1763 FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
1764 wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
1765 strcpy( buf , res ) ;
1768 #elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
1770 rc
= ::DosQueryCurrentDir( 0 // current drive
1776 if (getcwd(buf
, sz
) == NULL
) {
1784 wxConvFile
.MB2WC(buf
, cbuf
, sz
);
1793 static const size_t maxPathLen
= 1024;
1796 wxGetWorkingDirectory(str
.GetWriteBuf(maxPathLen
), maxPathLen
);
1797 str
.UngetWriteBuf();
1802 bool wxSetWorkingDirectory(const wxString
& d
)
1804 #if defined( __UNIX__ ) || defined( __WXMAC__ )
1805 return (chdir(wxFNSTRINGCAST d
.fn_str()) == 0);
1806 #elif defined(__WXPM__)
1807 return (::DosSetCurrentDir((PSZ
)d
.c_str()) == 0);
1808 #elif defined(__WINDOWS__)
1811 return (bool)(SetCurrentDirectory(d
) != 0);
1813 // Must change drive, too.
1814 bool isDriveSpec
= ((strlen(d
) > 1) && (d
[1] == ':'));
1817 wxChar firstChar
= d
[0];
1821 firstChar
= firstChar
- 32;
1823 // To a drive number
1824 unsigned int driveNo
= firstChar
- 64;
1827 unsigned int noDrives
;
1828 _dos_setdrive(driveNo
, &noDrives
);
1831 bool success
= (chdir(WXSTRINGCAST d
) == 0);
1839 // Get the OS directory if appropriate (such as the Windows directory).
1840 // On non-Windows platform, probably just return the empty string.
1841 wxString
wxGetOSDirectory()
1843 #if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
1845 GetWindowsDirectory(buf
, 256);
1846 return wxString(buf
);
1848 return wxEmptyString
;
1852 bool wxEndsWithPathSeparator(const wxChar
*pszFileName
)
1854 size_t len
= wxStrlen(pszFileName
);
1858 return wxIsPathSeparator(pszFileName
[len
- 1]);
1861 // find a file in a list of directories, returns false if not found
1862 bool wxFindFileInPath(wxString
*pStr
, const wxChar
*pszPath
, const wxChar
*pszFile
)
1864 // we assume that it's not empty
1865 wxCHECK_MSG( !wxIsEmpty(pszFile
), FALSE
,
1866 _T("empty file name in wxFindFileInPath"));
1868 // skip path separator in the beginning of the file name if present
1869 if ( wxIsPathSeparator(*pszFile
) )
1872 // copy the path (strtok will modify it)
1873 wxChar
*szPath
= new wxChar
[wxStrlen(pszPath
) + 1];
1874 wxStrcpy(szPath
, pszPath
);
1877 wxChar
*pc
, *save_ptr
;
1878 for ( pc
= wxStrtok(szPath
, wxPATH_SEP
, &save_ptr
);
1880 pc
= wxStrtok((wxChar
*) NULL
, wxPATH_SEP
, &save_ptr
) )
1882 // search for the file in this directory
1884 if ( !wxEndsWithPathSeparator(pc
) )
1885 strFile
+= wxFILE_SEP_PATH
;
1888 if ( FileExists(strFile
) ) {
1894 // suppress warning about unused variable save_ptr when wxStrtok() is a
1895 // macro which throws away its third argument
1900 return pc
!= NULL
; // if true => we breaked from the loop
1903 void WXDLLEXPORT
wxSplitPath(const wxChar
*pszFileName
,
1908 // it can be empty, but it shouldn't be NULL
1909 wxCHECK_RET( pszFileName
, wxT("NULL file name in wxSplitPath") );
1911 wxFileName::SplitPath(pszFileName
, pstrPath
, pstrName
, pstrExt
);
1914 time_t WXDLLEXPORT
wxFileModificationTime(const wxString
& filename
)
1918 wxStat(filename
.fn_str(), &buf
);
1919 return buf
.st_mtime
;
1923 //------------------------------------------------------------------------
1924 // wild character routines
1925 //------------------------------------------------------------------------
1927 bool wxIsWild( const wxString
& pattern
)
1929 wxString tmp
= pattern
;
1930 wxChar
*pat
= WXSTRINGCAST(tmp
);
1933 case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
1943 bool wxMatchWild( const wxString
& pat
, const wxString
& text
, bool dot_special
)
1945 #if defined(HAVE_FNMATCH_H)
1947 // this probably won't work well for multibyte chars in Unicode mode?
1949 return fnmatch(pat
.fn_str(), text
.fn_str(), FNM_PERIOD
) == 0;
1951 return fnmatch(pat
.fn_str(), text
.fn_str(), 0) == 0;
1955 // #pragma error Broken implementation of wxMatchWild() -- needs fixing!
1958 * WARNING: this code is broken!
1961 wxString tmp1
= pat
;
1962 wxChar
*pattern
= WXSTRINGCAST(tmp1
);
1963 wxString tmp2
= text
;
1964 wxChar
*str
= WXSTRINGCAST(tmp2
);
1967 bool done
= FALSE
, ret_code
, ok
;
1968 // Below is for vi fans
1969 const wxChar OB
= wxT('{'), CB
= wxT('}');
1971 // dot_special means '.' only matches '.'
1972 if (dot_special
&& *str
== wxT('.') && *pattern
!= *str
)
1975 while ((*pattern
!= wxT('\0')) && (!done
)
1976 && (((*str
==wxT('\0'))&&((*pattern
==OB
)||(*pattern
==wxT('*'))))||(*str
!=wxT('\0')))) {
1980 if (*pattern
!= wxT('\0'))
1986 while ((*str
!=wxT('\0'))
1987 && ((ret_code
=wxMatchWild(pattern
, str
++, FALSE
)) == 0))
1990 while (*str
!= wxT('\0'))
1992 while (*pattern
!= wxT('\0'))
1999 if ((*pattern
== wxT('\0')) || (*pattern
== wxT(']'))) {
2003 if (*pattern
== wxT('\\')) {
2005 if (*pattern
== wxT('\0')) {
2010 if (*(pattern
+ 1) == wxT('-')) {
2013 if (*pattern
== wxT(']')) {
2017 if (*pattern
== wxT('\\')) {
2019 if (*pattern
== wxT('\0')) {
2024 if ((*str
< c
) || (*str
> *pattern
)) {
2028 } else if (*pattern
!= *str
) {
2033 while ((*pattern
!= wxT(']')) && (*pattern
!= wxT('\0'))) {
2034 if ((*pattern
== wxT('\\')) && (*(pattern
+ 1) != wxT('\0')))
2038 if (*pattern
!= wxT('\0')) {
2048 while ((*pattern
!= CB
) && (*pattern
!= wxT('\0'))) {
2051 while (ok
&& (*cp
!= wxT('\0')) && (*pattern
!= wxT('\0'))
2052 && (*pattern
!= wxT(',')) && (*pattern
!= CB
)) {
2053 if (*pattern
== wxT('\\'))
2055 ok
= (*pattern
++ == *cp
++);
2057 if (*pattern
== wxT('\0')) {
2063 while ((*pattern
!= CB
) && (*pattern
!= wxT('\0'))) {
2064 if (*++pattern
== wxT('\\')) {
2065 if (*++pattern
== CB
)
2070 while (*pattern
!=CB
&& *pattern
!=wxT(',') && *pattern
!=wxT('\0')) {
2071 if (*++pattern
== wxT('\\')) {
2072 if (*++pattern
== CB
|| *pattern
== wxT(','))
2077 if (*pattern
!= wxT('\0'))
2082 if (*str
== *pattern
) {
2089 while (*pattern
== wxT('*'))
2091 return ((*str
== wxT('\0')) && (*pattern
== wxT('\0')));
2097 #pragma warning(default:4706) // assignment within conditional expression