comparison util.h @ 1541:f8ef74e7c800

Merged nuklear_ui into default
author Michael Pavone <pavone@retrodev.com>
date Sun, 25 Mar 2018 12:01:49 -0700
parents e94cff9cb625
children 5efeca06d942
comparison
equal deleted inserted replaced
1533:78b7fc03c7c6 1541:f8ef74e7c800
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);
37 //Determines whether a character is a valid path separator for the current platform 39 //Determines whether a character is a valid path separator for the current platform
38 char is_path_sep(char c); 40 char is_path_sep(char c);
39 //Determines whether a path is considered an absolute path on the current platform 41 //Determines whether a path is considered an absolute path on the current platform
40 char is_absolute_path(char *path); 42 char is_absolute_path(char *path);
41 //Returns the basename of a path with th extension (if any) stripped 43 //Returns the basename of a path with th extension (if any) stripped
42 char * basename_no_extension(char *path); 44 char * basename_no_extension(char *path);
43 //Returns the extension from a path or NULL if there is no extension 45 //Returns the extension from a path or NULL if there is no extension
44 char *path_extension(char *path); 46 char *path_extension(char const *path);
47 //Returns true if the given path matches one of the extensions in the list
48 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 49 //Returns the directory portion of a path or NULL if there is no directory part
46 char *path_dirname(char *path); 50 char *path_dirname(char *path);
47 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 51 //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); 52 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 53 //Should be called by main with the value of argv[0] for use by get_exe_dir
60 char *read_bundled_file(char *name, uint32_t *sizeret); 64 char *read_bundled_file(char *name, uint32_t *sizeret);
61 //Retunrs an array of normal files and directories residing in a directory 65 //Retunrs an array of normal files and directories residing in a directory
62 dir_entry *get_dir_list(char *path, size_t *numret); 66 dir_entry *get_dir_list(char *path, size_t *numret);
63 //Frees a dir list returned by get_dir_list 67 //Frees a dir list returned by get_dir_list
64 void free_dir_list(dir_entry *list, size_t numentries); 68 void free_dir_list(dir_entry *list, size_t numentries);
69 //Performs a case-insensitive sort by file name on a dir list
70 void sort_dir_list(dir_entry *list, size_t num_entries);
65 //Gets the modification time of a file 71 //Gets the modification time of a file
66 time_t get_modification_time(char *path); 72 time_t get_modification_time(char *path);
67 //Recusrively creates a directory if it does not exist 73 //Recusrively creates a directory if it does not exist
68 int ensure_dir_exists(char *path); 74 int ensure_dir_exists(const char *path);
69 //Returns the contents of a symlink in a newly allocated string 75 //Returns the contents of a symlink in a newly allocated string
70 char * readlink_alloc(char * path); 76 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 77 //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, ...); 78 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 79 //Prints an information message to stdout and to a message box if not in headless mode and not attached to a console