nfd.h 1.8 KB

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