changeset 2782:4bd7825fab80

uniform ngx_file_info() interface with ngx_fd_info()
author Igor Sysoev <igor@sysoev.ru>
date Wed, 29 Apr 2009 19:28:52 +0000
parents f545c81e5ddb
children 87c088e6956a
files src/core/ngx_cycle.c src/core/ngx_file.c src/core/ngx_open_file_cache.c src/http/modules/ngx_http_dav_module.c src/os/win32/ngx_files.c
diffstat 5 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -1126,7 +1126,9 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx
         if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
             ngx_file_info_t  fi;
 
-            if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) {
+            if (ngx_file_info((const char *) file[i].name.data, &fi)
+                == NGX_FILE_ERROR)
+            {
                 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                               ngx_file_info_n " \"%s\" failed",
                               file[i].name.data);
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -489,7 +489,9 @@ ngx_create_pathes(ngx_cycle_t *cycle, ng
         {
         ngx_file_info_t   fi;
 
-        if (ngx_file_info((const char *) path[i]->name.data, &fi) == -1) {
+        if (ngx_file_info((const char *) path[i]->name.data, &fi)
+            == NGX_FILE_ERROR)
+        {
             ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                           ngx_file_info_n " \"%s\" failed", path[i]->name.data);
             return NGX_ERROR;
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -143,7 +143,7 @@ ngx_open_cached_file(ngx_open_file_cache
 
         if (of->test_only) {
 
-            if (ngx_file_info(name->data, &fi) == -1) {
+            if (ngx_file_info(name->data, &fi) == NGX_FILE_ERROR) {
                 of->err = ngx_errno;
                 of->failed = ngx_file_info_n;
                 return NGX_ERROR;
@@ -463,7 +463,7 @@ ngx_open_and_stat_file(u_char *name, ngx
 
     if (of->fd != NGX_INVALID_FILE) {
 
-        if (ngx_file_info(name, &fi) == -1) {
+        if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
             of->failed = ngx_file_info_n;
             goto failed;
         }
@@ -474,7 +474,7 @@ ngx_open_and_stat_file(u_char *name, ngx
 
     } else if (of->test_dir) {
 
-        if (ngx_file_info(name, &fi) == -1) {
+        if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
             of->failed = ngx_file_info_n;
             goto failed;
         }
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -221,7 +221,7 @@ ngx_http_dav_put_handler(ngx_http_reques
 
     temp = &r->request_body->temp_file->file.name;
 
-    if (ngx_file_info(path.data, &fi) == -1) {
+    if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
         status = NGX_HTTP_CREATED;
 
     } else {
@@ -326,7 +326,7 @@ ok:
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http delete filename: \"%s\"", path.data);
 
-    if (ngx_file_info(path.data, &fi) == -1) {
+    if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
         err = ngx_errno;
 
         rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
@@ -678,7 +678,7 @@ overwrite_done:
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http copy to: \"%s\"", copy.path.data);
 
-    if (ngx_file_info(copy.path.data, &fi) == -1) {
+    if (ngx_file_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
         err = ngx_errno;
 
         if (err != NGX_ENOENT) {
@@ -712,7 +712,7 @@ overwrite_done:
         dir = ngx_is_dir(&fi);
     }
 
-    if (ngx_file_info(path.data, &fi) == -1) {
+    if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
         return ngx_http_dav_error(r->connection->log, ngx_errno,
                                   NGX_HTTP_NOT_FOUND, ngx_file_info_n,
                                   path.data);
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -311,7 +311,7 @@ ngx_file_info(u_char *file, ngx_file_inf
     /* NT4 and Win98 */
 
     if (GetFileAttributesEx((char *) file, GetFileExInfoStandard, &fa) == 0) {
-        return NGX_ERROR;
+        return NGX_FILE_ERROR;
     }
 
     sb->dwFileAttributes = fa.dwFileAttributes;
@@ -321,7 +321,7 @@ ngx_file_info(u_char *file, ngx_file_inf
     sb->nFileSizeHigh = fa.nFileSizeHigh;
     sb->nFileSizeLow = fa.nFileSizeLow;
 
-    return NGX_OK;
+    return ~NGX_FILE_ERROR;
 }