[vlc-commits] win32: dirs-uap: create a function to get the name of a IStorageFolder
Steve Lhomme
git at videolan.org
Thu Apr 9 07:52:00 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Apr 6 12:45:19 2020 +0200| [82e876aad05ae252ac86e1d663049acf62086f82] | committer: Steve Lhomme
win32: dirs-uap: create a function to get the name of a IStorageFolder
It also released the IStorageFolder once it's done.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=82e876aad05ae252ac86e1d663049acf62086f82
---
src/win32/dirs-uap.c | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/win32/dirs-uap.c b/src/win32/dirs-uap.c
index 60dc99caa7..6f7d4d062b 100644
--- a/src/win32/dirs-uap.c
+++ b/src/win32/dirs-uap.c
@@ -41,6 +41,28 @@
#include <windows.storage.h>
#include <roapi.h>
+static char * GetFolderName(IStorageFolder *folder)
+{
+ HRESULT hr;
+ IStorageItem *item;
+ hr = IStorageFolder_QueryInterface(folder, &IID_IStorageItem, (void**)&item);
+ if (FAILED(hr))
+ return NULL;
+
+ char *result = NULL;
+ HSTRING path;
+ hr = IStorageItem_get_Path(item, &path);
+ if (SUCCEEDED(hr))
+ {
+ PCWSTR pszPathTemp = WindowsGetStringRawBuffer(path, NULL);
+ result = FromWide(pszPathTemp);
+ WindowsDeleteString(path);
+ }
+ IStorageItem_Release(item);
+ IStorageFolder_Release(folder);
+ return result;
+}
+
static char *config_GetShellDir(vlc_userdir_t csidl)
{
HRESULT hr;
@@ -132,28 +154,10 @@ end_other:
IKnownFoldersStatics_Release(knownFoldersStatics);
}
- char *result = NULL;
- if( SUCCEEDED(hr) && folder != NULL )
- {
- HSTRING path = NULL;
- IStorageItem *item = NULL;
- PCWSTR pszPathTemp;
- hr = IStorageFolder_QueryInterface(folder, &IID_IStorageItem, (void**)&item);
- if (FAILED(hr))
- goto end_folder;
- hr = IStorageItem_get_Path(item, &path);
- if (FAILED(hr))
- goto end_folder;
- pszPathTemp = WindowsGetStringRawBuffer(path, NULL);
- result = FromWide(pszPathTemp);
-end_folder:
- WindowsDeleteString(path);
- IStorageFolder_Release(folder);
- if (item)
- IStorageItem_Release(item);
- }
+ if( FAILED(hr) || folder == NULL )
+ return NULL;
- return result;
+ return GetFolderName(folder);
}
static char *config_GetDataDir(void)
More information about the vlc-commits
mailing list