31 #define DIRECTORY_SEPARATOR '\\'
33 #define DIRECTORY_SEPARATOR '/'
46 if (strlen(path) > 1 && path[0] ==
'/') {
50 #if (defined OS_WIN32 || defined __CYGWIN__)
51 if (strlen(path) > 2) {
52 if (isalpha((
unsigned char)path[0]) && path[1] ==
':') {
86 TmEcode PathJoin (
char *out_buf, uint16_t buf_len,
const char *
const dir,
const char *
const fname)
89 uint16_t max_path_len =
MAX(buf_len, PATH_MAX);
90 int bytes_written = snprintf(out_buf, max_path_len,
"%s%c%s", dir,
DIRECTORY_SEPARATOR, fname);
91 if (bytes_written <= 0) {
96 if (tmp_buf == NULL) {
97 SCLogError(
"Error resolving path: %s", strerror(errno));
100 memset(out_buf, 0, buf_len);
101 strlcpy(out_buf, tmp_buf, max_path_len);
111 return SCMkDir(path, S_IRWXU | S_IRGRP | S_IXGRP);
125 char pathbuf[PATH_MAX];
127 size_t len = strlen(path);
129 if (
len > PATH_MAX - 1) {
133 strlcpy(pathbuf, path,
sizeof(pathbuf));
135 for (p = pathbuf + 1; *p; p++) {
141 if (errno != EEXIST) {
152 if (errno != EEXIST) {
172 if (stat(path, &sb) == 0) {
189 if ((dir_entry->d_type == DT_DIR) &&
190 (strcmp(dir_entry->d_name,
".") != 0) &&
191 (strcmp(dir_entry->d_name,
"..") != 0)) {
207 return dir_entry->d_type == DT_REG;
223 return _fullpath(resolved_path, path, PATH_MAX);
225 return realpath(path, resolved_path);
237 if (!path || strlen(path) == 0)
244 if (*(
final + 1) ==
'\0')