comparison util.h @ 1692:5dacaef602a7 segacd

Merge from default
author Michael Pavone <pavone@retrodev.com>
date Sat, 05 Jan 2019 00:58:08 -0800
parents 7121daaa48c2
children eda8df5bc74c
comparison
equal deleted inserted replaced
1504:95b3a1a8b26c 1692:5dacaef602a7
32 char * strip_ws(char * text); 32 char * strip_ws(char * text);
33 //Inserts a null after the first word, returns a pointer to the second word 33 //Inserts a null after the first word, returns a pointer to the second word
34 char * split_keyval(char * text); 34 char * split_keyval(char * text);
35 //Takes a binary byte buffer and produces a lowercase hex string 35 //Takes a binary byte buffer and produces a lowercase hex string
36 void bin_to_hex(uint8_t *output, uint8_t *input, uint64_t size); 36 void bin_to_hex(uint8_t *output, uint8_t *input, uint64_t size);
37 //Takes an (optionally) null-terminated UTF16-BE string and converts a maximum of max_size code-units to UTF-8
38 char *utf16be_to_utf8(uint8_t *buf, uint32_t max_size);
39 //Returns the next Unicode codepoint from a utf-8 string
40 int utf8_codepoint(const char **text);
37 //Determines whether a character is a valid path separator for the current platform 41 //Determines whether a character is a valid path separator for the current platform
38 char is_path_sep(char c); 42 char is_path_sep(char c);
39 //Determines whether a path is considered an absolute path on the current platform 43 //Determines whether a path is considered an absolute path on the current platform
40 char is_absolute_path(char *path); 44 char is_absolute_path(char *path);
41 //Returns the basename of a path with th extension (if any) stripped 45 //Returns the basename of a path with th extension (if any) stripped
42 char * basename_no_extension(char *path); 46 char * basename_no_extension(const char *path);
43 //Returns the extension from a path or NULL if there is no extension 47 //Returns the extension from a path or NULL if there is no extension
44 char *path_extension(char *path); 48 char *path_extension(char const *path);
49 //Returns true if the given path matches one of the extensions in the list
50 uint8_t path_matches_extensions(char *path, char **ext_list, uint32_t num_exts);
45 //Returns the directory portion of a path or NULL if there is no directory part 51 //Returns the directory portion of a path or NULL if there is no directory part
46 char *path_dirname(char *path); 52 char *path_dirname(const char *path);
47 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 53 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000
48 uint32_t nearest_pow2(uint32_t val); 54 uint32_t nearest_pow2(uint32_t val);
49 //Should be called by main with the value of argv[0] for use by get_exe_dir 55 //Should be called by main with the value of argv[0] for use by get_exe_dir
50 void set_exe_str(char * str); 56 void set_exe_str(char * str);
51 //Returns the directory the executable is in 57 //Returns the directory the executable is in
60 char *read_bundled_file(char *name, uint32_t *sizeret); 66 char *read_bundled_file(char *name, uint32_t *sizeret);
61 //Retunrs an array of normal files and directories residing in a directory 67 //Retunrs an array of normal files and directories residing in a directory
62 dir_entry *get_dir_list(char *path, size_t *numret); 68 dir_entry *get_dir_list(char *path, size_t *numret);
63 //Frees a dir list returned by get_dir_list 69 //Frees a dir list returned by get_dir_list
64 void free_dir_list(dir_entry *list, size_t numentries); 70 void free_dir_list(dir_entry *list, size_t numentries);
71 //Performs a case-insensitive sort by file name on a dir list
72 void sort_dir_list(dir_entry *list, size_t num_entries);
65 //Gets the modification time of a file 73 //Gets the modification time of a file
66 time_t get_modification_time(char *path); 74 time_t get_modification_time(char *path);
67 //Recusrively creates a directory if it does not exist 75 //Recusrively creates a directory if it does not exist
68 int ensure_dir_exists(char *path); 76 int ensure_dir_exists(const char *path);
69 //Returns the contents of a symlink in a newly allocated string 77 //Returns the contents of a symlink in a newly allocated string
70 char * readlink_alloc(char * path); 78 char * readlink_alloc(char * path);
71 //Prints an error message to stderr and to a message box if not in headless mode and then exits 79 //Prints an error message to stderr and to a message box if not in headless mode and then exits
72 void fatal_error(char *format, ...); 80 void fatal_error(char *format, ...);
73 //Prints an information message to stdout and to a message box if not in headless mode and not attached to a console 81 //Prints an information message to stdout and to a message box if not in headless mode and not attached to a console