normalize_path support file resource start with file://

iovec_array
YuQing 2021-05-26 09:38:04 +08:00
parent 6fddce73c5
commit 768fbb68d4
3 changed files with 21 additions and 2 deletions

View File

@ -107,6 +107,13 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
#define IP_ADDRESS_SIZE 16
#define INFINITE_FILE_SIZE (256 * 1024LL * 1024 * 1024 * 1024 * 1024LL)
#define FILE_RESOURCE_TAG_STR "file://"
#define FILE_RESOURCE_TAG_LEN (sizeof(FILE_RESOURCE_TAG_STR) - 1)
#define IS_FILE_RESOURCE(filename) \
(strncasecmp(filename, FILE_RESOURCE_TAG_STR, \
FILE_RESOURCE_TAG_LEN) == 0)
#ifndef byte
#define byte signed char
#endif

View File

@ -60,6 +60,7 @@ int get_url_content_ex(const char *url, const int url_len,
char *pPort;
char *pSpace;
*error_info = '\0';
*http_status = 0;
if (*content == NULL)
{
@ -254,9 +255,8 @@ int get_url_content_ex(const char *url, const int url_len,
*http_status = atoi(pSpace + 1);
*content_len -= pContent - *content;
memcpy(*content, pContent, *content_len);
memmove(*content, pContent, *content_len);
*(*content + *content_len) = '\0';
*error_info = '\0';
} while (0);
close(sock);

View File

@ -2996,6 +2996,13 @@ int normalize_path(const char *from, const char *filename,
const char *last;
int len;
if (IS_FILE_RESOURCE(from)) {
from = from + FILE_RESOURCE_TAG_LEN;
}
if (IS_FILE_RESOURCE(filename)) {
filename = filename + FILE_RESOURCE_TAG_LEN;
}
if (*filename == '/') {
return snprintf(full_filename, size, "%s", filename);
}
@ -3099,6 +3106,11 @@ int normalize_path_ex(const char *from, const char *filename,
return normalize_path(from, filename, full_filename, size);
}
if (IS_FILE_RESOURCE(filename)) {
return snprintf(full_filename, size, "%s",
filename + FILE_RESOURCE_TAG_LEN);
}
if (!is_url_from) {
return snprintf(full_filename, size, "%s", filename);
}