mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
pathIsBaseName() added to utils.c
The function is used to test that the specified string looks like just as the basename of a path, without any absolute or relative path.
This commit is contained in:
parent
0781ad6899
commit
6978aeb3bf
@ -457,6 +457,14 @@ sds getAbsolutePath(char *filename) {
|
||||
return abspath;
|
||||
}
|
||||
|
||||
/* Return true if the specified path is just a file basename without any
|
||||
* relative or absolute path. This function just checks that no / or \
|
||||
* character exists inside the specified path, that's enough in the
|
||||
* environments where Redis runs. */
|
||||
int pathIsBaseName(char *path) {
|
||||
return strchr(path,'/') == NULL && strchr(path,'\\') == NULL;
|
||||
}
|
||||
|
||||
#ifdef UTIL_TEST_MAIN
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -40,5 +40,6 @@ int string2ll(const char *s, size_t slen, long long *value);
|
||||
int string2l(const char *s, size_t slen, long *value);
|
||||
int d2string(char *buf, size_t len, double value);
|
||||
sds getAbsolutePath(char *filename);
|
||||
int pathIsBaseName(char *path);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user