save dialog */ It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns * NFD_OKAY */
| 862 | /* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns |
| 863 | * NFD_OKAY */ |
| 864 | nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, |
| 865 | const nfdu8filteritem_t* filterList, |
| 866 | nfdfiltersize_t count, |
| 867 | const nfdu8char_t* defaultPath, |
| 868 | const nfdu8char_t* defaultName) { |
| 869 | // populate the real nfdnfilteritem_t |
| 870 | FilterItem_Guard filterItemsNGuard; |
| 871 | if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { |
| 872 | return NFD_ERROR; |
| 873 | } |
| 874 | |
| 875 | // convert and normalize the default path, but only if it is not nullptr |
| 876 | FreeCheck_Guard<nfdnchar_t> defaultPathNGuard; |
| 877 | ConvertU8ToNative(defaultPath, defaultPathNGuard); |
| 878 | NormalizePathSeparator(defaultPathNGuard.data); |
| 879 | |
| 880 | // convert the default name, but only if it is not nullptr |
| 881 | FreeCheck_Guard<nfdnchar_t> defaultNameNGuard; |
| 882 | ConvertU8ToNative(defaultName, defaultNameNGuard); |
| 883 | |
| 884 | // call the native function |
| 885 | nfdnchar_t* outPathN; |
| 886 | nfdresult_t res = NFD_SaveDialogN( |
| 887 | &outPathN, filterItemsNGuard.data, count, defaultPathNGuard.data, defaultNameNGuard.data); |
| 888 | |
| 889 | if (res != NFD_OKAY) { |
| 890 | return res; |
| 891 | } |
| 892 | |
| 893 | // convert the outPath to UTF-8 |
| 894 | res = CopyWCharToNFDChar(outPathN, *outPath); |
| 895 | |
| 896 | // free the native out path, and return the result |
| 897 | NFD_FreePathN(outPathN); |
| 898 | return res; |
| 899 | } |
| 900 | |
| 901 | /* select folder dialog */ |
| 902 | /* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns |
no test coverage detected