From 01646d7cf4ff92f04519a1f174754879e3302d5a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 8 Jan 2012 01:34:37 +0000 Subject: [PATCH] Remove StandardPaths::DecodePathMaybeRelative, as it's been deprecated forever Originally committed to SVN as r6232. --- aegisub/src/ass_file.cpp | 20 ++++++-------------- aegisub/src/preferences_base.cpp | 4 ++-- aegisub/src/standard_paths.cpp | 29 ----------------------------- aegisub/src/standard_paths.h | 26 -------------------------- 4 files changed, 8 insertions(+), 71 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 9aa609965..9f980cfed 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -128,19 +128,13 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent) if (file.FileExists()) { wxString path = lagi_wxString(OPT_GET("Path/Auto/Backup")->GetString()); if (path.empty()) path = file.GetPath(); + wxFileName dstpath(StandardPaths::DecodePath(path)); + if (!dstpath.DirExists()) + wxMkdir(dstpath.GetPath()); - wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) - path = StandardPaths::DecodePathMaybeRelative(path, "?user/"); - path += "/"; - dstpath.Assign(path); + dstpath.SetFullName(file.GetName() + ".ORIGINAL." + file.GetExt()); - if (!dstpath.DirExists()) { - wxMkdir(path); - } - - wxString backup = path + file.GetName() + ".ORIGINAL." + file.GetExt(); - wxCopyFile(file.GetFullPath(), backup, true); + wxCopyFile(file.GetFullPath(), dstpath.GetFullPath(), true); } } @@ -190,11 +184,9 @@ wxString AssFile::AutoSave() { wxString path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString()); if (!path) path = origfile.GetPath(); + path = StandardPaths::DecodePath(path); wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) - path = StandardPaths::DecodePathMaybeRelative(path, "?user/"); - dstpath.AssignDir(path); if (!dstpath.DirExists()) wxMkdir(path); diff --git a/aegisub/src/preferences_base.cpp b/aegisub/src/preferences_base.cpp index 209458d9f..732fe1fc5 100644 --- a/aegisub/src/preferences_base.cpp +++ b/aegisub/src/preferences_base.cpp @@ -79,10 +79,10 @@ public: }; static void browse_button(wxTextCtrl *ctrl) { - wxString def = StandardPaths::DecodePathMaybeRelative(ctrl->GetValue(), "?user/"); + wxString def = StandardPaths::DecodePath(ctrl->GetValue()); wxDirDialog dlg(0, _("Please choose the folder:"), def); if (dlg.ShowModal() == wxID_OK) { - wxString dir = StandardPaths::EncodePath(dlg.GetPath()); + wxString dir = dlg.GetPath(); if (!dir.empty()) ctrl->SetValue(dir); } diff --git a/aegisub/src/standard_paths.cpp b/aegisub/src/standard_paths.cpp index fdb97127b..27a9db010 100644 --- a/aegisub/src/standard_paths.cpp +++ b/aegisub/src/standard_paths.cpp @@ -125,19 +125,6 @@ wxString StandardPaths::DoDecodePath(wxString path) { else return path; } - - -/// @brief Encode path -/// @param path -/// @return -/// -wxString StandardPaths::DoEncodePath(const wxString &path) { - // TODO - return path; -} - - - /// @brief Set value of a ? path /// @param path /// @param value @@ -145,19 +132,3 @@ wxString StandardPaths::DoEncodePath(const wxString &path) { void StandardPaths::DoSetPathValue(const wxString &path, const wxString &value) { paths[path] = value; } - - - -/// @brief Decode a path that for legacy reasons might be relative to another path -/// @param path parent path. -/// @param relativeTo relative path. -/// @returns absolute path -/// @depreciated Older aegisub versions allowed people to put in single directory names w/out a full path this isn't an issue with 2.2 as preferences will be redone. -wxString StandardPaths::DecodePathMaybeRelative(const wxString &path, const wxString &relativeTo) { - wxFileName res(DecodePath(path)); - if (res.IsRelative()) - res.Assign(DecodePath(relativeTo + "/" + path)); - return res.GetFullPath(); -} - - diff --git a/aegisub/src/standard_paths.h b/aegisub/src/standard_paths.h index e05f9aad9..40a9eb84c 100644 --- a/aegisub/src/standard_paths.h +++ b/aegisub/src/standard_paths.h @@ -34,11 +34,6 @@ /// @ingroup utility /// - - - -/////////// -// Headers #ifndef AGI_PRE #include #endif @@ -50,10 +45,8 @@ /// /// DOCME class StandardPaths { -private: static StandardPaths &GetInstance(); - /// DOCME std::map paths; @@ -62,29 +55,10 @@ private: StandardPaths& operator=(StandardPaths const&); wxString DoDecodePath(wxString path); - wxString DoEncodePath(const wxString &path); void DoSetPathValue(const wxString &path, const wxString &value); public: - /// @brief DOCME - /// @param path - /// @return - /// static wxString DecodePath(const wxString &path) { return GetInstance().DoDecodePath(path); } - static wxString DecodePathMaybeRelative(const wxString &path, const wxString &relativeTo); - - /// @brief DOCME - /// @param path - /// @return - /// - static wxString EncodePath(const wxString &path) { return GetInstance().DoEncodePath(path); } - - /// @brief DOCME - /// @param path - /// @param value - /// static void SetPathValue(const wxString &path, const wxString &value) { GetInstance().DoSetPathValue(path,value); } }; - -