]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
Reverted bogus fix for bogus bug report #13402.
[wxWidgets.git] / src / common / filename.cpp
index 882581cdedb7b0881579485673c5b0d8fa78373e..f90221af89b4a5343d35370890afe3b17871f37b 100644 (file)
 extern const wxULongLong wxInvalidSize = (unsigned)-1;
 #endif // wxUSE_LONGLONG
 
-#ifdef __WIN32__
-    // this define is missing from VC6 headers
-    #ifndef INVALID_FILE_ATTRIBUTES
-        #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
-    #endif
-#endif // __WIN32__
-
 namespace
 {
 
@@ -608,9 +601,7 @@ bool wxFileName::FileExists() const
 /* static */
 bool wxFileName::FileExists( const wxString &filePath )
 {
-#if defined(__WXPALMOS__)
-    return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
     // we must use GetFileAttributes() instead of the ANSI C functions because
     // it can cope with network (UNC) paths unlike them
     DWORD ret = ::GetFileAttributes(filePath.t_str());
@@ -666,9 +657,7 @@ bool wxFileName::DirExists( const wxString &dirPath )
         strPath << wxT('.');
 #endif
 
-#if defined(__WXPALMOS__)
-    return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
     // stat() can't cope with network paths
     DWORD ret = ::GetFileAttributes(strPath.t_str());
 
@@ -816,7 +805,7 @@ static bool wxTempOpen(wxFFile *file, const wxString& path, bool *deleteOnClose)
     int fd = wxTempOpen(path, deleteOnClose);
     if (fd == -1)
         return false;
-    file->Attach(wx_fdopen(fd, "w+b"));
+    file->Attach(wx_fdopen(fd, "w+b"), path);
     return file->IsOpened();
 #endif // wx_fdopen
 }
@@ -927,7 +916,7 @@ static wxString wxCreateTempImpl(
         if ( ffileTemp )
         {
         #ifdef wx_fdopen
-            ffileTemp->Attach(wx_fdopen(fdTemp, "r+b"));
+            ffileTemp->Attach(wx_fdopen(fdTemp, "r+b"), path);
         #else
             ffileTemp->Open(path, wxT("r+b"));
             close(fdTemp);
@@ -957,7 +946,7 @@ static wxString wxCreateTempImpl(
     }
 #else // !HAVE_MKTEMP (includes __DOS__)
     // generate the unique file name ourselves
-    #if !defined(__DOS__) && !defined(__PALMOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) )
+    #if !defined(__DOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) )
     path << (unsigned int)getpid();
     #endif
 
@@ -1455,15 +1444,24 @@ bool wxFileName::Normalize(int flags,
 
             if ( dir == wxT("..") )
             {
-                if ( m_dirs.IsEmpty() )
+                if ( m_dirs.empty() )
                 {
-                    wxLogError(_("The path '%s' contains too many \"..\"!"),
-                               GetFullPath().c_str());
-                    return false;
-                }
+                    // We have more ".." than directory components so far.
+                    // Don't treat this as an error as the path could have been
+                    // entered by user so try to handle it reasonably: if the
+                    // path is absolute, just ignore the extra ".." because
+                    // "/.." is the same as "/". Otherwise, i.e. for relative
+                    // paths, keep ".." unchanged because removing it would
+                    // modify the file a relative path refers to.
+                    if ( !m_relative )
+                        continue;
 
-                m_dirs.RemoveAt(m_dirs.GetCount() - 1);
-                continue;
+                }
+                else // Normal case, go one step up.
+                {
+                    m_dirs.pop_back();
+                    continue;
+                }
             }
         }
 
@@ -2641,10 +2639,7 @@ wxULongLong wxFileName::GetSize(const wxString &filename)
     if (!wxFileExists(filename))
         return wxInvalidSize;
 
-#if defined(__WXPALMOS__)
-    // TODO
-    return wxInvalidSize;
-#elif defined(__WIN32__)
+#if defined(__WIN32__)
     wxFileHandle f(filename, wxFileHandle::ReadAttr);
     if (!f.IsOk())
         return wxInvalidSize;