if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL) {
if (was_sep) /* replace only if it was there: */
*s = SEP;
if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL) {
if (was_sep) /* replace only if it was there: */
*s = SEP;
- // convert any back-directory situations
- if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
- {
+ // convert any back-directory situations
+ if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
+ {
- Handle myPath ;
- short length ;
-
- FSpGetFullPath( spec , &length , &myPath ) ;
- ::SetHandleSize( myPath , length + 1 ) ;
- ::HLock( myPath ) ;
- (*myPath)[length] = 0 ;
- if ( length > 0 && (*myPath)[length-1] ==':' )
- (*myPath)[length-1] = 0 ;
-
- wxString result( (char*) *myPath ) ;
- ::HUnlock( myPath ) ;
- ::DisposeHandle( myPath ) ;
- return result ;
+ Handle myPath ;
+ short length ;
+
+ FSpGetFullPath( spec , &length , &myPath ) ;
+ ::SetHandleSize( myPath , length + 1 ) ;
+ ::HLock( myPath ) ;
+ (*myPath)[length] = 0 ;
+ if ( length > 0 && (*myPath)[length-1] ==':' )
+ (*myPath)[length-1] = 0 ;
+
+ wxString result( (char*) *myPath ) ;
+ ::HUnlock( myPath ) ;
+ ::DisposeHandle( myPath ) ;
+ return result ;
- wxString var = wxUnix2MacFilename( path ) ;
- wxMacFilename2FSSpec( var , spec ) ;
+ wxString var = wxUnix2MacFilename( path ) ;
+ wxMacFilename2FSSpec( var , spec ) ;
bool wxRemoveFile(const wxString& file)
{
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
bool wxRemoveFile(const wxString& file)
{
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
return FALSE; //to be changed since rmdir exists in VMS7.x
#elif defined( __WXMAC__ )
return (rmdir(wxUnix2MacFilename( dir )) == 0);
return FALSE; //to be changed since rmdir exists in VMS7.x
#elif defined( __WXMAC__ )
return (rmdir(wxUnix2MacFilename( dir )) == 0);
// does the path exists? (may have or not '/' or '\\' at the end)
bool wxPathExists(const wxChar *pszPathName)
{
// does the path exists? (may have or not '/' or '\\' at the end)
bool wxPathExists(const wxChar *pszPathName)
{
- /* Windows API returns -1 from stat for "c:\dir\" if "c:\dir" exists
- * OTOH, we should change "d:" to "d:\" and leave "\" as is. */
- wxString strPath(pszPathName);
- if ( wxEndsWithPathSeparator(pszPathName) && pszPathName[1] != wxT('\0') )
- strPath.Last() = wxT('\0');
+ wxString strPath(pszPathName);
+#ifdef __WINDOWS__
+ // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
+ // so remove all trailing backslashes from the path - but don't do this for
+ // the pathes "d:\" (which are different from "d:") nor for just "\"
+ while ( wxEndsWithPathSeparator(strPath) )
+ {
+ size_t len = strPath.length();
+ if ( len == 1 || strPath[len - 1] == _T(':') )
+ break;
#if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
if (gs_dirStream)
closedir(gs_dirStream); // edz 941103: better housekeping
#if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
if (gs_dirStream)
closedir(gs_dirStream); // edz 941103: better housekeping
- path = wxT('/');
- // path is empty => Local directory
+#ifdef __VMS
+ {
+ wxStrcpy( specvms , wxT( "[000000]" ) );
+ gs_strFileSpec = specvms;
+ wxString path_vms(wxPathOnly(gs_strFileSpec));
+ path = path_vms;
+ }
+#else
+ path = wxT('/');
+#endif
+ // path is empty => Local directory
nextDir = readdir(gs_dirStream) )
{
if (wxMatchWild(name, nextDir->d_name, FALSE) && // RR: added FALSE to find hidden files
nextDir = readdir(gs_dirStream) )
{
if (wxMatchWild(name, nextDir->d_name, FALSE) && // RR: added FALSE to find hidden files
- strcmp(nextDir->d_name, ".") &&
- strcmp(nextDir->d_name, "..") )
+ strcmp(nextDir->d_name, ".") &&
+ strcmp(nextDir->d_name, "..") )
- FSSpec fsspec ;
-
- wxUnixFilename2FSSpec( result , &fsspec ) ;
- g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
- g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
- g_iter.m_index = 0 ;
-
- Boolean isDir ;
- FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ;
- if ( !isDir )
- return wxEmptyString ;
-
- return wxFindNextFile( ) ;
+ FSSpec fsspec ;
+
+ wxUnixFilename2FSSpec( result , &fsspec ) ;
+ g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
+ g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
+ g_iter.m_index = 0 ;
+
+ Boolean isDir ;
+ FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ;
+ if ( !isDir )
+ return wxEmptyString ;
+
+ return wxFindNextFile( ) ;
- short err = noErr ;
-
- while ( err == noErr )
- {
- g_iter.m_index++ ;
- g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
- g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
- err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
- if ( err != noErr )
- break ;
-
- if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
- break ;
-
- if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
- continue ;
-
- // hit !
- break ;
- }
- if ( err != noErr )
- {
- return wxEmptyString ;
- }
- FSSpec spec ;
-
- FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
- g_iter.m_dirId,
- g_iter.m_name,
- &spec) ;
-
- return wxMacFSSpec2UnixFilename( &spec ) ;
+ short err = noErr ;
+
+ while ( err == noErr )
+ {
+ g_iter.m_index++ ;
+ g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
+ g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
+ err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
+ if ( err != noErr )
+ break ;
+
+ if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
+ break ;
+
+ if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
+ continue ;
+
+ // hit !
+ break ;
+ }
+ if ( err != noErr )
+ {
+ return wxEmptyString ;
+ }
+ FSSpec spec ;
+
+ FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
+ g_iter.m_dirId,
+ g_iter.m_name,
+ &spec) ;
+
+ return wxMacFSSpec2UnixFilename( &spec ) ;
#ifdef _MSC_VER
if (_getcwd(cbuf, sz) == NULL) {
#elif defined( __WXMAC__)
#ifdef _MSC_VER
if (_getcwd(cbuf, sz) == NULL) {
#elif defined( __WXMAC__)
- enum
- {
- SFSaveDisk = 0x214, CurDirStore = 0x398
- };
- FSSpec cwdSpec ;
-
- FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
- wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
- strcpy( buf , res ) ;
- if (0) {
+ enum
+ {
+ SFSaveDisk = 0x214, CurDirStore = 0x398
+ };
+ FSSpec cwdSpec ;
+
+ FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
+ wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
+ strcpy( buf , res ) ;
+ if (0) {
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
#elif defined( __WXMAC__)
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
#elif defined( __WXMAC__)
- enum
- {
- SFSaveDisk = 0x214, CurDirStore = 0x398
- };
- FSSpec cwdSpec ;
-
- FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
- wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
- strcpy( buf , res ) ;
- if (0) {
+ enum
+ {
+ SFSaveDisk = 0x214, CurDirStore = 0x398
+ };
+ FSSpec cwdSpec ;
+
+ FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
+ wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
+ strcpy( buf , res ) ;
+ if (0) {
+#elif(__VISAGECPP__)
+ APIRET rc;
+ rc = ::DosQueryCurrentDir( 0 // current drive
+ ,buf
+ ,(PULONG)&sz
+ );
+ if (rc != 0) {
{
// we assume that it's not empty
wxCHECK_MSG( !wxIsEmpty(pszFile), FALSE,
{
// we assume that it's not empty
wxCHECK_MSG( !wxIsEmpty(pszFile), FALSE,
// skip path separator in the beginning of the file name if present
if ( wxIsPathSeparator(*pszFile) )
// skip path separator in the beginning of the file name if present
if ( wxIsPathSeparator(*pszFile) )