#ifdef _WIN32
  #include <direct.h>
 
  int open_dir(char *name);
  char* next_fname();
  
  #define cdir_open_dir(str) open_dir
  #define cdir_next_fname next_fname
  #define cdir_mkdir(dname, mode) _mkdir((char *)dname)
  #define cdir_rmdir(dname) _rmdir((char *)dname)
  #define cdir_chdir(dname) _chdir((char *)dname)
  #define cdir_getcwd(arg) _getcwd(0,0)
#else
  #include <sys/stat.h>
  #include <stdlib.h>
  #include <dirent.h>
  
  DIR* open_dir(char *name);
  char* next_fname();

  #define cdir_open_dir(str) open_dir((char *)str)
  #define cdir_next_fname next_fname
  #define cdir_mkdir(dname, mode) mkdir((char *)dname, mode)
  #define cdir_rmdir(dname) rmdir((char *)dname)
  #define cdir_chdir(dname) chdir((char *)dname)
  #define cdir_getcwd(arg) getcwd(0,0)
#endif
