X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74cf9763b4cd29d2a8acd27da76573a0fd164254..e9c54ec33655bfa9a57eb7955b114621fb940e1f:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index c711152e64..70474e9b9e 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -124,6 +124,10 @@ #endif #endif +#ifdef __EMX__ +#define MAX_PATH _MAX_PATH +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -434,6 +438,9 @@ void wxFileName::Clear() m_volume = m_name = m_ext = wxEmptyString; + + // we don't have any absolute path for now + m_relative = TRUE; } /* static */ @@ -639,10 +646,10 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) path += _T("XXXXXX"); // we need to copy the path to the buffer in which mkstemp() can modify it - wxCharBuffer buf(path.fn_str()); + wxCharBuffer buf = wxConvFile.cWX2MB( path ); // cast is safe because the string length doesn't change - int fdTemp = mkstemp( (char *)buf.data() ); + int fdTemp = mkstemp( (char*)(const char*) buf ); if ( fdTemp == -1 ) { // this might be not necessary as mkstemp() on most systems should have @@ -651,8 +658,8 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) } else // mkstemp() succeeded { - path = wxConvFile.cMB2WX(buf); - + path = wxConvFile.cMB2WX( (const char*) buf ); + // avoid leaking the fd if ( fileTemp ) { @@ -669,14 +676,14 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) // same as above path += _T("XXXXXX"); - wxCharBuffer buf(path.fn_str()); - if ( !mktemp( buf ) ) + wxCharBuffer buf = wxConvFile.cWX2MB( path ); + if ( !mktemp( (const char*) buf ) ) { path.clear(); } else { - path = wxConvFile.cMB2WX(buf); + path = wxConvFile.cMB2WX( (const char*) buf ); } #else // !HAVE_MKTEMP (includes __DOS__) // generate the unique file name ourselves @@ -964,8 +971,8 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format) // get cwd only once - small time saving wxString cwd = wxGetCwd(); - Normalize(wxPATH_NORM_ALL, cwd, format); - fnBase.Normalize(wxPATH_NORM_ALL, cwd, format); + Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, cwd, format); + fnBase.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, cwd, format); bool withCase = IsCaseSensitive(format); @@ -1022,8 +1029,8 @@ bool wxFileName::SameAs(const wxFileName &filepath, wxPathFormat format) // get cwd only once - small time saving wxString cwd = wxGetCwd(); - fn1.Normalize(wxPATH_NORM_ALL, cwd, format); - fn2.Normalize(wxPATH_NORM_ALL, cwd, format); + fn1.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, cwd, format); + fn2.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, cwd, format); if ( fn1.GetFullPath() == fn2.GetFullPath() ) return TRUE; @@ -1355,7 +1362,13 @@ wxString wxFileName::GetLongPath() const WIN32_FIND_DATA findFileData; HANDLE hFind; - pathOut = wxEmptyString; + + if ( HasVolume() ) + pathOut = GetVolume() + + GetVolumeSeparator(wxPATH_DOS) + + GetPathSeparator(wxPATH_DOS); + else + pathOut = wxEmptyString; wxArrayString dirs = GetDirs(); dirs.Add(GetFullName()); @@ -1373,7 +1386,8 @@ wxString wxFileName::GetLongPath() const if ( tmpPath.empty() ) continue; - if ( tmpPath.Last() == wxT(':') ) + // can't see this being necessary? MF + if ( tmpPath.Last() == GetVolumeSeparator(wxPATH_DOS) ) { // Can't pass a drive and root dir to FindFirstFile, // so continue to next dir @@ -1385,8 +1399,12 @@ wxString wxFileName::GetLongPath() const hFind = ::FindFirstFile(tmpPath, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { - // Error: return immediately with the original path - return path; + // Error: most likely reason is that path doesn't exist, so + // append any unprocessed parts and return + for ( i += 1; i < count; i++ ) + tmpPath += wxFILE_SEP_PATH + dirs[i]; + + return tmpPath; } pathOut += findFileData.cFileName; @@ -1727,7 +1745,7 @@ public : m_type = from.m_type ; m_creator = from.m_creator ; } - MacDefaultExtensionRecord( char * extension , OSType type , OSType creator ) + MacDefaultExtensionRecord( const char * extension , OSType type , OSType creator ) { strncpy( m_ext , extension , kMacExtensionMaxLength ) ; m_ext[kMacExtensionMaxLength] = 0 ; @@ -1763,7 +1781,7 @@ static void MacEnsureDefaultExtensionsLoaded() } ; // we could load the pc exchange prefs here too - for ( int i = 0 ; i < WXSIZEOF( defaults ) ; ++i ) + for ( size_t i = 0 ; i < WXSIZEOF( defaults ) ; ++i ) { gMacDefaultExtensions.Add( defaults[i] ) ; }