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 // there are just too many of those...
37 #pragma warning(disable:4706) // assignment within conditional expression
44 #if !defined(__WATCOMC__)
45 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
53 #include <sys/types.h>
67 #include "wx/os2/private.h"
70 #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
74 #endif // native Win compiler
78 #include <sys/unistd.h>
82 #ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
83 // this (3.1 I believe) and how to test for it.
84 // If this works for Borland 4.0 as well, then no worries.
96 // No, Cygwin doesn't appear to have fnmatch.h after all.
97 #if defined(HAVE_FNMATCH_H)
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 #define _MAXPATHLEN 500
111 extern wxChar
*wxBuffer
;
115 #include "morefile.h"
116 #include "moreextr.h"
117 #include "fullpath.h"
118 #include "fspcompa.h"
121 IMPLEMENT_DYNAMIC_CLASS(wxPathList
, wxStringList
)
123 // ----------------------------------------------------------------------------
125 // ----------------------------------------------------------------------------
127 static wxChar wxFileFunctionsBuffer
[4*_MAXPATHLEN
];
129 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
131 // VisualAge C++ V4.0 cannot have any external linkage const decs
132 // in headers included by more than one primary source
134 const off_t wxInvalidOffset
= (off_t
)-1;
137 // ============================================================================
139 // ============================================================================
141 void wxPathList::Add (const wxString
& path
)
143 wxStringList::Add (WXSTRINGCAST path
);
146 // Add paths e.g. from the PATH environment variable
147 void wxPathList::AddEnvList (const wxString
& envVariable
)
149 static const wxChar PATH_TOKS
[] =
151 wxT(" ;"); // Don't seperate with colon in DOS (used for drive)
156 wxChar
*val
= wxGetenv (WXSTRINGCAST envVariable
);
159 wxChar
*s
= copystring (val
);
160 wxChar
*save_ptr
, *token
= wxStrtok (s
, PATH_TOKS
, &save_ptr
);
164 Add (copystring (token
));
167 if ((token
= wxStrtok ((wxChar
*) NULL
, PATH_TOKS
, &save_ptr
)) != NULL
)
168 Add (wxString(token
));
172 // suppress warning about unused variable save_ptr when wxStrtok() is a
173 // macro which throws away its third argument
180 // Given a full filename (with path), ensure that that file can
181 // be accessed again USING FILENAME ONLY by adding the path
182 // to the list if not already there.
183 void wxPathList::EnsureFileAccessible (const wxString
& path
)
185 wxString
path_only(wxPathOnly(path
));
186 if ( !path_only
.IsEmpty() )
188 if ( !Member(path_only
) )
193 bool wxPathList::Member (const wxString
& path
)
195 for (wxNode
* node
= First (); node
!= NULL
; node
= node
->Next ())
197 wxString
path2((wxChar
*) node
->Data ());
199 #if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__)
201 path
.CompareTo (path2
, wxString::ignoreCase
) == 0
203 // Case sensitive File System
204 path
.CompareTo (path2
) == 0
212 wxString
wxPathList::FindValidPath (const wxString
& file
)
214 if (wxFileExists (wxExpandPath(wxFileFunctionsBuffer
, file
)))
215 return wxString(wxFileFunctionsBuffer
);
217 wxChar buf
[_MAXPATHLEN
];
218 wxStrcpy(buf
, wxFileFunctionsBuffer
);
220 wxChar
*filename
= (wxChar
*) NULL
; /* shut up buggy egcs warning */
221 filename
= IsAbsolutePath (buf
) ? wxFileNameFromPath (buf
) : (wxChar
*)buf
;
223 for (wxNode
* node
= First (); node
; node
= node
->Next ())
225 wxChar
*path
= (wxChar
*) node
->Data ();
226 wxStrcpy (wxFileFunctionsBuffer
, path
);
227 wxChar ch
= wxFileFunctionsBuffer
[wxStrlen(wxFileFunctionsBuffer
)-1];
228 if (ch
!= wxT('\\') && ch
!= wxT('/'))
229 wxStrcat (wxFileFunctionsBuffer
, wxT("/"));
230 wxStrcat (wxFileFunctionsBuffer
, filename
);
232 Unix2DosFilename (wxFileFunctionsBuffer
);
234 if (wxFileExists (wxFileFunctionsBuffer
))
236 return wxString(wxFileFunctionsBuffer
); // Found!
240 return wxString(wxT("")); // Not found
243 wxString
wxPathList::FindAbsoluteValidPath (const wxString
& file
)
245 wxString f
= FindValidPath(file
);
246 if ( wxIsAbsolutePath(f
) )
250 wxGetWorkingDirectory(buf
.GetWriteBuf(_MAXPATHLEN
), _MAXPATHLEN
- 1);
252 if ( !wxEndsWithPathSeparator(buf
) )
254 buf
+= wxFILE_SEP_PATH
;
262 wxFileExists (const wxString
& filename
)
264 #ifdef __GNUWIN32__ // (fix a B20 bug)
265 if (GetFileAttributes(filename
) == 0xFFFFFFFF)
269 #elif defined(__WXMAC__)
271 if (filename
&& stat (wxUnix2MacFilename(filename
), &stbuf
) == 0 )
277 if ((filename
!= wxT("")) && wxStat (wxFNSTRINGCAST filename
.fn_str(), &stbuf
) == 0)
284 /* Vadim's alternative implementation
286 // does the file exist?
287 bool wxFileExists(const char *pszFileName)
290 return !access(pszFileName, 0) &&
291 !stat(pszFileName, &st) &&
292 (st.st_mode & S_IFREG);
297 wxIsAbsolutePath (const wxString
& filename
)
299 if (filename
!= wxT(""))
301 if (filename
[0] == wxT('/')
303 || (filename
[0] == wxT('[') && filename
[1] != wxT('.'))
307 || filename
[0] == wxT('\\') || (wxIsalpha (filename
[0]) && filename
[1] == wxT(':'))
316 * Strip off any extension (dot something) from end of file,
317 * IF one exists. Inserts zero into buffer.
321 void wxStripExtension(wxChar
*buffer
)
323 int len
= wxStrlen(buffer
);
327 if (buffer
[i
] == wxT('.'))
336 void wxStripExtension(wxString
& buffer
)
338 size_t len
= buffer
.Length();
342 if (buffer
.GetChar(i
) == wxT('.'))
344 buffer
= buffer
.Left(i
);
351 // Destructive removal of /./ and /../ stuff
352 wxChar
*wxRealPath (wxChar
*path
)
355 static const wxChar SEP
= wxT('\\');
356 Unix2DosFilename(path
);
358 static const wxChar SEP
= wxT('/');
360 if (path
[0] && path
[1]) {
361 /* MATTHEW: special case "/./x" */
363 if (path
[2] == SEP
&& path
[1] == wxT('.'))
371 if (p
[1] == wxT('.') && p
[2] == wxT('.') && (p
[3] == SEP
|| p
[3] == wxT('\0')))
374 for (q
= p
- 1; q
>= path
&& *q
!= SEP
; q
--);
375 if (q
[0] == SEP
&& (q
[1] != wxT('.') || q
[2] != wxT('.') || q
[3] != SEP
)
376 && (q
- 1 <= path
|| q
[-1] != SEP
))
379 if (path
[0] == wxT('\0'))
385 /* Check that path[2] is NULL! */
386 else if (path
[1] == wxT(':') && !path
[2])
395 else if (p
[1] == wxT('.') && (p
[2] == SEP
|| p
[2] == wxT('\0')))
404 wxChar
*wxCopyAbsolutePath(const wxString
& filename
)
406 if (filename
== wxT(""))
407 return (wxChar
*) NULL
;
409 if (! IsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer
, filename
))) {
410 wxChar buf
[_MAXPATHLEN
];
412 wxGetWorkingDirectory(buf
, WXSIZEOF(buf
));
413 wxChar ch
= buf
[wxStrlen(buf
) - 1];
415 if (ch
!= wxT('\\') && ch
!= wxT('/'))
416 wxStrcat(buf
, wxT("\\"));
419 wxStrcat(buf
, wxT("/"));
421 wxStrcat(buf
, wxFileFunctionsBuffer
);
422 return copystring( wxRealPath(buf
) );
424 return copystring( wxFileFunctionsBuffer
);
430 ~user/ => user's home dir
431 If the environment variable a = "foo" and b = "bar" then:
448 /* input name in name, pathname output to buf. */
450 wxChar
*wxExpandPath(wxChar
*buf
, const wxChar
*name
)
452 register wxChar
*d
, *s
, *nm
;
453 wxChar lnm
[_MAXPATHLEN
];
456 // Some compilers don't like this line.
457 // const wxChar trimchars[] = wxT("\n \t");
460 trimchars
[0] = wxT('\n');
461 trimchars
[1] = wxT(' ');
462 trimchars
[2] = wxT('\t');
466 const wxChar SEP
= wxT('\\');
468 const wxChar SEP
= wxT('/');
471 if (name
== NULL
|| *name
== wxT('\0'))
473 nm
= copystring(name
); // Make a scratch copy
476 /* Skip leading whitespace and cr */
477 while (wxStrchr((wxChar
*)trimchars
, *nm
) != NULL
)
479 /* And strip off trailing whitespace and cr */
480 s
= nm
+ (q
= wxStrlen(nm
)) - 1;
481 while (q
-- && wxStrchr((wxChar
*)trimchars
, *s
) != NULL
)
489 q
= nm
[0] == wxT('\\') && nm
[1] == wxT('~');
492 /* Expand inline environment variables */
510 while ((*d
++ = *s
)) {
512 if (*s
== wxT('\\')) {
513 if ((*(d
- 1) = *++s
)) {
522 if (*s
++ == wxT('$') && (*s
== wxT('{') || *s
== wxT(')')))
524 if (*s
++ == wxT('$'))
527 register wxChar
*start
= d
;
528 register int braces
= (*s
== wxT('{') || *s
== wxT('('));
529 register wxChar
*value
;
531 // VA gives assignment in logical expr warning
537 if (braces
? (*s
== wxT('}') || *s
== wxT(')')) : !(wxIsalnum(*s
) || *s
== wxT('_')) )
542 value
= wxGetenv(braces
? start
+ 1 : start
);
545 // VA gives assignment in logical expr warning
546 for ((d
= start
- 1); (*d
); *d
++ = *value
++);
548 for ((d
= start
- 1); (*d
++ = *value
++););
557 /* Expand ~ and ~user */
560 if (nm
[0] == wxT('~') && !q
)
563 if (nm
[1] == SEP
|| nm
[1] == 0)
565 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
566 if ((s
= WXSTRINGCAST
wxGetUserHome(wxT(""))) != NULL
) {
571 { /* ~user/filename */
572 register wxChar
*nnm
;
573 register wxChar
*home
;
574 for (s
= nm
; *s
&& *s
!= SEP
; s
++);
575 int was_sep
; /* MATTHEW: Was there a separator, or NULL? */
576 was_sep
= (*s
== SEP
);
577 nnm
= *s
? s
+ 1 : s
;
579 // FIXME: wxGetUserHome could return temporary storage in Unicode mode
580 if ((home
= WXSTRINGCAST
wxGetUserHome(wxString(nm
+ 1))) == NULL
) {
581 if (was_sep
) /* replace only if it was there: */
592 if (s
&& *s
) { /* MATTHEW: s could be NULL if user '~' didn't exist */
594 while (wxT('\0') != (*d
++ = *s
++))
597 if (d
- 1 > buf
&& *(d
- 2) != SEP
)
602 // VA gives assignment in logical expr warning
606 while ((*d
++ = *s
++));
608 delete[] nm_tmp
; // clean up alloc
609 /* Now clean up the buffer */
610 return wxRealPath(buf
);
613 /* Contract Paths to be build upon an environment variable
616 example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib
618 The call wxExpandPath can convert these back!
621 wxContractPath (const wxString
& filename
, const wxString
& envname
, const wxString
& user
)
623 static wxChar dest
[_MAXPATHLEN
];
625 if (filename
== wxT(""))
626 return (wxChar
*) NULL
;
628 wxStrcpy (dest
, WXSTRINGCAST filename
);
630 Unix2DosFilename(dest
);
633 // Handle environment
634 const wxChar
*val
= (const wxChar
*) NULL
;
635 wxChar
*tcp
= (wxChar
*) NULL
;
636 if (envname
!= WXSTRINGCAST NULL
&& (val
= wxGetenv (WXSTRINGCAST envname
)) != NULL
&&
637 (tcp
= wxStrstr (dest
, val
)) != NULL
)
639 wxStrcpy (wxFileFunctionsBuffer
, tcp
+ wxStrlen (val
));
642 wxStrcpy (tcp
, WXSTRINGCAST envname
);
643 wxStrcat (tcp
, wxT("}"));
644 wxStrcat (tcp
, wxFileFunctionsBuffer
);
647 // Handle User's home (ignore root homes!)
649 if ((val
= wxGetUserHome (user
)) != NULL
&&
650 (len
= wxStrlen(val
)) > 2 &&
651 wxStrncmp(dest
, val
, len
) == 0)
653 wxStrcpy(wxFileFunctionsBuffer
, wxT("~"));
655 wxStrcat(wxFileFunctionsBuffer
, (const wxChar
*) user
);
657 // strcat(wxFileFunctionsBuffer, "\\");
659 // strcat(wxFileFunctionsBuffer, "/");
661 wxStrcat(wxFileFunctionsBuffer
, dest
+ len
);
662 wxStrcpy (dest
, wxFileFunctionsBuffer
);
668 // Return just the filename, not the path
670 wxChar
*wxFileNameFromPath (wxChar
*path
)
674 register wxChar
*tcp
;
676 tcp
= path
+ wxStrlen (path
);
677 while (--tcp
>= path
)
679 if (*tcp
== wxT('/') || *tcp
== wxT('\\')
681 || *tcp
== wxT(':') || *tcp
== wxT(']'))
687 #if defined(__WXMSW__) || defined(__WXPM__)
688 if (wxIsalpha (*path
) && *(path
+ 1) == wxT(':'))
695 wxString
wxFileNameFromPath (const wxString
& path1
)
697 if (path1
!= wxT(""))
700 wxChar
*path
= WXSTRINGCAST path1
;
701 register wxChar
*tcp
;
703 tcp
= path
+ wxStrlen (path
);
704 while (--tcp
>= path
)
706 if (*tcp
== wxT('/') || *tcp
== wxT('\\')
708 || *tcp
== wxT(':') || *tcp
== wxT(']'))
712 return wxString(tcp
+ 1);
714 #if defined(__WXMSW__) || defined(__WXPM__)
715 if (wxIsalpha (*path
) && *(path
+ 1) == wxT(':'))
716 return wxString(path
+ 2);
719 // Yes, this should return the path, not an empty string, otherwise
720 // we get "thing.txt" -> "".
724 // Return just the directory, or NULL if no directory
726 wxPathOnly (wxChar
*path
)
730 static wxChar buf
[_MAXPATHLEN
];
733 wxStrcpy (buf
, path
);
735 int l
= wxStrlen(path
);
740 // Search backward for a backward or forward slash
741 while (!done
&& i
> -1)
744 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\') || path
[i
] == wxT(']'))
748 if ( path
[i
] == wxT(']') )
759 #if defined(__WXMSW__) || defined(__WXPM__)
760 // Try Drive specifier
761 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
763 // A:junk --> A:. (since A:.\junk Not A:\junk)
771 return (wxChar
*) NULL
;
774 // Return just the directory, or NULL if no directory
775 wxString
wxPathOnly (const wxString
& path
)
779 wxChar buf
[_MAXPATHLEN
];
782 wxStrcpy (buf
, WXSTRINGCAST path
);
784 int l
= path
.Length();
789 // Search backward for a backward or forward slash
790 while (!done
&& i
> -1)
793 if (path
[i
] == wxT('/') || path
[i
] == wxT('\\') || path
[i
] == wxT(']'))
797 if ( path
[i
] == wxT(']') )
803 return wxString(buf
);
808 #if defined(__WXMSW__) || defined(__WXPM__)
809 // Try Drive specifier
810 if (wxIsalpha (buf
[0]) && buf
[1] == wxT(':'))
812 // A:junk --> A:. (since A:.\junk Not A:\junk)
815 return wxString(buf
);
820 return wxString(wxT(""));
823 // Utility for converting delimiters in DOS filenames to UNIX style
824 // and back again - or we get nasty problems with delimiters.
825 // Also, convert to lower case, since case is significant in UNIX.
829 static char sMacFileNameConversion
[ 1000 ] ;
831 wxString
wxMac2UnixFilename (const char *str
)
833 char *s
= sMacFileNameConversion
;
837 memmove( s
+1 , s
,strlen( s
) + 1) ;
848 *s
= wxTolower (*s
); // Case INDEPENDENT
852 return wxString (sMacFileNameConversion
) ;
855 wxString
wxUnix2MacFilename (const char *str
)
857 char *s
= sMacFileNameConversion
;
863 // relative path , since it goes on with slash which is translated to a :
864 memmove( s
, s
+1 ,strlen( s
) ) ;
866 else if ( *s
== '/' )
868 // absolute path -> on mac just start with the drive name
869 memmove( s
, s
+1 ,strlen( s
) ) ;
873 wxASSERT_MSG( 1 , "unkown path beginning" ) ;
877 if (*s
== '/' || *s
== '\\')
879 // convert any back-directory situations
880 if ( *(s
+1) == '.' && *(s
+2) == '.' && ( (*(s
+3) == '/' || *(s
+3) == '\\') ) )
883 memmove( s
+1 , s
+3 ,strlen( s
+3 ) + 1 ) ;
892 return wxString (sMacFileNameConversion
) ;
895 wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
)
900 FSpGetFullPath( spec
, &length
, &myPath
) ;
901 ::SetHandleSize( myPath
, length
+ 1 ) ;
903 (*myPath
)[length
] = 0 ;
904 if ( length
> 0 && (*myPath
)[length
-1] ==':' )
905 (*myPath
)[length
-1] = 0 ;
907 wxString
result( (char*) *myPath
) ;
908 ::HUnlock( myPath
) ;
909 ::DisposeHandle( myPath
) ;
913 wxString
wxMacFSSpec2UnixFilename( const FSSpec
*spec
)
915 return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec
) ) ;
918 void wxMacFilename2FSSpec( const char *path
, FSSpec
*spec
)
920 FSpLocationFromFullPath( strlen(path
) , path
, spec
) ;
923 void wxUnixFilename2FSSpec( const char *path
, FSSpec
*spec
)
925 wxString var
= wxUnix2MacFilename( path
) ;
926 wxMacFilename2FSSpec( var
, spec
) ;
931 wxDos2UnixFilename (char *s
)
940 *s
= wxTolower (*s
); // Case INDEPENDENT
947 #if defined(__WXMSW__) || defined(__WXPM__)
948 wxUnix2DosFilename (wxChar
*s
)
950 wxUnix2DosFilename (wxChar
*WXUNUSED(s
) )
953 // Yes, I really mean this to happen under DOS only! JACS
954 #if defined(__WXMSW__) || defined(__WXPM__)
965 // Concatenate two files to form third
967 wxConcatFiles (const wxString
& file1
, const wxString
& file2
, const wxString
& file3
)
969 wxChar
*outfile
= wxGetTempFileName("cat");
971 FILE *fp1
= (FILE *) NULL
;
972 FILE *fp2
= (FILE *) NULL
;
973 FILE *fp3
= (FILE *) NULL
;
974 // Open the inputs and outputs
976 if ((fp1
= fopen (wxUnix2MacFilename( file1
), "rb")) == NULL
||
977 (fp2
= fopen (wxUnix2MacFilename( file2
), "rb")) == NULL
||
978 (fp3
= fopen (wxUnix2MacFilename( outfile
), "wb")) == NULL
)
980 if ((fp1
= wxFopen (WXSTRINGCAST file1
, wxT("rb"))) == NULL
||
981 (fp2
= wxFopen (WXSTRINGCAST file2
, wxT("rb"))) == NULL
||
982 (fp3
= wxFopen (outfile
, wxT("wb"))) == NULL
)
995 while ((ch
= getc (fp1
)) != EOF
)
996 (void) putc (ch
, fp3
);
999 while ((ch
= getc (fp2
)) != EOF
)
1000 (void) putc (ch
, fp3
);
1004 bool result
= wxRenameFile(outfile
, file3
);
1011 wxCopyFile (const wxString
& file1
, const wxString
& file2
)
1018 if ((fd1
= fopen (wxUnix2MacFilename( file1
), "rb")) == NULL
)
1020 if ((fd2
= fopen (wxUnix2MacFilename( file2
), "wb")) == NULL
)
1022 if ((fd1
= wxFopen (WXSTRINGCAST file1
, wxT("rb"))) == NULL
)
1024 if ((fd2
= wxFopen (WXSTRINGCAST file2
, wxT("wb"))) == NULL
)
1031 while ((ch
= getc (fd1
)) != EOF
)
1032 (void) putc (ch
, fd2
);
1040 wxRenameFile (const wxString
& file1
, const wxString
& file2
)
1043 if (0 == rename (wxUnix2MacFilename( file1
), wxUnix2MacFilename( file2
)))
1046 // Normal system call
1047 if (0 == wxRename (wxCSTRINGCAST file1
, wxCSTRINGCAST file2
))
1051 if (wxCopyFile(file1
, file2
)) {
1052 wxRemoveFile(file1
);
1059 bool wxRemoveFile(const wxString
& file
)
1061 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
1062 int flag
= wxRemove(file
);
1063 #elif defined( __WXMAC__ )
1064 int flag
= unlink(wxUnix2MacFilename( file
));
1066 int flag
= unlink(wxFNSTRINGCAST file
.fn_str());
1068 return (flag
== 0) ;
1071 bool wxMkdir(const wxString
& dir
, int perm
)
1073 #if defined( __WXMAC__ )
1074 return (mkdir(wxUnix2MacFilename( dir
) , 0 ) == 0);
1076 const wxChar
*dirname
= dir
.c_str();
1078 // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
1079 // for the GNU compiler
1080 #if (!(defined(__WXMSW__) || defined(__WXPM__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__)
1081 if ( mkdir(wxFNCONV(dirname
), perm
) != 0 )
1082 #elif defined(__WXPM__)
1083 if (::DosCreateDir((PSZ
)dirname
, NULL
) != 0) // enhance for EAB's??
1084 #else // !MSW and !OS/2 VAC++
1085 if ( wxMkDir(wxFNSTRINGCAST
wxFNCONV(dirname
)) != 0 )
1088 wxLogSysError(_("Directory '%s' couldn't be created"), dirname
);
1097 bool wxRmdir(const wxString
& dir
, int WXUNUSED(flags
))
1100 return FALSE
; //to be changed since rmdir exists in VMS7.x
1101 #elif defined( __WXMAC__ )
1102 return (rmdir(wxUnix2MacFilename( dir
)) == 0);
1103 #elif defined(__WXPM__)
1104 return (::DosDeleteDir((PSZ
)dir
.c_str()) == 0);
1108 return FALSE
; // What to do?
1110 return (wxRmDir(wxFNSTRINGCAST dir
.fn_str()) == 0);
1117 bool wxDirExists(const wxString
& dir
)
1120 return FALSE
; //To be changed since stat exists in VMS7.x
1121 #elif !defined(__WXMSW__)
1123 return (stat(dir
.fn_str(), &sbuf
) != -1) && S_ISDIR(sbuf
.st_mode
) ? TRUE
: FALSE
;
1126 /* MATTHEW: [6] Always use same code for Win32, call FindClose */
1127 #if defined(__WIN32__)
1128 WIN32_FIND_DATA fileInfo
;
1131 struct ffblk fileInfo
;
1133 struct find_t fileInfo
;
1137 #if defined(__WIN32__)
1138 HANDLE h
= FindFirstFile((LPTSTR
) WXSTRINGCAST dir
,(LPWIN32_FIND_DATA
)&fileInfo
);
1140 if (h
==INVALID_HANDLE_VALUE
)
1144 return ((fileInfo
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) == FILE_ATTRIBUTE_DIRECTORY
);
1147 // In Borland findfirst has a different argument
1148 // ordering from _dos_findfirst. But _dos_findfirst
1149 // _should_ be ok in both MS and Borland... why not?
1151 return ((findfirst(WXSTRINGCAST dir
, &fileInfo
, _A_SUBDIR
) == 0 && (fileInfo
.ff_attrib
& _A_SUBDIR
) != 0));
1153 return (((_dos_findfirst(WXSTRINGCAST dir
, _A_SUBDIR
, &fileInfo
) == 0) && (fileInfo
.attrib
& _A_SUBDIR
)) != 0);
1162 // does the path exists? (may have or not '/' or '\\' at the end)
1163 bool wxPathExists(const wxChar
*pszPathName
)
1165 wxString
strPath(pszPathName
);
1167 // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
1168 // so remove all trailing backslashes from the path - but don't do this for
1169 // the pathes "d:\" (which are different from "d:") nor for just "\"
1170 while ( wxEndsWithPathSeparator(strPath
) )
1172 size_t len
= strPath
.length();
1173 if ( len
== 1 || strPath
[len
- 1] == _T(':') )
1176 strPath
.Truncate(len
- 1);
1178 #endif // __WINDOWS__
1181 #ifndef __VISAGECPP__
1182 return wxStat(wxFNSTRINGCAST strPath
.fn_str(), &st
) == 0 &&
1183 ((st
.st_mode
& S_IFMT
) == S_IFDIR
);
1185 // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
1186 return wxStat(wxFNSTRINGCAST strPath
.fn_str(), &st
) == 0 &&
1187 (st
.st_mode
== S_IFDIR
);
1192 // Get a temporary filename, opening and closing the file.
1193 wxChar
*wxGetTempFileName(const wxString
& prefix
, wxChar
*buf
)
1199 ::GetTempFileName(0, WXSTRINGCAST prefix
, 0, tmp
);
1201 wxChar tmp
[MAX_PATH
];
1202 wxChar tmpPath
[MAX_PATH
];
1203 ::GetTempPath(MAX_PATH
, tmpPath
);
1204 ::GetTempFileName(tmpPath
, WXSTRINGCAST prefix
, 0, tmp
);
1206 if (buf
) wxStrcpy(buf
, tmp
);
1207 else buf
= copystring(tmp
);
1211 static short last_temp
= 0; // cache last to speed things a bit
1212 // At most 1000 temp files to a process! We use a ring count.
1213 wxChar tmp
[100]; // FIXME static buffer
1215 for (short suffix
= last_temp
+ 1; suffix
!= last_temp
; ++suffix
%= 1000)
1217 wxSprintf (tmp
, wxT("/tmp/%s%d.%03x"), WXSTRINGCAST prefix
, (int) getpid (), (int) suffix
);
1218 if (!wxFileExists( tmp
))
1220 // Touch the file to create it (reserve name)
1221 FILE *fd
= fopen (wxFNCONV(tmp
), "w");
1226 wxStrcpy( buf
, tmp
);
1228 buf
= copystring( tmp
);
1232 wxLogError( _("wxWindows: error finding temporary file name.\n") );
1233 if (buf
) buf
[0] = 0;
1234 return (wxChar
*) NULL
;
1238 bool wxGetTempFileName(const wxString
& prefix
, wxString
& buf
)
1241 if (wxGetTempFileName(prefix
, buf2
) != (wxChar
*) NULL
)
1250 // Get first file name matching given wild card.
1254 // Get first file name matching given wild card.
1255 // Flags are reserved for future use.
1257 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1258 static DIR *gs_dirStream
= (DIR *) NULL
;
1259 static wxString gs_strFileSpec
;
1260 static int gs_findFlags
= 0;
1263 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1267 wxChar
*specvms
= NULL
;
1270 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1272 closedir(gs_dirStream
); // edz 941103: better housekeping
1274 gs_findFlags
= flags
;
1276 gs_strFileSpec
= spec
;
1278 // Find path only so we can concatenate
1279 // found file onto path
1280 wxString
path(wxPathOnly(gs_strFileSpec
));
1282 // special case: path is really "/"
1283 if ( !path
&& gs_strFileSpec
[0u] == wxT('/') )
1286 wxStrcpy( specvms
, wxT( "[000000]" ) );
1287 gs_strFileSpec
= specvms
;
1288 wxString
path_vms(wxPathOnly(gs_strFileSpec
));
1294 // path is empty => Local directory
1298 wxStrcpy( specvms
, wxT( "[]" ) );
1299 gs_strFileSpec
= specvms
;
1300 wxString
path_vms1(wxPathOnly(gs_strFileSpec
));
1307 gs_dirStream
= opendir(path
.fn_str());
1308 if ( !gs_dirStream
)
1310 wxLogSysError(_("Can not enumerate files in directory '%s'"),
1315 result
= wxFindNextFile();
1317 #endif // !VMS6.x or earlier
1322 wxString
wxFindNextFile()
1326 #if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
1327 wxCHECK_MSG( gs_dirStream
, result
, wxT("must call wxFindFirstFile first") );
1329 // Find path only so we can concatenate
1330 // found file onto path
1331 wxString
path(wxPathOnly(gs_strFileSpec
));
1332 wxString
name(wxFileNameFromPath(gs_strFileSpec
));
1334 /* MATTHEW: special case: path is really "/" */
1335 if ( !path
&& gs_strFileSpec
[0u] == wxT('/'))
1339 struct dirent
*nextDir
;
1340 for ( nextDir
= readdir(gs_dirStream
);
1342 nextDir
= readdir(gs_dirStream
) )
1344 if (wxMatchWild(name
, nextDir
->d_name
, FALSE
) && // RR: added FALSE to find hidden files
1345 strcmp(nextDir
->d_name
, ".") &&
1346 strcmp(nextDir
->d_name
, "..") )
1349 if ( !path
.IsEmpty() )
1352 if ( path
!= wxT('/') )
1356 result
+= nextDir
->d_name
;
1358 // Only return "." and ".." when they match
1360 if ( (strcmp(nextDir
->d_name
, ".") == 0) ||
1361 (strcmp(nextDir
->d_name
, "..") == 0))
1363 if ( (gs_findFlags
& wxDIR
) != 0 )
1369 isdir
= wxDirExists(result
);
1371 // and only return directories when flags & wxDIR
1372 if ( !gs_findFlags
||
1373 ((gs_findFlags
& wxDIR
) && isdir
) ||
1374 ((gs_findFlags
& wxFILE
) && !isdir
) )
1381 result
.Empty(); // not found
1383 closedir(gs_dirStream
);
1384 gs_dirStream
= (DIR *) NULL
;
1385 #endif // !VMS6.2 or earlier
1390 #elif defined(__WXMAC__)
1392 struct MacDirectoryIterator
1400 static int g_iter_flags
;
1402 static MacDirectoryIterator g_iter
;
1404 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1408 g_iter_flags
= flags
; /* MATTHEW: [5] Remember flags */
1410 // Find path only so we can concatenate found file onto path
1411 wxString
path(wxPathOnly(spec
));
1412 if ( !path
.IsEmpty() )
1413 result
<< path
<< wxT('\\');
1417 wxUnixFilename2FSSpec( result
, &fsspec
) ;
1418 g_iter
.m_CPB
.hFileInfo
.ioVRefNum
= fsspec
.vRefNum
;
1419 g_iter
.m_CPB
.hFileInfo
.ioNamePtr
= g_iter
.m_name
;
1420 g_iter
.m_index
= 0 ;
1423 FSpGetDirectoryID( &fsspec
, &g_iter
.m_dirId
, &isDir
) ;
1425 return wxEmptyString
;
1427 return wxFindNextFile( ) ;
1430 wxString
wxFindNextFile()
1436 while ( err
== noErr
)
1439 g_iter
.m_CPB
.dirInfo
.ioFDirIndex
= g_iter
.m_index
;
1440 g_iter
.m_CPB
.dirInfo
.ioDrDirID
= g_iter
.m_dirId
; /* we need to do this every time */
1441 err
= PBGetCatInfoSync((CInfoPBPtr
)&g_iter
.m_CPB
);
1445 if ( ( g_iter
.m_CPB
.dirInfo
.ioFlAttrib
& ioDirMask
) != 0 && (g_iter_flags
& wxDIR
) ) // we have a directory
1448 if ( ( g_iter
.m_CPB
.dirInfo
.ioFlAttrib
& ioDirMask
) == 0 && !(g_iter_flags
& wxFILE
) )
1456 return wxEmptyString
;
1460 FSMakeFSSpecCompat(g_iter
.m_CPB
.hFileInfo
.ioVRefNum
,
1465 return wxMacFSSpec2UnixFilename( &spec
) ;
1468 #elif defined(__WXMSW__)
1471 static HANDLE gs_hFileStruct
= INVALID_HANDLE_VALUE
;
1472 static WIN32_FIND_DATA gs_findDataStruct
;
1475 static struct ffblk gs_findDataStruct
;
1477 static struct _find_t gs_findDataStruct
;
1481 static wxString gs_strFileSpec
;
1482 static int gs_findFlags
= 0;
1484 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1488 gs_strFileSpec
= spec
;
1489 gs_findFlags
= flags
; /* MATTHEW: [5] Remember flags */
1491 // Find path only so we can concatenate found file onto path
1492 wxString
path(wxPathOnly(gs_strFileSpec
));
1493 if ( !path
.IsEmpty() )
1494 result
<< path
<< wxT('\\');
1497 if ( gs_hFileStruct
!= INVALID_HANDLE_VALUE
)
1498 FindClose(gs_hFileStruct
);
1500 gs_hFileStruct
= ::FindFirstFile(WXSTRINGCAST spec
, &gs_findDataStruct
);
1502 if ( gs_hFileStruct
== INVALID_HANDLE_VALUE
)
1509 bool isdir
= !!(gs_findDataStruct
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
);
1511 if (isdir
&& !(flags
& wxDIR
))
1512 return wxFindNextFile();
1513 else if (!isdir
&& flags
&& !(flags
& wxFILE
))
1514 return wxFindNextFile();
1516 result
+= gs_findDataStruct
.cFileName
;
1520 int flag
= _A_NORMAL
;
1525 if (findfirst(WXSTRINGCAST spec
, &gs_findDataStruct
, flag
) == 0)
1527 if (_dos_findfirst(WXSTRINGCAST spec
, flag
, &gs_findDataStruct
) == 0)
1533 attrib
= gs_findDataStruct
.ff_attrib
;
1535 attrib
= gs_findDataStruct
.attrib
;
1538 if (attrib
& _A_SUBDIR
) {
1539 if (!(gs_findFlags
& wxDIR
))
1540 return wxFindNextFile();
1541 } else if (gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1542 return wxFindNextFile();
1546 gs_findDataStruct
.ff_name
1548 gs_findDataStruct
.name
1558 wxString
wxFindNextFile()
1562 // Find path only so we can concatenate found file onto path
1563 wxString
path(wxPathOnly(gs_strFileSpec
));
1568 if (gs_hFileStruct
== INVALID_HANDLE_VALUE
)
1571 bool success
= (FindNextFile(gs_hFileStruct
, &gs_findDataStruct
) != 0);
1574 FindClose(gs_hFileStruct
);
1575 gs_hFileStruct
= INVALID_HANDLE_VALUE
;
1579 bool isdir
= !!(gs_findDataStruct
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
);
1581 if (isdir
&& !(gs_findFlags
& wxDIR
))
1583 else if (!isdir
&& gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1586 if ( !path
.IsEmpty() )
1587 result
<< path
<< wxT('\\');
1588 result
<< gs_findDataStruct
.cFileName
;
1595 if (findnext(&gs_findDataStruct
) == 0)
1597 if (_dos_findnext(&gs_findDataStruct
) == 0)
1600 /* MATTHEW: [5] Check directory flag */
1604 attrib
= gs_findDataStruct
.ff_attrib
;
1606 attrib
= gs_findDataStruct
.attrib
;
1609 if (attrib
& _A_SUBDIR
) {
1610 if (!(gs_findFlags
& wxDIR
))
1612 } else if (gs_findFlags
&& !(gs_findFlags
& wxFILE
))
1618 gs_findDataStruct
.ff_name
1620 gs_findDataStruct
.name
1629 #elif defined(__WXPM__)
1631 wxString
wxFindFirstFile(const wxChar
*spec
, int flags
)
1636 // TODO: figure something out here for OS/2
1637 gs_strFileSpec = spec;
1638 gs_findFlags = flags;
1640 // Find path only so we can concatenate found file onto path
1641 wxString path(wxPathOnly(gs_strFileSpec));
1642 if ( !path.IsEmpty() )
1643 result << path << wxT('\\');
1645 int flag = _A_NORMAL;
1649 if (_dos_findfirst(WXSTRINGCAST spec, flag, &gs_findDataStruct) == 0)
1652 attrib = gs_findDataStruct.attrib;
1654 if (attrib & _A_SUBDIR) {
1655 if (!(gs_findFlags & wxDIR))
1656 return wxFindNextFile();
1657 } else if (gs_findFlags && !(gs_findFlags & wxFILE))
1658 return wxFindNextFile();
1660 result += gs_findDataStruct.name;
1666 wxString
wxFindNextFile()
1673 #endif // Unix/Windows/OS/2
1675 // Get current working directory.
1676 // If buf is NULL, allocates space using new, else
1678 wxChar
*wxGetWorkingDirectory(wxChar
*buf
, int sz
)
1681 buf
= new wxChar
[sz
+1];
1683 char *cbuf
= new char[sz
+1];
1685 if (_getcwd(cbuf
, sz
) == NULL
) {
1686 #elif defined( __WXMAC__)
1689 SFSaveDisk
= 0x214, CurDirStore
= 0x398
1693 FSMakeFSSpec( - *(short *) SFSaveDisk
, *(long *) CurDirStore
, NULL
, &cwdSpec
) ;
1694 wxString res
= wxMacFSSpec2UnixFilename( &cwdSpec
) ;
1695 strcpy( buf
, res
) ;
1698 if (getcwd(cbuf
, sz
) == NULL
) {
1703 if (_getcwd(buf
, sz
) == NULL
) {
1704 #elif defined( __WXMAC__)
1707 SFSaveDisk
= 0x214, CurDirStore
= 0x398
1711 FSMakeFSSpec( - *(short *) SFSaveDisk
, *(long *) CurDirStore
, NULL
, &cwdSpec
) ;
1712 wxString res
= wxMacFSSpec2UnixFilename( &cwdSpec
) ;
1713 strcpy( buf
, res
) ;
1715 #elif(__VISAGECPP__)
1717 rc
= ::DosQueryCurrentDir( 0 // current drive
1723 if (getcwd(buf
, sz
) == NULL
) {
1731 wxConvFile
.MB2WC(buf
, cbuf
, sz
);
1740 static const size_t maxPathLen
= 1024;
1743 wxGetWorkingDirectory(str
.GetWriteBuf(maxPathLen
), maxPathLen
);
1744 str
.UngetWriteBuf();
1749 bool wxSetWorkingDirectory(const wxString
& d
)
1751 #if defined( __UNIX__ ) || defined( __WXMAC__ )
1752 return (chdir(wxFNSTRINGCAST d
.fn_str()) == 0);
1753 #elif defined(__WXPM__)
1754 return (::DosSetCurrentDir((PSZ
)d
.c_str()) == 0);
1755 #elif defined(__WINDOWS__)
1758 return (bool)(SetCurrentDirectory(d
) != 0);
1760 // Must change drive, too.
1761 bool isDriveSpec
= ((strlen(d
) > 1) && (d
[1] == ':'));
1764 wxChar firstChar
= d
[0];
1768 firstChar
= firstChar
- 32;
1770 // To a drive number
1771 unsigned int driveNo
= firstChar
- 64;
1774 unsigned int noDrives
;
1775 _dos_setdrive(driveNo
, &noDrives
);
1778 bool success
= (chdir(WXSTRINGCAST d
) == 0);
1786 // Get the OS directory if appropriate (such as the Windows directory).
1787 // On non-Windows platform, probably just return the empty string.
1788 wxString
wxGetOSDirectory()
1792 GetWindowsDirectory(buf
, 256);
1793 return wxString(buf
);
1795 return wxEmptyString
;
1799 bool wxEndsWithPathSeparator(const wxChar
*pszFileName
)
1801 size_t len
= wxStrlen(pszFileName
);
1805 return wxIsPathSeparator(pszFileName
[len
- 1]);
1808 // find a file in a list of directories, returns false if not found
1809 bool wxFindFileInPath(wxString
*pStr
, const wxChar
*pszPath
, const wxChar
*pszFile
)
1811 // we assume that it's not empty
1812 wxCHECK_MSG( !wxIsEmpty(pszFile
), FALSE
,
1813 _T("empty file name in wxFindFileInPath"));
1815 // skip path separator in the beginning of the file name if present
1816 if ( wxIsPathSeparator(*pszFile
) )
1819 // copy the path (strtok will modify it)
1820 wxChar
*szPath
= new wxChar
[wxStrlen(pszPath
) + 1];
1821 wxStrcpy(szPath
, pszPath
);
1824 wxChar
*pc
, *save_ptr
;
1825 for ( pc
= wxStrtok(szPath
, wxPATH_SEP
, &save_ptr
);
1827 pc
= wxStrtok((wxChar
*) NULL
, wxPATH_SEP
, &save_ptr
) )
1829 // search for the file in this directory
1831 if ( !wxEndsWithPathSeparator(pc
) )
1832 strFile
+= wxFILE_SEP_PATH
;
1835 if ( FileExists(strFile
) ) {
1841 // suppress warning about unused variable save_ptr when wxStrtok() is a
1842 // macro which throws away its third argument
1847 return pc
!= NULL
; // if true => we breaked from the loop
1850 void WXDLLEXPORT
wxSplitPath(const wxChar
*pszFileName
,
1855 // it can be empty, but it shouldn't be NULL
1856 wxCHECK_RET( pszFileName
, wxT("NULL file name in wxSplitPath") );
1858 const wxChar
*pDot
= wxStrrchr(pszFileName
, wxFILE_SEP_EXT
);
1861 // under Windows we understand both separators
1862 const wxChar
*pSepUnix
= wxStrrchr(pszFileName
, wxFILE_SEP_PATH_UNIX
);
1863 const wxChar
*pSepDos
= wxStrrchr(pszFileName
, wxFILE_SEP_PATH_DOS
);
1864 const wxChar
*pLastSeparator
= pSepUnix
> pSepDos
? pSepUnix
: pSepDos
;
1865 #else // assume Unix
1866 const wxChar
*pLastSeparator
= wxStrrchr(pszFileName
, wxFILE_SEP_PATH_UNIX
);
1870 if ( (pDot
== pszFileName
) || (*(pDot
- 1) == wxFILE_SEP_PATH_UNIX
) )
1872 // under Unix, dot may be (and commonly is) the first character of the
1873 // filename, don't treat the entire filename as extension in this case
1879 if ( pDot
&& (pDot
< pLastSeparator
) )
1881 // the dot is part of the path, not the start of the extension
1887 if ( pLastSeparator
)
1888 *pstrPath
= wxString(pszFileName
, pLastSeparator
- pszFileName
);
1895 const wxChar
*start
= pLastSeparator
? pLastSeparator
+ 1 : pszFileName
;
1896 const wxChar
*end
= pDot
? pDot
: pszFileName
+ wxStrlen(pszFileName
);
1898 *pstrName
= wxString(start
, end
- start
);
1904 *pstrExt
= wxString(pDot
+ 1);
1910 time_t WXDLLEXPORT
wxFileModificationTime(const wxString
& filename
)
1914 wxStat(filename
.fn_str(), &buf
);
1915 return buf
.st_mtime
;
1919 //------------------------------------------------------------------------
1920 // wild character routines
1921 //------------------------------------------------------------------------
1923 bool wxIsWild( const wxString
& pattern
)
1925 wxString tmp
= pattern
;
1926 wxChar
*pat
= WXSTRINGCAST(tmp
);
1929 case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
1939 bool wxMatchWild( const wxString
& pat
, const wxString
& text
, bool dot_special
)
1941 #if defined(HAVE_FNMATCH_H)
1943 // this probably won't work well for multibyte chars in Unicode mode?
1945 return fnmatch(pat
.fn_str(), text
.fn_str(), FNM_PERIOD
) == 0;
1947 return fnmatch(pat
.fn_str(), text
.fn_str(), 0) == 0;
1951 // #pragma error Broken implementation of wxMatchWild() -- needs fixing!
1954 * WARNING: this code is broken!
1957 wxString tmp1
= pat
;
1958 wxChar
*pattern
= WXSTRINGCAST(tmp1
);
1959 wxString tmp2
= text
;
1960 wxChar
*str
= WXSTRINGCAST(tmp2
);
1963 bool done
= FALSE
, ret_code
, ok
;
1964 // Below is for vi fans
1965 const wxChar OB
= wxT('{'), CB
= wxT('}');
1967 // dot_special means '.' only matches '.'
1968 if (dot_special
&& *str
== wxT('.') && *pattern
!= *str
)
1971 while ((*pattern
!= wxT('\0')) && (!done
)
1972 && (((*str
==wxT('\0'))&&((*pattern
==OB
)||(*pattern
==wxT('*'))))||(*str
!=wxT('\0')))) {
1976 if (*pattern
!= wxT('\0'))
1982 while ((*str
!=wxT('\0'))
1983 && (!(ret_code
=wxMatchWild(pattern
, str
++, FALSE
))))
1986 while (*str
!= wxT('\0'))
1988 while (*pattern
!= wxT('\0'))
1995 if ((*pattern
== wxT('\0')) || (*pattern
== wxT(']'))) {
1999 if (*pattern
== wxT('\\')) {
2001 if (*pattern
== wxT('\0')) {
2006 if (*(pattern
+ 1) == wxT('-')) {
2009 if (*pattern
== wxT(']')) {
2013 if (*pattern
== wxT('\\')) {
2015 if (*pattern
== wxT('\0')) {
2020 if ((*str
< c
) || (*str
> *pattern
)) {
2024 } else if (*pattern
!= *str
) {
2029 while ((*pattern
!= wxT(']')) && (*pattern
!= wxT('\0'))) {
2030 if ((*pattern
== wxT('\\')) && (*(pattern
+ 1) != wxT('\0')))
2034 if (*pattern
!= wxT('\0')) {
2044 while ((*pattern
!= CB
) && (*pattern
!= wxT('\0'))) {
2047 while (ok
&& (*cp
!= wxT('\0')) && (*pattern
!= wxT('\0'))
2048 && (*pattern
!= wxT(',')) && (*pattern
!= CB
)) {
2049 if (*pattern
== wxT('\\'))
2051 ok
= (*pattern
++ == *cp
++);
2053 if (*pattern
== wxT('\0')) {
2059 while ((*pattern
!= CB
) && (*pattern
!= wxT('\0'))) {
2060 if (*++pattern
== wxT('\\')) {
2061 if (*++pattern
== CB
)
2066 while (*pattern
!=CB
&& *pattern
!=wxT(',') && *pattern
!=wxT('\0')) {
2067 if (*++pattern
== wxT('\\')) {
2068 if (*++pattern
== CB
|| *pattern
== wxT(','))
2073 if (*pattern
!= wxT('\0'))
2078 if (*str
== *pattern
) {
2085 while (*pattern
== wxT('*'))
2087 return ((*str
== wxT('\0')) && (*pattern
== wxT('\0')));
2093 #pragma warning(default:4706) // assignment within conditional expression