Mercurial > repos > blastem
diff util.h @ 1648:b7ecd0d6a77b mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 25 Dec 2018 11:12:26 -0800 |
parents | 7121daaa48c2 |
children | eda8df5bc74c |
line wrap: on
line diff
--- a/util.h Sun Dec 31 10:11:16 2017 -0800 +++ b/util.h Tue Dec 25 11:12:26 2018 -0800 @@ -34,16 +34,22 @@ char * split_keyval(char * text); //Takes a binary byte buffer and produces a lowercase hex string void bin_to_hex(uint8_t *output, uint8_t *input, uint64_t size); +//Takes an (optionally) null-terminated UTF16-BE string and converts a maximum of max_size code-units to UTF-8 +char *utf16be_to_utf8(uint8_t *buf, uint32_t max_size); +//Returns the next Unicode codepoint from a utf-8 string +int utf8_codepoint(const char **text); //Determines whether a character is a valid path separator for the current platform char is_path_sep(char c); //Determines whether a path is considered an absolute path on the current platform char is_absolute_path(char *path); //Returns the basename of a path with th extension (if any) stripped -char * basename_no_extension(char *path); +char * basename_no_extension(const char *path); //Returns the extension from a path or NULL if there is no extension -char *path_extension(char *path); +char *path_extension(char const *path); +//Returns true if the given path matches one of the extensions in the list +uint8_t path_matches_extensions(char *path, char **ext_list, uint32_t num_exts); //Returns the directory portion of a path or NULL if there is no directory part -char *path_dirname(char *path); +char *path_dirname(const char *path); //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 uint32_t nearest_pow2(uint32_t val); //Should be called by main with the value of argv[0] for use by get_exe_dir @@ -62,10 +68,12 @@ dir_entry *get_dir_list(char *path, size_t *numret); //Frees a dir list returned by get_dir_list void free_dir_list(dir_entry *list, size_t numentries); +//Performs a case-insensitive sort by file name on a dir list +void sort_dir_list(dir_entry *list, size_t num_entries); //Gets the modification time of a file time_t get_modification_time(char *path); //Recusrively creates a directory if it does not exist -int ensure_dir_exists(char *path); +int ensure_dir_exists(const char *path); //Returns the contents of a symlink in a newly allocated string char * readlink_alloc(char * path); //Prints an error message to stderr and to a message box if not in headless mode and then exits