Skip to content

Commit

Permalink
Win32: non-ASCII directory names support in ngx_delete_dir().
Browse files Browse the repository at this point in the history
This makes it possible to delete directories with non-ASCII characters
when using the dav module (ticket #1433).
  • Loading branch information
mdounin committed Feb 23, 2023
1 parent 89719dc commit f8075f1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/os/win32/ngx_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,42 @@ ngx_create_dir(u_char *name, ngx_uint_t access)
}


ngx_int_t
ngx_delete_dir(u_char *name)
{
long rc;
size_t len;
u_short *u;
ngx_err_t err;
u_short utf16[NGX_UTF16_BUFLEN];

len = NGX_UTF16_BUFLEN;
u = ngx_utf8_to_utf16(utf16, name, &len, 0);

if (u == NULL) {
return NGX_FILE_ERROR;
}

rc = NGX_FILE_ERROR;

if (ngx_win32_check_filename(u, len, 0) != NGX_OK) {
goto failed;
}

rc = RemoveDirectoryW(u);

failed:

if (u != utf16) {
err = ngx_errno;
ngx_free(u);
ngx_set_errno(err);
}

return rc;
}


ngx_int_t
ngx_open_glob(ngx_glob_t *gl)
{
Expand Down
2 changes: 1 addition & 1 deletion src/os/win32/ngx_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ ngx_int_t ngx_create_dir(u_char *name, ngx_uint_t access);
#define ngx_create_dir_n "CreateDirectory()"


#define ngx_delete_dir(name) RemoveDirectory((const char *) name)
ngx_int_t ngx_delete_dir(u_char *name);
#define ngx_delete_dir_n "RemoveDirectory()"


Expand Down

0 comments on commit f8075f1

Please sign in to comment.