提交 25a3ad7f 编写于 作者: A antirez

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.
上级 028fdbb7
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册