]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
split wxGrid implementation in grideditors.cpp (for wxGridCellEditor-derived classes...
[wxWidgets.git] / src / common / filename.cpp
index 4373beb7443454986c9f070c5759a515874f671a..508954f955161f594ca10a78cf995247e7ae988d 100644 (file)
@@ -1152,7 +1152,6 @@ bool wxFileName::Normalize(int flags,
         }
     }
 
-
     // the existing path components
     wxArrayString dirs = GetDirs();
 
@@ -1302,6 +1301,49 @@ bool wxFileName::Normalize(int flags,
     return true;
 }
 
+#ifndef __WXWINCE__
+bool wxFileName::ReplaceEnvVariable(const wxString& envname,
+                                    const wxString& replacementFmtString,
+                                    wxPathFormat format)
+{
+    // look into stringForm for the contents of the given environment variable
+    wxString val;
+    if (envname.empty() ||
+        !wxGetEnv(envname, &val))
+        return false;
+    if (val.empty())
+        return false;
+
+    wxString stringForm = GetPath(wxPATH_GET_VOLUME, format);
+        // do not touch the file name and the extension
+
+    wxString replacement = wxString::Format(replacementFmtString, envname);
+    stringForm.Replace(val, replacement);
+
+    // Now assign ourselves the modified path:
+    Assign(stringForm, GetFullName(), format);
+
+    return true;
+}
+#endif
+
+bool wxFileName::ReplaceHomeDir(wxPathFormat format)
+{
+    wxString homedir = wxGetHomeDir();
+    if (homedir.empty())
+        return false;
+
+    wxString stringForm = GetPath(wxPATH_GET_VOLUME, format);
+        // do not touch the file name and the extension
+
+    stringForm.Replace(homedir, "~");
+
+    // Now assign ourselves the modified path:
+    Assign(stringForm, GetFullName(), format);
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 // get the shortcut target
 // ----------------------------------------------------------------------------
@@ -1331,7 +1373,7 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath,
                                    wxString* arguments)
 {
     wxString path, file, ext;
-    wxSplitPath(shortcutPath, & path, & file, & ext);
+    wxFileName::SplitPath(shortcutPath, & path, & file, & ext);
 
     HRESULT hres;
     IShellLink* psl;