summaryrefslogtreecommitdiff
path: root/libs/pbd/windows_special_dirs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/pbd/windows_special_dirs.cc')
-rw-r--r--libs/pbd/windows_special_dirs.cc31
1 files changed, 10 insertions, 21 deletions
diff --git a/libs/pbd/windows_special_dirs.cc b/libs/pbd/windows_special_dirs.cc
index 5e924f57e1..d5138050df 100644
--- a/libs/pbd/windows_special_dirs.cc
+++ b/libs/pbd/windows_special_dirs.cc
@@ -23,38 +23,27 @@
#include "pbd/windows_special_dirs.h"
-//***************************************************************
-//
-// get_win_special_folder()
-//
-// Gets the full path name that corresponds of one of the Windows
-// special folders, such as "My Documents" and the like. The input
-// parameter must be one of the corresponding CSIDL values, such
-// as CSIDL_SYSTEM etc.
-//
-// Returns:
-//
-// On Success: A pointer to a newly allocated string containing
-// the name of the special folder (must later be freed).
-// On Failure: NULL
-//
-
-char *
-PBD::get_win_special_folder (int csidl)
+std::string
+PBD::get_win_special_folder_path (int csidl)
{
wchar_t path[PATH_MAX+1];
HRESULT hr;
LPITEMIDLIST pidl = 0;
- char *retval = 0;
+ char *utf8_folder_path = 0;
if (S_OK == (hr = SHGetSpecialFolderLocation (0, csidl, &pidl))) {
if (SHGetPathFromIDListW (pidl, path)) {
- retval = g_utf16_to_utf8 ((const gunichar2*)path, -1, 0, 0, 0);
+ utf8_folder_path = g_utf16_to_utf8 ((const gunichar2*)path, -1, 0, 0, 0);
}
CoTaskMemFree (pidl);
}
- return retval;
+ if (utf8_folder_path != NULL) {
+ std::string folder_path(utf8_folder_path);
+ g_free (utf8_folder_path);
+ return folder_path;
+ }
+ return std::string();
}