comparison util.h @ 955:229c23b3ab73

Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
author Michael Pavone <pavone@retrodev.com>
date Fri, 15 Apr 2016 18:29:39 -0700
parents 540cc4a7d626
children 1618d3676a35
comparison
equal deleted inserted replaced
954:cbc5b39e5518 955:229c23b3ab73
18 long file_size(FILE * f); 18 long file_size(FILE * f);
19 //Strips whitespace and non-printable characters from the beginning and end of a string 19 //Strips whitespace and non-printable characters from the beginning and end of a string
20 char * strip_ws(char * text); 20 char * strip_ws(char * text);
21 //Inserts a null after the first word, returns a pointer to the second word 21 //Inserts a null after the first word, returns a pointer to the second word
22 char * split_keyval(char * text); 22 char * split_keyval(char * text);
23 //Returns the basename of a path with th extension (if any) stripped
24 char * basename_no_extension(char *path);
23 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 25 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000
24 uint32_t nearest_pow2(uint32_t val); 26 uint32_t nearest_pow2(uint32_t val);
25 //Should be called by main with the value of argv[0] for use by get_exe_dir 27 //Should be called by main with the value of argv[0] for use by get_exe_dir
26 void set_exe_str(char * str); 28 void set_exe_str(char * str);
27 //Returns the directory the executable is in 29 //Returns the directory the executable is in
28 char * get_exe_dir(); 30 char * get_exe_dir();
29 //Returns the user's home directory 31 //Returns the user's home directory
30 char * get_home_dir(); 32 char * get_home_dir();
31 //Returns an appropriate path for storing config files 33 //Returns an appropriate path for storing config files
32 char const *get_config_dir(); 34 char const *get_config_dir();
35 //Returns an appropriate path for saving non-config data like savestates
36 char const *get_save_dir();
33 //Reads a file bundled with the executable 37 //Reads a file bundled with the executable
34 char *read_bundled_file(char *name, long *sizeret); 38 char *read_bundled_file(char *name, long *sizeret);
35 //Retunrs an array of normal files and directories residing in a directory 39 //Retunrs an array of normal files and directories residing in a directory
36 dir_entry *get_dir_list(char *path, size_t *numret); 40 dir_entry *get_dir_list(char *path, size_t *numret);
37 //Frees a dir list returned by get_dir_list 41 //Frees a dir list returned by get_dir_list
38 void free_dir_list(dir_entry *list, size_t numentries); 42 void free_dir_list(dir_entry *list, size_t numentries);
43 //Recusrively creates a directory if it does not exist
44 int ensure_dir_exists(char *path);
39 //Returns the contents of a symlink in a newly allocated string 45 //Returns the contents of a symlink in a newly allocated string
40 char * readlink_alloc(char * path); 46 char * readlink_alloc(char * path);
41 //Prints an error message to stderr and to a message box if not in headless mode and then exits 47 //Prints an error message to stderr and to a message box if not in headless mode and then exits
42 void fatal_error(char *format, ...); 48 void fatal_error(char *format, ...);
43 //Prints an information message to stdout and to a message box if not in headless mode and not attached to a console 49 //Prints an information message to stdout and to a message box if not in headless mode and not attached to a console