comparison util.c @ 1852:a4cae960fd08

Allow config file to be saved with executable for "portable" setups
author Michael Pavone <pavone@retrodev.com>
date Wed, 24 Apr 2019 19:08:49 -0700
parents 30f2821ffd65
children 5a76a7373823
comparison
equal deleted inserted replaced
1851:419b458f93cd 1852:a4cae960fd08
852 void sort_dir_list(dir_entry *list, size_t num_entries) 852 void sort_dir_list(dir_entry *list, size_t num_entries)
853 { 853 {
854 qsort(list, num_entries, sizeof(dir_entry), sort_dir_alpha); 854 qsort(list, num_entries, sizeof(dir_entry), sort_dir_alpha);
855 } 855 }
856 856
857 uint8_t delete_file(char *path)
858 {
859 #ifdef _WIN32
860 //TODO: Call Unicode version and prepend special string to remove max path limitation
861 return 0 != DeleteFileA(path);
862 #else
863 return 0 == unlink(path);
864 #endif
865 }
866
857 #ifdef __ANDROID__ 867 #ifdef __ANDROID__
858 868
859 #include <SDL.h> 869 #include <SDL.h>
860 #ifndef IS_LIB 870 #ifndef IS_LIB
861 char *read_bundled_file(char *name, uint32_t *sizeret) 871 char *read_bundled_file(char *name, uint32_t *sizeret)
941 ret = NULL; 951 ret = NULL;
942 } 952 }
943 fclose(f); 953 fclose(f);
944 return ret; 954 return ret;
945 } 955 }
946 #endif 956 #endif //ISLIB
947 957
948 #ifdef _WIN32 958 #ifdef _WIN32
949 char const *get_userdata_dir() 959 char const *get_userdata_dir()
950 { 960 {
951 static char path[MAX_PATH]; 961 static char path[MAX_PATH];
998 } 1008 }
999 return savedir; 1009 return savedir;
1000 } 1010 }
1001 1011
1002 1012
1003 #endif 1013 #endif //_WIN32
1004 1014 #endif //__ANDROID__
1005 1015
1006
1007 #endif