nginx/src/os/win32/ngx_files.h

63 lines
2.1 KiB
C
Raw Normal View History

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>
/* INVALID_FILE_ATTRIBUTES specified but never defined at least in VC6SP2 */
#ifndef INVALID_FILE_ATTRIBUTES
#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
#endif
2002-08-26 23:18:19 +08:00
typedef HANDLE ngx_fd_t;
2002-12-15 14:25:09 +08:00
#define NGX_INVALID_FILE INVALID_HANDLE_VALUE
#define NGX_FILE_ERROR 0
2002-08-26 23:18:19 +08:00
typedef unsigned __int64 off_t;
2002-08-20 22:48:28 +08:00
typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t;
#define ngx_open_file(name, flags) \
CreateFile(name, flags, \
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
2002-12-16 05:08:04 +08:00
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL)
/*
2002-08-20 22:48:28 +08:00
NULL, OPEN_EXISTING, 0, NULL)
2002-12-16 05:08:04 +08:00
*/
2002-08-20 22:48:28 +08:00
2002-09-02 22:48:24 +08:00
#define ngx_open_file_n "CreateFile()"
2002-08-20 22:48:28 +08:00
2002-09-02 22:48:24 +08:00
#define NGX_FILE_RDONLY GENERIC_READ
2002-08-20 22:48:28 +08:00
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
int ngx_file_type(char *filename, ngx_file_info_t *fi);
2002-12-15 14:25:09 +08:00
#define ngx_file_type_n "GetFileAttributes"
2002-08-20 22:48:28 +08:00
2002-12-15 14:25:09 +08:00
#define ngx_stat_fd(fd, fi) GetFileInformationByHandle(fd, fi)
#define ngx_stat_fd_n "GetFileInformationByHandle"
2002-08-20 22:48:28 +08:00
2002-12-15 14:25:09 +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
#define ngx_file_size(fi) \
2002-12-15 14:25:09 +08:00
(((off_t) fi.nFileSizeHigh << 32) | fi.nFileSizeLow)
2002-08-20 22:48:28 +08:00
2002-12-15 14:25:09 +08:00
/* There are 134774 days between 1 Jan 1970 and 1 Jan 1601,
11644473600 seconds or 11644473600,000,000,0 100-nanosecond intervals */
2002-08-20 22:48:28 +08:00
2002-12-15 14:25:09 +08:00
#define ngx_file_mtime(fi) \
(time_t) (((((unsigned __int64) fi.ftLastWriteTime.dwHighDateTime << 32) \
| fi.ftLastWriteTime.dwLowDateTime) \
- 116444736000000000) / 10000000)
2002-08-20 22:48:28 +08:00
2002-12-15 14:25:09 +08:00
#define ngx_read_file_n "ReadFile()"
2002-09-02 22:48:24 +08:00
#endif /* _NGX_FILES_H_INCLUDED_ */