1 /* 2 Native File Dialog 3 4 User API 5 6 http://www.frogtoss.com/labs 7 */ 8 9 10 #ifndef _NFD_H 11 #define _NFD_H 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #include <stddef.h> 18 19 /* denotes UTF-8 char */ 20 typedef char nfdchar_t; 21 22 /* opaque data structure -- see NFD_PathSet_* */ 23 typedef struct { 24 nfdchar_t *buf; 25 size_t *indices; /* byte offsets into buf */ 26 size_t count; /* number of indices into buf */ 27 }nfdpathset_t; 28 29 typedef enum { 30 NFD_ERROR, /* programmatic error */ 31 NFD_OKAY, /* user pressed okay, or successful return */ 32 NFD_CANCEL /* user pressed cancel */ 33 }nfdresult_t; 34 35 36 /* nfd_<targetplatform>.c */ 37 38 /* single file open dialog */ 39 nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, 40 const nfdchar_t *defaultPath, 41 nfdchar_t **outPath ); 42 43 /* multiple file open dialog */ 44 nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, 45 const nfdchar_t *defaultPath, 46 nfdpathset_t *outPaths ); 47 48 /* save dialog */ 49 nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, 50 const nfdchar_t *defaultPath, 51 nfdchar_t **outPath ); 52 53 54 /* select folder dialog */ 55 nfdresult_t NFD_PickFolder( const nfdchar_t *defaultPath, 56 nfdchar_t **outPath); 57 58 /* nfd_common.c */ 59 60 /* free the memory allocated for a path */ 61 void NFD_FreePath( nfdchar_t *outPath ); 62 /* get last error -- set when nfdresult_t returns NFD_ERROR */ 63 const char *NFD_GetError( void ); 64 /* get the number of entries stored in pathSet */ 65 size_t NFD_PathSet_GetCount( const nfdpathset_t *pathSet ); 66 /* Get the UTF-8 path at offset index */ 67 nfdchar_t *NFD_PathSet_GetPath( const nfdpathset_t *pathSet, size_t index ); 68 /* Free the pathSet */ 69 void NFD_PathSet_Free( nfdpathset_t *pathSet ); 70 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif 77