2004-09-28 16:34:51 +08:00
|
|
|
|
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-09-02 22:48:24 +08:00
|
|
|
#ifndef _NGX_FILES_H_INCLUDED_
|
|
|
|
#define _NGX_FILES_H_INCLUDED_
|
2002-08-20 22:48:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
2003-06-03 23:42:58 +08:00
|
|
|
#include <ngx_core.h>
|
2003-01-30 15:28:09 +08:00
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-14 00:16:33 +08:00
|
|
|
/* INVALID_FILE_ATTRIBUTES is specified but not defined at least in MSVC6SP2 */
|
2002-08-20 22:48:28 +08:00
|
|
|
#ifndef INVALID_FILE_ATTRIBUTES
|
2003-11-14 00:16:33 +08:00
|
|
|
#define INVALID_FILE_ATTRIBUTES 0xffffffff
|
2002-08-20 22:48:28 +08:00
|
|
|
#endif
|
|
|
|
|
2003-11-14 00:16:33 +08:00
|
|
|
/* INVALID_SET_FILE_POINTER is not defined at least in MSVC6SP2 */
|
|
|
|
#ifndef INVALID_SET_FILE_POINTER
|
|
|
|
#define INVALID_SET_FILE_POINTER 0xffffffff
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-12-15 14:25:09 +08:00
|
|
|
#define NGX_INVALID_FILE INVALID_HANDLE_VALUE
|
|
|
|
#define NGX_FILE_ERROR 0
|
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
|
|
|
|
|
2003-06-02 23:24:30 +08:00
|
|
|
#define ngx_open_file(name, access, create) \
|
2005-03-01 23:20:36 +08:00
|
|
|
CreateFile((const char *) name, access, \
|
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
|
|
|
|
NULL, create, FILE_FLAG_BACKUP_SEMANTICS, NULL)
|
2002-12-16 05:08:04 +08:00
|
|
|
/*
|
2005-03-01 23:20:36 +08:00
|
|
|
NULL, OPEN_EXISTING, 0, NULL)
|
2002-12-16 05:08:04 +08:00
|
|
|
*/
|
2003-06-02 23:24:30 +08:00
|
|
|
#define ngx_open_file_n "CreateFile()"
|
|
|
|
|
|
|
|
#define NGX_FILE_RDONLY GENERIC_READ
|
|
|
|
#define NGX_FILE_RDWR GENERIC_READ|GENERIC_WRITE
|
|
|
|
#define NGX_FILE_CREATE_OR_OPEN OPEN_ALWAYS
|
|
|
|
#define NGX_FILE_OPEN OPEN_EXISTING
|
2003-06-03 23:42:58 +08:00
|
|
|
#define NGX_FILE_APPEND 0
|
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_int_t ngx_file_append_mode(ngx_fd_t fd);
|
2003-06-03 23:42:58 +08:00
|
|
|
#define ngx_file_append_mode_n "SetFilePointer()"
|
2003-06-02 23:24:30 +08:00
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2006-04-14 17:53:38 +08:00
|
|
|
#define ngx_open_tempfile(name, persistent, mode) \
|
2005-03-01 23:20:36 +08:00
|
|
|
CreateFile((const char *) name, \
|
|
|
|
GENERIC_READ|GENERIC_WRITE, \
|
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
|
|
|
|
NULL, \
|
|
|
|
CREATE_NEW, \
|
|
|
|
persistent ? 0: \
|
|
|
|
FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE, \
|
|
|
|
NULL);
|
2003-04-12 00:01:14 +08:00
|
|
|
|
2003-05-20 23:37:55 +08:00
|
|
|
#define ngx_open_tempfile_n "CreateFile()"
|
|
|
|
|
|
|
|
|
2002-12-15 14:25:09 +08:00
|
|
|
#define ngx_close_file CloseHandle
|
|
|
|
#define ngx_close_file_n "CloseHandle()"
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
|
2005-10-27 23:46:13 +08:00
|
|
|
#define ngx_write_fd(fd, buf, size) WriteFile(fd, buf, size, NULL, NULL)
|
|
|
|
#define ngx_linefeed(p) *p++ = CR; *p++ = LF;
|
|
|
|
#define NGX_LINEFEED_SIZE 2
|
|
|
|
|
|
|
|
|
2004-03-17 05:26:01 +08:00
|
|
|
#define ngx_delete_file(name) DeleteFile((const char *) name)
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_delete_file_n "DeleteFile()"
|
|
|
|
|
|
|
|
|
2006-04-14 17:53:38 +08:00
|
|
|
#define ngx_rename_file(o, n) MoveFile((const char *) o, (const char *) n)
|
2003-11-12 06:16:11 +08:00
|
|
|
#define ngx_rename_file_n "MoveFile()"
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
|
2005-03-01 23:20:36 +08:00
|
|
|
ngx_pool_t *pool);
|
2003-11-17 05:49:42 +08:00
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_int_t ngx_file_info(u_char *filename, ngx_file_info_t *fi);
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_file_info_n "GetFileAttributesEx()"
|
|
|
|
|
2003-11-12 06:16:11 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_fd_info(fd, fi) GetFileInformationByHandle(fd, fi)
|
|
|
|
#define ngx_fd_info_n "GetFileInformationByHandle"
|
2003-04-12 00:01:14 +08:00
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_is_dir(fi) ((fi)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
#define ngx_is_file(fi) !((fi)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
2002-08-20 22:48:28 +08:00
|
|
|
|
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_file_size(fi) \
|
2005-03-01 23:20:36 +08:00
|
|
|
(((off_t) (fi)->nFileSizeHigh << 32) | (fi)->nFileSizeLow)
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_file_uniq(fi) (*(ngx_file_uniq_t *) &(fi)->nFileIndexHigh)
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-12 02:13:43 +08:00
|
|
|
|
|
|
|
/* 116444736000000000 is commented in src/os/win32/ngx_time.c */
|
2002-08-20 22:48:28 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_file_mtime(fi) \
|
|
|
|
(time_t) (((((unsigned __int64) (fi)->ftLastWriteTime.dwHighDateTime << 32) \
|
|
|
|
| (fi)->ftLastWriteTime.dwLowDateTime) \
|
2002-12-15 14:25:09 +08:00
|
|
|
- 116444736000000000) / 10000000)
|
2002-08-20 22:48:28 +08:00
|
|
|
|
|
|
|
|
2004-05-18 23:29:08 +08:00
|
|
|
#define ngx_getcwd(buf, size) GetCurrentDirectory(size, buf)
|
|
|
|
#define ngx_getcwd_n "GetCurrentDirectory()"
|
|
|
|
#define NGX_MAX_PATH MAX_PATH
|
|
|
|
|
|
|
|
|
2004-03-17 05:26:01 +08:00
|
|
|
#define NGX_DIR_MASK (u_char *) "/*"
|
2003-11-17 05:49:42 +08:00
|
|
|
#define NGX_DIR_MASK_LEN 2
|
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_open_dir_n "FindFirstFile()"
|
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_int_t ngx_read_dir(ngx_dir_t *dir);
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_read_dir_n "FindNextFile()"
|
|
|
|
|
|
|
|
|
|
|
|
#define ngx_close_dir(d) FindClose((d)->dir)
|
|
|
|
#define ngx_close_dir_n "FindClose()"
|
|
|
|
|
|
|
|
|
2004-03-17 05:26:01 +08:00
|
|
|
#define ngx_create_dir(name) CreateDirectory((const char *) name, NULL)
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_create_dir_n "CreateDirectory()"
|
|
|
|
|
|
|
|
|
2004-03-17 05:26:01 +08:00
|
|
|
#define ngx_delete_dir(name) RemoveDirectory((const char *) name)
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_delete_dir_n "RemoveDirectory()"
|
|
|
|
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
#define ngx_de_name(dir) ((u_char *) (dir)->fd.cFileName)
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_de_namelen(dir) ngx_strlen((dir)->fd.cFileName)
|
2005-03-19 20:38:37 +08:00
|
|
|
|
|
|
|
ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir);
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_de_info_n "dummy()"
|
2005-03-19 20:38:37 +08:00
|
|
|
|
|
|
|
ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir);
|
2005-03-01 23:20:36 +08:00
|
|
|
#define ngx_de_link_info_n "dummy()"
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_de_is_dir(dir) \
|
2005-03-01 23:20:36 +08:00
|
|
|
((dir)->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_de_is_file(dir) \
|
2005-03-01 23:20:36 +08:00
|
|
|
!((dir)->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
#define ngx_de_is_link(dir) 0
|
2003-11-17 05:49:42 +08:00
|
|
|
#define ngx_de_size(dir) \
|
2005-03-01 23:20:36 +08:00
|
|
|
(((off_t) (dir)->fd.nFileSizeHigh << 32) | (dir)->fd.nFileSizeLow)
|
2003-11-17 05:49:42 +08:00
|
|
|
|
|
|
|
/* 116444736000000000 is commented in src/os/win32/ngx_time.c */
|
|
|
|
|
|
|
|
#define ngx_de_mtime(dir) \
|
2005-03-01 23:20:36 +08:00
|
|
|
(time_t) (((((unsigned __int64) \
|
2003-11-17 05:49:42 +08:00
|
|
|
(dir)->fd.ftLastWriteTime.dwHighDateTime << 32) \
|
|
|
|
| (dir)->fd.ftLastWriteTime.dwLowDateTime) \
|
|
|
|
- 116444736000000000) / 10000000)
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-16 15:10:12 +08:00
|
|
|
ssize_t ngx_read_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset);
|
2003-05-30 22:27:59 +08:00
|
|
|
#define ngx_read_file_n "ReadFile()"
|
|
|
|
|
2004-03-16 15:10:12 +08:00
|
|
|
ssize_t ngx_write_file(ngx_file_t *file, u_char *buf, size_t size,
|
2005-03-01 23:20:36 +08:00
|
|
|
off_t offset);
|
2003-11-13 14:14:05 +08:00
|
|
|
|
|
|
|
ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *ce,
|
2005-03-01 23:20:36 +08:00
|
|
|
off_t offset, ngx_pool_t *pool);
|
2003-11-13 14:14:05 +08:00
|
|
|
|
|
|
|
|
2002-09-02 22:48:24 +08:00
|
|
|
#endif /* _NGX_FILES_H_INCLUDED_ */
|