]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
compilation fix
[wxWidgets.git] / src / common / filename.cpp
index 05a84579cf2537cb86b2beca262dc09749ad36e8..db24f8040fa9af6109eec6f89aee9301f95667da 100644 (file)
@@ -634,13 +634,19 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
 
     path += name;
 
+    // Needed for Unicode/Ansi conversion
+    char buf[500];
+    
 #if defined(HAVE_MKSTEMP)
     // scratch space for mkstemp()
     path += _T("XXXXXX");
 
-    // can use the cast here because the length doesn't change and the string
-    // is not shared
-    int fdTemp = mkstemp((char *)path.mb_str());
+#if wxUSE_UNICODE
+    strcpy( buf, wxConvFile.cWC2MB( path ) );
+#else
+    strcpy( buf, path.c_str() );
+#endif
+    int fdTemp = mkstemp( buf );
     if ( fdTemp == -1 )
     {
         // this might be not necessary as mkstemp() on most systems should have
@@ -649,6 +655,11 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
     }
     else // mkstemp() succeeded
     {
+#if wxUSE_UNICODE
+        path = wxConvFile.cMB2WC( buf );
+#else
+        path = buf;
+#endif
         // avoid leaking the fd
         if ( fileTemp )
         {
@@ -665,10 +676,23 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
     // same as above
     path += _T("XXXXXX");
 
-    if ( !mktemp((char *)path.mb_str()) )
+#if wxUSE_UNICODE
+    strcpy( buf, wxConvFile.cWC2MB( path ) );
+#else
+    strcpy( buf, path.c_str() );
+#endif
+    if ( !mktemp( buf )
     {
         path.clear();
     }
+    else
+    {
+#if wxUSE_UNICODE
+        path = wxConvFile.cMB2WC( buf );
+#else
+        path = buf;
+#endif
+    }
 #else // !HAVE_MKTEMP (includes __DOS__)
     // generate the unique file name ourselves
     #ifndef __DOS__
@@ -1601,7 +1625,7 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
     utimbuf utm;
     utm.actime = dtAccess ? dtAccess->GetTicks() : dtMod->GetTicks();
     utm.modtime = dtMod ? dtMod->GetTicks() : dtAccess->GetTicks();
-    if ( utime(GetFullPath(), &utm) == 0 )
+    if ( utime(GetFullPath().fn_str(), &utm) == 0 )
     {
         return TRUE;
     }
@@ -1639,7 +1663,7 @@ bool wxFileName::Touch()
 {
 #if defined(__UNIX_LIKE__)
     // under Unix touching file is simple: just pass NULL to utime()
-    if ( utime(GetFullPath(), NULL) == 0 )
+    if ( utime(GetFullPath().fn_str(), NULL) == 0 )
     {
         return TRUE;
     }
@@ -1660,7 +1684,7 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess,
 {
 #if defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
     wxStructStat stBuf;
-    if ( wxStat(GetFullPath(), &stBuf) == 0 )
+    if ( wxStat( GetFullPath().c_str(), &stBuf) == 0 )
     {
         if ( dtAccess )
             dtAccess->Set(stBuf.st_atime);