diff --git a/src/include/nfd.h b/src/include/nfd.h index 495e883..20926b0 100644 --- a/src/include/nfd.h +++ b/src/include/nfd.h @@ -33,12 +33,14 @@ extern "C" { #include +typedef char nfdu8char_t; + #ifdef _WIN32 /* denotes UTF-16 char */ typedef wchar_t nfdnchar_t; #else /* denotes UTF-8 char */ -typedef char nfdnchar_t; +typedef nfdu8char_t nfdnchar_t; #endif // _WIN32 /* opaque data structure -- see NFD_PathSet_* */ @@ -74,15 +76,30 @@ typedef enum { NFD_CANCEL /* user pressed cancel */ } nfdresult_t; +typedef struct { + const nfdu8char_t* name; + const nfdu8char_t* spec; +} nfdu8filteritem_t; + +#ifdef _WIN32 +/* denotes UTF-16 Filter Item */ typedef struct { const nfdnchar_t* name; const nfdnchar_t* spec; } nfdnfilteritem_t; +#else +/* denotes UTF-8 Filter Item */ +typedef nfdu8filteritem_t nfdnfilteritem_t; +#endif // _WIN32 /* free a file path that was returned by the dialogs */ -/* Note: use NFD_PathSet_FreePath to free path from pathset instead of this function */ +/* Note: use NFD_PathSet_FreePathN to free path from pathset instead of this function */ NFD_API void NFD_FreePathN(nfdnchar_t* filePath); +/* free a file path that was returned by the dialogs */ +/* Note: use NFD_PathSet_FreePathU8 to free path from pathset instead of this function */ +NFD_API void NFD_FreePathU8(nfdu8char_t* filePath); + /* initialize NFD - call this for every thread that might use NFD, before calling any other NFD * functions on that thread */ NFD_API nfdresult_t NFD_Init(void); @@ -100,8 +117,18 @@ NFD_API nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, nfdfiltersize_t filterCount, const nfdnchar_t* defaultPath); +/* single file open dialog */ +/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns + * NFD_OKAY */ +/* If filterCount is zero, filterList is ignored (you can use NULL) */ +/* If defaultPath is NULL, the operating system will decide */ +NFD_API nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath); + /* multiple file open dialog */ -/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_Free() if this function +/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_FreeN() if this function * returns NFD_OKAY */ /* If filterCount is zero, filterList is ignored (you can use NULL) */ /* If defaultPath is NULL, the operating system will decide */ @@ -110,6 +137,16 @@ NFD_API nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, nfdfiltersize_t filterCount, const nfdnchar_t* defaultPath); +/* multiple file open dialog */ +/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_FreeU8() if this function + * returns NFD_OKAY */ +/* If filterCount is zero, filterList is ignored (you can use NULL) */ +/* If defaultPath is NULL, the operating system will decide */ +NFD_API nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath); + /* save dialog */ /* It is the caller's responsibility to free `outPath` via NFD_FreePathN() if this function returns * NFD_OKAY */ @@ -121,12 +158,29 @@ NFD_API nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath, const nfdnchar_t* defaultName); +/* save dialog */ +/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns + * NFD_OKAY */ +/* If filterCount is zero, filterList is ignored (you can use NULL) */ +/* If defaultPath is NULL, the operating system will decide */ +NFD_API nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath, + const nfdu8char_t* defaultName); + /* select folder dialog */ /* It is the caller's responsibility to free `outPath` via NFD_FreePathN() if this function returns * NFD_OKAY */ /* If defaultPath is NULL, the operating system will decide */ NFD_API nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath); +/* select folder dialog */ +/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns + * NFD_OKAY */ +/* If defaultPath is NULL, the operating system will decide */ +NFD_API nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath); + /* Get last error -- set when nfdresult_t returns NFD_ERROR */ /* Returns the last error that was set, or NULL if there is no error. */ /* The memory is owned by NFD and should not be freed by user code. */ @@ -149,20 +203,22 @@ typedef unsigned int nfdpathsetsize_t; /* note that some paths might be invalid (NFD_ERROR will be returned by NFD_PathSet_GetPath), so we * might not actually have this number of usable paths */ NFD_API nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count); -/* Gets the UTF-8 path at offset index */ +/* Gets the native path at offset index */ /* It is the caller's responsibility to free `outPath` via NFD_PathSet_FreePathN() if this function * returns NFD_OKAY */ NFD_API nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, nfdpathsetsize_t index, nfdnchar_t** outPath); +/* Gets the UTF-8 path at offset index */ +/* It is the caller's responsibility to free `outPath` via NFD_PathSet_FreePathU8() if this function + * returns NFD_OKAY */ +NFD_API nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, + nfdpathsetsize_t index, + nfdu8char_t** outPath); /* Free the path gotten by NFD_PathSet_GetPathN */ -#ifdef _WIN32 -#define NFD_PathSet_FreePathN NFD_FreePathN -#elif __APPLE__ -#define NFD_PathSet_FreePathN NFD_FreePathN -#else NFD_API void NFD_PathSet_FreePathN(const nfdnchar_t* filePath); -#endif // _WIN32, __APPLE__ +/* Free the path gotten by NFD_PathSet_GetPathU8 */ +NFD_API void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath); /* Gets an enumerator of the path set. */ /* It is the caller's responsibility to free `enumerator` via NFD_PathSet_FreeEnum() if this @@ -173,74 +229,25 @@ NFD_API nfdresult_t NFD_PathSet_GetEnum(const nfdpathset_t* pathSet, NFD_API void NFD_PathSet_FreeEnum(nfdpathsetenum_t* enumerator); /* Gets the next item from the path set enumerator. * If there are no more items, then *outPaths will be set to NULL. */ -/* It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePath() if this +/* It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePathN() if this * function returns NFD_OKAY and `*outPath` is not null */ NFD_API nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** outPath); +/* Gets the next item from the path set enumerator. + * If there are no more items, then *outPaths will be set to NULL. */ +/* It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePathU8() if this + * function returns NFD_OKAY and `*outPath` is not null */ +NFD_API nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath); /* Free the pathSet */ NFD_API void NFD_PathSet_Free(const nfdpathset_t* pathSet); #ifdef _WIN32 -/* say that the U8 versions of functions are not just #defined to be the native versions */ +/* say that the U8 versions of functions are not just __attribute__((alias(""))) to the native + * versions */ #define NFD_DIFFERENT_NATIVE_FUNCTIONS -typedef char nfdu8char_t; - -typedef struct { - const nfdu8char_t* name; - const nfdu8char_t* spec; -} nfdu8filteritem_t; - -/* UTF-8 compatibility functions */ - -/* free a file path that was returned */ -NFD_API void NFD_FreePathU8(nfdu8char_t* outPath); - -/* single file open dialog */ -/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns - * NFD_OKAY */ -NFD_API nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, - const nfdu8filteritem_t* filterList, - nfdfiltersize_t count, - const nfdu8char_t* defaultPath); - -/* multiple file open dialog */ -/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_Free() if this function - * returns NFD_OKAY */ -NFD_API nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, - const nfdu8filteritem_t* filterList, - nfdfiltersize_t count, - const nfdu8char_t* defaultPath); - -/* save dialog */ -/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns - * NFD_OKAY */ -NFD_API nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, - const nfdu8filteritem_t* filterList, - nfdfiltersize_t count, - const nfdu8char_t* defaultPath, - const nfdu8char_t* defaultName); - -/* select folder dialog */ -/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns - * NFD_OKAY */ -NFD_API nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath); - -/* Get the UTF-8 path at offset index */ -/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns - * NFD_OKAY */ -NFD_API nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, - nfdpathsetsize_t index, - nfdu8char_t** outPath); - -/* Gets the next item from the path set enumerator. - * If there are no more items, then *outPaths will be set to NULL. */ -/* It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePathU8() if this - * function returns NFD_OKAY and `*outPath` is not null */ -NFD_API nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath); - -#define NFD_PathSet_FreePathU8 NFD_FreePathU8 +#endif // _WIN32 #ifdef NFD_NATIVE typedef nfdnchar_t nfdchar_t; @@ -266,32 +273,6 @@ typedef nfdu8filteritem_t nfdfilteritem_t; #define NFD_PathSet_EnumNext NFD_PathSet_EnumNextU8 #endif // NFD_NATIVE -#else // _WIN32 - -/* the native charset is already UTF-8 */ -typedef nfdnchar_t nfdchar_t; -typedef nfdnfilteritem_t nfdfilteritem_t; -#define NFD_FreePath NFD_FreePathN -#define NFD_OpenDialog NFD_OpenDialogN -#define NFD_OpenDialogMultiple NFD_OpenDialogMultipleN -#define NFD_SaveDialog NFD_SaveDialogN -#define NFD_PickFolder NFD_PickFolderN -#define NFD_PathSet_GetPath NFD_PathSet_GetPathN -#define NFD_PathSet_FreePath NFD_PathSet_FreePathN -#define NFD_PathSet_EnumNext NFD_PathSet_EnumNextN -typedef nfdnchar_t nfdu8char_t; -typedef nfdnfilteritem_t nfdu8filteritem_t; -#define NFD_FreePathU8 NFD_FreePathN -#define NFD_OpenDialogU8 NFD_OpenDialogN -#define NFD_OpenDialogMultipleU8 NFD_OpenDialogMultipleN -#define NFD_SaveDialogU8 NFD_SaveDialogN -#define NFD_PickFolderU8 NFD_PickFolderN -#define NFD_PathSet_GetPathU8 NFD_PathSet_GetPathN -#define NFD_PathSet_FreePathU8 NFD_PathSet_FreePathN -#define NFD_PathSet_EnumNextU8 NFD_PathSet_EnumNextN - -#endif // _WIN32 - #ifdef __cplusplus } #endif // __cplusplus diff --git a/src/nfd_cocoa.m b/src/nfd_cocoa.m index aeffb1c..babd6d4 100644 --- a/src/nfd_cocoa.m +++ b/src/nfd_cocoa.m @@ -188,6 +188,10 @@ void NFD_FreePathN(nfdnchar_t* filePath) { NFDi_Free((void*)filePath); } +void NFD_FreePathU8(nfdu8char_t* filePath) { + NFD_FreePathN(filePath); +} + static NSApplicationActivationPolicy old_app_policy; nfdresult_t NFD_Init(void) { @@ -236,6 +240,13 @@ nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, return result; } +nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) { + return NFD_OpenDialogN(outPath, filterList, filterCount, defaultPath); +} + nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -270,6 +281,13 @@ nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, return result; } +nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) { + return NFD_OpenDialogMultipleN(outPaths, filterList, filterCount, defaultPath); +} + nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -306,6 +324,14 @@ nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, return result; } +nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath, + const nfdu8char_t* defaultName) { + return NFD_SaveDialogN(outPath, filterList, filterCount, defaultPath, defaultName); +} + nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) { nfdresult_t result = NFD_CANCEL; @autoreleasepool { @@ -332,6 +358,10 @@ nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) return result; } +nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath) { + return NFD_PickFolderN(outPath, defaultPath); +} + nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count) { const NSArray* urls = (const NSArray*)pathSet; *count = [urls count]; @@ -351,6 +381,36 @@ nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, } } +nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, + nfdpathsetsize_t index, + nfdu8char_t** outPath) { + return NFD_PathSet_GetPathN(pathSet, index, outPath); +} + +void NFD_PathSet_FreePathN(const nfdnchar_t* filePath) { + // const_cast not supported on Mac + union { + const nfdnchar_t* constPath; + nfdnchar_t* nonConstPath; + } pathUnion; + + pathUnion.constPath = filePath; + + NFD_FreePathN(pathUnion.nonConstPath); +} + +void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath) { + // const_cast not supported on Mac + union { + const nfdu8char_t* constPath; + nfdu8char_t* nonConstPath; + } pathUnion; + + pathUnion.constPath = filePath; + + NFD_FreePathU8(pathUnion.nonConstPath); +} + void NFD_PathSet_Free(const nfdpathset_t* pathSet) { const NSArray* urls = (const NSArray*)pathSet; [urls release]; @@ -389,3 +449,7 @@ nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** out } } } + +nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) { + return NFD_PathSet_EnumNextN(enumerator, outPath); +} diff --git a/src/nfd_gtk.cpp b/src/nfd_gtk.cpp index dda56a8..cb1696d 100644 --- a/src/nfd_gtk.cpp +++ b/src/nfd_gtk.cpp @@ -410,6 +410,8 @@ void NFD_FreePathN(nfdnchar_t* filePath) { g_free(filePath); } +void NFD_FreePathU8(nfdu8char_t* filePath) __attribute__((alias("NFD_FreePathN"))); + nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -442,6 +444,12 @@ nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, } } +nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_OpenDialogN"))); + nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -478,6 +486,12 @@ nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, } } +nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_OpenDialogMultipleN"))); + nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -534,6 +548,13 @@ nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, } } +nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath, + const nfdu8char_t* defaultName) + __attribute__((alias("NFD_SaveDialogN"))); + nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) { GtkWidget* widget = gtk_file_chooser_dialog_new("Select folder", nullptr, @@ -560,6 +581,9 @@ nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) } } +nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_PickFolderN"))); + nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count) { assert(pathSet); // const_cast because methods on GSList aren't const, but it should act @@ -584,12 +608,20 @@ nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, return NFD_OKAY; } +nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, + nfdpathsetsize_t index, + nfdu8char_t** outPath) + __attribute__((alias("NFD_PathSet_GetPathN"))); + void NFD_PathSet_FreePathN(const nfdnchar_t* filePath) { assert(filePath); (void)filePath; // prevent warning in release build // no-op, because NFD_PathSet_Free does the freeing for us } +void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath) + __attribute__((alias("NFD_PathSet_FreePathN"))); + void NFD_PathSet_Free(const nfdpathset_t* pathSet) { assert(pathSet); // const_cast because methods on GSList aren't const, but it should act @@ -629,3 +661,6 @@ nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** out return NFD_OKAY; } + +nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) + __attribute__((alias("NFD_PathSet_EnumNextN"))); diff --git a/src/nfd_portal.cpp b/src/nfd_portal.cpp index 23e1f1f..655dcb8 100644 --- a/src/nfd_portal.cpp +++ b/src/nfd_portal.cpp @@ -1371,6 +1371,8 @@ void NFD_FreePathN(nfdnchar_t* filePath) { NFDi_Free(filePath); } +void NFD_FreePathU8(nfdu8char_t* filePath) __attribute__((alias("NFD_FreePathN"))); + nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -1396,6 +1398,12 @@ nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, return AllocAndCopyFilePath(uri, *outPath); } +nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_OpenDialogN"))); + nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -1420,6 +1428,12 @@ nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, return NFD_OKAY; } +nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_OpenDialogMultipleN"))); + nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, const nfdnfilteritem_t* filterList, nfdfiltersize_t filterCount, @@ -1459,6 +1473,13 @@ nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, #endif } +nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, + const nfdu8filteritem_t* filterList, + nfdfiltersize_t filterCount, + const nfdu8char_t* defaultPath, + const nfdu8char_t* defaultName) + __attribute__((alias("NFD_SaveDialogN"))); + nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) { (void)defaultPath; // Default path not supported for portal backend @@ -1498,6 +1519,9 @@ nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) return AllocAndCopyFilePath(uri, *outPath); } +nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath) + __attribute__((alias("NFD_PickFolderN"))); + nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count) { assert(pathSet); DBusMessage* msg = const_cast(static_cast(pathSet)); @@ -1533,11 +1557,19 @@ nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, return AllocAndCopyFilePath(uri, *outPath); } +nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, + nfdpathsetsize_t index, + nfdu8char_t** outPath) + __attribute__((alias("NFD_PathSet_GetPathN"))); + void NFD_PathSet_FreePathN(const nfdnchar_t* filePath) { assert(filePath); NFD_FreePathN(const_cast(filePath)); } +void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath) + __attribute__((alias("NFD_PathSet_FreePathN"))); + void NFD_PathSet_Free(const nfdpathset_t* pathSet) { assert(pathSet); DBusMessage* msg = const_cast(static_cast(pathSet)); @@ -1573,3 +1605,6 @@ nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** out dbus_message_iter_next(&uri_iter); return NFD_OKAY; } + +nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) + __attribute__((alias("NFD_PathSet_EnumNextN"))); diff --git a/src/nfd_win.cpp b/src/nfd_win.cpp index 772dfb2..e83cc72 100644 --- a/src/nfd_win.cpp +++ b/src/nfd_win.cpp @@ -639,6 +639,10 @@ nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, return NFD_OKAY; } +void NFD_PathSet_FreePathN(const nfdnchar_t* filePath) { + NFD_FreePathN(const_cast(filePath)); +} + nfdresult_t NFD_PathSet_GetEnum(const nfdpathset_t* pathSet, nfdpathsetenum_t* outEnumerator) { assert(pathSet); // const_cast because methods on IShellItemArray aren't const, but it should act like const to @@ -945,6 +949,10 @@ nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, return res; } +void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath) { + NFD_FreePathU8(const_cast(filePath)); +} + nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) { // call the native function nfdnchar_t* outPathN;