mirror of
https://github.com/nginx/nginx.git
synced 2025-01-05 05:34:56 -06:00
Win32: non-ASCII directory names support in ngx_getcwd().
This makes it possible to start nginx without a prefix explicitly set in a directory with non-ASCII characters in it.
This commit is contained in:
parent
99d5ad72a4
commit
1edc23cc84
@ -429,6 +429,40 @@ ngx_realpath(u_char *path, u_char *resolved)
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
ngx_getcwd(u_char *buf, size_t size)
|
||||
{
|
||||
u_char *p;
|
||||
size_t n;
|
||||
u_short utf16[NGX_MAX_PATH];
|
||||
|
||||
n = GetCurrentDirectoryW(NGX_MAX_PATH, utf16);
|
||||
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (n > NGX_MAX_PATH) {
|
||||
ngx_set_errno(ERROR_INSUFFICIENT_BUFFER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = ngx_utf16_to_utf8(buf, utf16, &size, NULL);
|
||||
|
||||
if (p == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p != buf) {
|
||||
ngx_free(p);
|
||||
ngx_set_errno(ERROR_INSUFFICIENT_BUFFER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size - 1;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
|
||||
{
|
||||
|
@ -178,8 +178,12 @@ void ngx_close_file_mapping(ngx_file_mapping_t *fm);
|
||||
|
||||
u_char *ngx_realpath(u_char *path, u_char *resolved);
|
||||
#define ngx_realpath_n ""
|
||||
#define ngx_getcwd(buf, size) GetCurrentDirectory(size, (char *) buf)
|
||||
|
||||
|
||||
size_t ngx_getcwd(u_char *buf, size_t size);
|
||||
#define ngx_getcwd_n "GetCurrentDirectory()"
|
||||
|
||||
|
||||
#define ngx_path_separator(c) ((c) == '/' || (c) == '\\')
|
||||
|
||||
#define NGX_HAVE_MAX_PATH 1
|
||||
|
Loading…
Reference in New Issue
Block a user