Mercurial > repos > blastem
comparison util.h @ 1008:51885857c019
Removed assumptions that path separators are Unix style outside of Unix-only verions of functions
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 May 2016 21:39:43 -0700 |
parents | 1618d3676a35 |
children | 22e87b739ad6 |
comparison
equal
deleted
inserted
replaced
1007:5165537244e2 | 1008:51885857c019 |
---|---|
6 | 6 |
7 typedef struct { | 7 typedef struct { |
8 char *name; | 8 char *name; |
9 uint8_t is_dir; | 9 uint8_t is_dir; |
10 } dir_entry; | 10 } dir_entry; |
11 | |
12 #ifdef _WIN32 | |
13 #define PATH_SEP "\\" | |
14 #else | |
15 #define PATH_SEP "/" | |
16 #endif | |
11 | 17 |
12 //Utility functions | 18 //Utility functions |
13 | 19 |
14 //Allocates a new string containing the concatenation of first and second | 20 //Allocates a new string containing the concatenation of first and second |
15 char * alloc_concat(char const * first, char const * second); | 21 char * alloc_concat(char const * first, char const * second); |
19 long file_size(FILE * f); | 25 long file_size(FILE * f); |
20 //Strips whitespace and non-printable characters from the beginning and end of a string | 26 //Strips whitespace and non-printable characters from the beginning and end of a string |
21 char * strip_ws(char * text); | 27 char * strip_ws(char * text); |
22 //Inserts a null after the first word, returns a pointer to the second word | 28 //Inserts a null after the first word, returns a pointer to the second word |
23 char * split_keyval(char * text); | 29 char * split_keyval(char * text); |
30 //Determines whether a character is a valid path separator for the current platform | |
31 char is_path_sep(char c); | |
32 //Determines whether a path is considered an absolute path on the current platform | |
33 char is_absolute_path(char *path); | |
24 //Returns the basename of a path with th extension (if any) stripped | 34 //Returns the basename of a path with th extension (if any) stripped |
25 char * basename_no_extension(char *path); | 35 char * basename_no_extension(char *path); |
26 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 | 36 //Gets the smallest power of two that is >= a certain value, won't work for values > 0x80000000 |
27 uint32_t nearest_pow2(uint32_t val); | 37 uint32_t nearest_pow2(uint32_t val); |
28 //Should be called by main with the value of argv[0] for use by get_exe_dir | 38 //Should be called by main with the value of argv[0] for use by get_exe_dir |