|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _NFD_H |
|
|
#define _NFD_H |
|
|
|
|
|
#if defined(_WIN32) |
|
|
#if defined(NFD_EXPORT) |
|
|
#define NFD_API __declspec(dllexport) |
|
|
#elif defined(NFD_SHARED) |
|
|
#define NFD_API __declspec(dllimport) |
|
|
#endif |
|
|
#else |
|
|
#if defined(NFD_EXPORT) || defined(NFD_SHARED) |
|
|
#if defined(__GNUC__) || defined(__clang__) |
|
|
#define NFD_API __attribute__((visibility("default"))) |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
#ifndef NFD_API |
|
|
#define NFD_API |
|
|
#endif |
|
|
|
|
|
#ifdef __cplusplus |
|
|
extern "C" { |
|
|
#define NFD_INLINE inline |
|
|
#else |
|
|
#define NFD_INLINE static inline |
|
|
#endif |
|
|
|
|
|
#include <stddef.h> |
|
|
|
|
|
typedef char nfdu8char_t; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
typedef wchar_t nfdnchar_t; |
|
|
#else |
|
|
|
|
|
typedef nfdu8char_t nfdnchar_t; |
|
|
#endif |
|
|
|
|
|
|
|
|
typedef void nfdpathset_t; |
|
|
#ifndef NFD_PORTAL |
|
|
typedef struct { |
|
|
void* ptr; |
|
|
} nfdpathsetenum_t; |
|
|
#else |
|
|
typedef struct { |
|
|
void* d1; |
|
|
void* d2; |
|
|
unsigned int d3; |
|
|
int d4; |
|
|
int d5; |
|
|
int d6; |
|
|
int d7; |
|
|
int d8; |
|
|
int d9; |
|
|
int d10; |
|
|
int d11; |
|
|
int p1; |
|
|
void* p2; |
|
|
void* p3; |
|
|
} nfdpathsetenum_t; |
|
|
#endif |
|
|
|
|
|
typedef unsigned int nfdfiltersize_t; |
|
|
|
|
|
typedef enum { |
|
|
NFD_ERROR, |
|
|
NFD_OKAY, |
|
|
NFD_CANCEL |
|
|
} nfdresult_t; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
const nfdu8char_t* name; |
|
|
const nfdu8char_t* spec; |
|
|
} nfdu8filteritem_t; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
typedef struct { |
|
|
const nfdnchar_t* name; |
|
|
const nfdnchar_t* spec; |
|
|
} nfdnfilteritem_t; |
|
|
#else |
|
|
|
|
|
typedef nfdu8filteritem_t nfdnfilteritem_t; |
|
|
#endif |
|
|
|
|
|
|
|
|
enum { |
|
|
NFD_WINDOW_HANDLE_TYPE_UNSET = 0, |
|
|
|
|
|
NFD_WINDOW_HANDLE_TYPE_WINDOWS = 1, |
|
|
|
|
|
NFD_WINDOW_HANDLE_TYPE_COCOA = 2, |
|
|
|
|
|
NFD_WINDOW_HANDLE_TYPE_X11 = 3, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
size_t type; |
|
|
void* handle; |
|
|
} nfdwindowhandle_t; |
|
|
|
|
|
typedef size_t nfdversion_t; |
|
|
|
|
|
typedef struct { |
|
|
const nfdu8filteritem_t* filterList; |
|
|
nfdfiltersize_t filterCount; |
|
|
const nfdu8char_t* defaultPath; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdopendialogu8args_t; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
typedef struct { |
|
|
const nfdnfilteritem_t* filterList; |
|
|
nfdfiltersize_t filterCount; |
|
|
const nfdnchar_t* defaultPath; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdopendialognargs_t; |
|
|
#else |
|
|
typedef nfdopendialogu8args_t nfdopendialognargs_t; |
|
|
#endif |
|
|
|
|
|
typedef struct { |
|
|
const nfdu8filteritem_t* filterList; |
|
|
nfdfiltersize_t filterCount; |
|
|
const nfdu8char_t* defaultPath; |
|
|
const nfdu8char_t* defaultName; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdsavedialogu8args_t; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
typedef struct { |
|
|
const nfdnfilteritem_t* filterList; |
|
|
nfdfiltersize_t filterCount; |
|
|
const nfdnchar_t* defaultPath; |
|
|
const nfdnchar_t* defaultName; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdsavedialognargs_t; |
|
|
#else |
|
|
typedef nfdsavedialogu8args_t nfdsavedialognargs_t; |
|
|
#endif |
|
|
|
|
|
typedef struct { |
|
|
const nfdu8char_t* defaultPath; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdpickfolderu8args_t; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
typedef struct { |
|
|
const nfdnchar_t* defaultPath; |
|
|
nfdwindowhandle_t parentWindow; |
|
|
} nfdpickfoldernargs_t; |
|
|
#else |
|
|
typedef nfdpickfolderu8args_t nfdpickfoldernargs_t; |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NFD_INTERFACE_VERSION 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API void NFD_FreePathN(nfdnchar_t* filePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API void NFD_FreePathU8(nfdu8char_t* filePath); |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_Init(void); |
|
|
|
|
|
|
|
|
NFD_API void NFD_Quit(void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, |
|
|
const nfdnfilteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdnchar_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, |
|
|
const nfdu8filteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdu8char_t* defaultPath); |
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogN_With_Impl(nfdversion_t version, |
|
|
nfdnchar_t** outPath, |
|
|
const nfdopendialognargs_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_OpenDialogN_With(nfdnchar_t** outPath, |
|
|
const nfdopendialognargs_t* args) { |
|
|
return NFD_OpenDialogN_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogU8_With_Impl(nfdversion_t version, |
|
|
nfdu8char_t** outPath, |
|
|
const nfdopendialogu8args_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_OpenDialogU8_With(nfdu8char_t** outPath, |
|
|
const nfdopendialogu8args_t* args) { |
|
|
return NFD_OpenDialogU8_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, |
|
|
const nfdnfilteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdnchar_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, |
|
|
const nfdu8filteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdu8char_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogMultipleN_With_Impl(nfdversion_t version, |
|
|
const nfdpathset_t** outPaths, |
|
|
const nfdopendialognargs_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_OpenDialogMultipleN_With(const nfdpathset_t** outPaths, |
|
|
const nfdopendialognargs_t* args) { |
|
|
return NFD_OpenDialogMultipleN_With_Impl(NFD_INTERFACE_VERSION, outPaths, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_OpenDialogMultipleU8_With_Impl(nfdversion_t version, |
|
|
const nfdpathset_t** outPaths, |
|
|
const nfdopendialogu8args_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_OpenDialogMultipleU8_With(const nfdpathset_t** outPaths, |
|
|
const nfdopendialogu8args_t* args) { |
|
|
return NFD_OpenDialogMultipleU8_With_Impl(NFD_INTERFACE_VERSION, outPaths, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, |
|
|
const nfdnfilteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdnchar_t* defaultPath, |
|
|
const nfdnchar_t* defaultName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, |
|
|
const nfdu8filteritem_t* filterList, |
|
|
nfdfiltersize_t filterCount, |
|
|
const nfdu8char_t* defaultPath, |
|
|
const nfdu8char_t* defaultName); |
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_SaveDialogN_With_Impl(nfdversion_t version, |
|
|
nfdnchar_t** outPath, |
|
|
const nfdsavedialognargs_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_SaveDialogN_With(nfdnchar_t** outPath, |
|
|
const nfdsavedialognargs_t* args) { |
|
|
return NFD_SaveDialogN_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_SaveDialogU8_With_Impl(nfdversion_t version, |
|
|
nfdu8char_t** outPath, |
|
|
const nfdsavedialogu8args_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_SaveDialogU8_With(nfdu8char_t** outPath, |
|
|
const nfdsavedialogu8args_t* args) { |
|
|
return NFD_SaveDialogU8_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath); |
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderN_With_Impl(nfdversion_t version, |
|
|
nfdnchar_t** outPath, |
|
|
const nfdpickfoldernargs_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_PickFolderN_With(nfdnchar_t** outPath, |
|
|
const nfdpickfoldernargs_t* args) { |
|
|
return NFD_PickFolderN_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderU8_With_Impl(nfdversion_t version, |
|
|
nfdu8char_t** outPath, |
|
|
const nfdpickfolderu8args_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_PickFolderU8_With(nfdu8char_t** outPath, |
|
|
const nfdpickfolderu8args_t* args) { |
|
|
return NFD_PickFolderU8_With_Impl(NFD_INTERFACE_VERSION, outPath, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderMultipleN(const nfdpathset_t** outPaths, |
|
|
const nfdnchar_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderMultipleU8(const nfdpathset_t** outPaths, |
|
|
const nfdu8char_t* defaultPath); |
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderMultipleN_With_Impl(nfdversion_t version, |
|
|
const nfdpathset_t** outPaths, |
|
|
const nfdpickfoldernargs_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_PickFolderMultipleN_With(const nfdpathset_t** outPaths, |
|
|
const nfdpickfoldernargs_t* args) { |
|
|
return NFD_PickFolderMultipleN_With_Impl(NFD_INTERFACE_VERSION, outPaths, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PickFolderMultipleU8_With_Impl(nfdversion_t version, |
|
|
const nfdpathset_t** outPaths, |
|
|
const nfdpickfolderu8args_t* args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_INLINE nfdresult_t NFD_PickFolderMultipleU8_With(const nfdpathset_t** outPaths, |
|
|
const nfdpickfolderu8args_t* args) { |
|
|
return NFD_PickFolderMultipleU8_With_Impl(NFD_INTERFACE_VERSION, outPaths, args); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API const char* NFD_GetError(void); |
|
|
|
|
|
|
|
|
NFD_API void NFD_ClearError(void); |
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
typedef unsigned long nfdpathsetsize_t; |
|
|
#elif __APPLE__ |
|
|
typedef unsigned long nfdpathsetsize_t; |
|
|
#else |
|
|
typedef unsigned int nfdpathsetsize_t; |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, |
|
|
nfdpathsetsize_t index, |
|
|
nfdnchar_t** outPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, |
|
|
nfdpathsetsize_t index, |
|
|
nfdu8char_t** outPath); |
|
|
|
|
|
|
|
|
NFD_API void NFD_PathSet_FreePathN(const nfdnchar_t* filePath); |
|
|
|
|
|
|
|
|
NFD_API void NFD_PathSet_FreePathU8(const nfdu8char_t* filePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_GetEnum(const nfdpathset_t* pathSet, |
|
|
nfdpathsetenum_t* outEnumerator); |
|
|
|
|
|
|
|
|
NFD_API void NFD_PathSet_FreeEnum(nfdpathsetenum_t* enumerator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** outPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NFD_API nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath); |
|
|
|
|
|
|
|
|
NFD_API void NFD_PathSet_Free(const nfdpathset_t* pathSet); |
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
|
|
|
|
#define NFD_DIFFERENT_NATIVE_FUNCTIONS |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifdef NFD_NATIVE |
|
|
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_PickFolderMultiple NFD_PickFolderMultipleN |
|
|
#define NFD_PathSet_GetPath NFD_PathSet_GetPathN |
|
|
#define NFD_PathSet_FreePath NFD_PathSet_FreePathN |
|
|
#define NFD_PathSet_EnumNext NFD_PathSet_EnumNextN |
|
|
#else |
|
|
typedef nfdu8char_t nfdchar_t; |
|
|
typedef nfdu8filteritem_t nfdfilteritem_t; |
|
|
#define NFD_FreePath NFD_FreePathU8 |
|
|
#define NFD_OpenDialog NFD_OpenDialogU8 |
|
|
#define NFD_OpenDialogMultiple NFD_OpenDialogMultipleU8 |
|
|
#define NFD_SaveDialog NFD_SaveDialogU8 |
|
|
#define NFD_PickFolder NFD_PickFolderU8 |
|
|
#define NFD_PickFolderMultiple NFD_PickFolderMultipleU8 |
|
|
#define NFD_PathSet_GetPath NFD_PathSet_GetPathU8 |
|
|
#define NFD_PathSet_FreePath NFD_PathSet_FreePathU8 |
|
|
#define NFD_PathSet_EnumNext NFD_PathSet_EnumNextU8 |
|
|
#endif |
|
|
|
|
|
#undef NFD_INLINE |
|
|
#ifdef __cplusplus |
|
|
} |
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|