mirror of
https://github.com/nginx/nginx.git
synced 2025-08-06 14:56:15 +08:00
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
This commit is contained in:
parent
cea9034015
commit
501fc74854
@ -481,15 +481,14 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_create_path_and_rename_file(ngx_str_t *src, ngx_str_t *to,
|
||||
ngx_uint_t access, ngx_uint_t full_path, ngx_uint_t delete, ngx_log_t *log)
|
||||
ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to, ngx_ext_rename_file_t *ext)
|
||||
{
|
||||
ngx_err_t err;
|
||||
|
||||
#if !(NGX_WIN32)
|
||||
|
||||
if (ngx_change_file_access(src->data, access) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
||||
if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
|
||||
ngx_change_file_access_n " \"%s\" failed", src->data);
|
||||
err = 0;
|
||||
goto failed;
|
||||
@ -497,6 +496,15 @@ ngx_create_path_and_rename_file(ngx_str_t *src, ngx_str_t *to,
|
||||
|
||||
#endif
|
||||
|
||||
if (ext->time != -1) {
|
||||
if (ngx_set_file_time(src->data, ext->fd, ext->time) != NGX_OK) {
|
||||
ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
|
||||
ngx_set_file_time_n " \"%s\" failed", src->data);
|
||||
err = 0;
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) {
|
||||
return NGX_OK;
|
||||
}
|
||||
@ -505,14 +513,14 @@ ngx_create_path_and_rename_file(ngx_str_t *src, ngx_str_t *to,
|
||||
|
||||
if (err == NGX_ENOENT) {
|
||||
|
||||
if (!full_path) {
|
||||
if (!ext->create_path) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
err = ngx_create_full_path(to->data, ngx_dir_access(access));
|
||||
err = ngx_create_full_path(to->data, ngx_dir_access(ext->access));
|
||||
|
||||
if (err) {
|
||||
ngx_log_error(NGX_LOG_CRIT, log, err,
|
||||
ngx_log_error(NGX_LOG_CRIT, ext->log, err,
|
||||
ngx_create_dir_n " \"%s\" failed", to->data);
|
||||
err = 0;
|
||||
goto failed;
|
||||
@ -529,7 +537,7 @@ ngx_create_path_and_rename_file(ngx_str_t *src, ngx_str_t *to,
|
||||
#if (NGX_WIN32)
|
||||
|
||||
if (err == NGX_EEXIST) {
|
||||
if (ngx_win32_rename_file(src, to, log) == NGX_OK) {
|
||||
if (ngx_win32_rename_file(src, to, ext->log) == NGX_OK) {
|
||||
|
||||
if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) {
|
||||
return NGX_OK;
|
||||
@ -546,15 +554,15 @@ ngx_create_path_and_rename_file(ngx_str_t *src, ngx_str_t *to,
|
||||
|
||||
failed:
|
||||
|
||||
if (delete) {
|
||||
if (ext->delete) {
|
||||
if (ngx_delete_file(src->data) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
||||
ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
|
||||
ngx_delete_file_n " \"%s\" failed", src->data);
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
ngx_log_error(NGX_LOG_CRIT, log, err,
|
||||
ngx_log_error(NGX_LOG_CRIT, ext->log, err,
|
||||
ngx_rename_file_n " \"%s\" to \"%s\" failed",
|
||||
src->data, to->data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user