📄 apr_file_io.h
字号:
/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */#ifndef APR_FILE_IO_H#define APR_FILE_IO_H/** * @file apr_file_io.h * @brief APR File I/O Handling */#include "apr.h"#include "apr_pools.h"#include "apr_time.h"#include "apr_errno.h"#include "apr_file_info.h"#include "apr_inherit.h"#define APR_WANT_STDIO /**< for SEEK_* */#define APR_WANT_IOVEC /**< for apr_file_writev */#include "apr_want.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//** * @defgroup apr_file_io File I/O Handling Functions * @ingroup APR * @{ *//** * @defgroup apr_file_open_flags File Open Flags/Routines * @{ *//* Note to implementors: Values in the range 0x00100000--0x80000000 are reserved for platform-specific values. */#define APR_READ 0x00001 /**< Open the file for reading */#define APR_WRITE 0x00002 /**< Open the file for writing */#define APR_CREATE 0x00004 /**< Create the file if not there */#define APR_APPEND 0x00008 /**< Append to the end of the file */#define APR_TRUNCATE 0x00010 /**< Open the file and truncate to 0 length */#define APR_BINARY 0x00020 /**< Open the file in binary mode */#define APR_EXCL 0x00040 /**< Open should fail if APR_CREATE and file exists. */#define APR_BUFFERED 0x00080 /**< Open the file for buffered I/O */#define APR_DELONCLOSE 0x00100 /**< Delete the file after close */#define APR_XTHREAD 0x00200 /**< Platform dependent tag to open the file for use across multiple threads */#define APR_SHARELOCK 0x00400 /**< Platform dependent support for higher level locked read/write access to support writes across process/machines */#define APR_FILE_NOCLEANUP 0x00800 /**< Do not register a cleanup when the file is opened */#define APR_SENDFILE_ENABLED 0x01000 /**< Advisory flag that this file should support apr_sendfile operation */#define APR_LARGEFILE 0x04000 /**< Platform dependent flag to enable large file support; WARNING see below. *//** @warning The APR_LARGEFILE flag only has effect on some platforms * where sizeof(apr_off_t) == 4. Where implemented, it allows opening * and writing to a file which exceeds the size which can be * represented by apr_off_t (2 gigabytes). When a file's size does * exceed 2Gb, apr_file_info_get() will fail with an error on the * descriptor, likewise apr_stat()/apr_lstat() will fail on the * filename. apr_dir_read() will fail with APR_INCOMPLETE on a * directory entry for a large file depending on the particular * APR_FINFO_* flags. Generally, it is not recommended to use this * flag. *//** @} *//** * @defgroup apr_file_seek_flags File Seek Flags * @{ *//* flags for apr_file_seek *//** Set the file position */#define APR_SET SEEK_SET/** Current */#define APR_CUR SEEK_CUR/** Go to end of file */#define APR_END SEEK_END/** @} *//** * @defgroup apr_file_attrs_set_flags File Attribute Flags * @{ *//* flags for apr_file_attrs_set */#define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */#define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */#define APR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden *//** @} *//** File attributes */typedef apr_uint32_t apr_fileattrs_t;/** should be same as whence type in lseek, POSIX defines this as int */typedef int apr_seek_where_t;/** * Structure for referencing files. */typedef struct apr_file_t apr_file_t;/* File lock types/flags *//** * @defgroup apr_file_lock_types File Lock Types * @{ */#define APR_FLOCK_SHARED 1 /**< Shared lock. More than one process or thread can hold a shared lock at any given time. Essentially, this is a "read lock", preventing writers from establishing an exclusive lock. */#define APR_FLOCK_EXCLUSIVE 2 /**< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock". */#define APR_FLOCK_TYPEMASK 0x000F /**< mask to extract lock type */#define APR_FLOCK_NONBLOCK 0x0010 /**< do not block while acquiring the file lock *//** @} *//** * Open the specified file. * @param newf The opened file descriptor. * @param fname The full path to the file (using / on all systems) * @param flag Or'ed value of: * <PRE> * APR_READ open for reading * APR_WRITE open for writing * APR_CREATE create the file if not there * APR_APPEND file ptr is set to end prior to all writes * APR_TRUNCATE set length to zero if file exists * APR_BINARY not a text file (This flag is ignored on * UNIX because it has no meaning) * APR_BUFFERED buffer the data. Default is non-buffered * APR_EXCL return error if APR_CREATE and file exists * APR_DELONCLOSE delete the file after closing. * APR_XTHREAD Platform dependent tag to open the file * for use across multiple threads * APR_SHARELOCK Platform dependent support for higher * level locked read/write access to support * writes across process/machines * APR_FILE_NOCLEANUP Do not register a cleanup with the pool * passed in on the <EM>cont</EM> argument (see below). * The apr_os_file_t handle in apr_file_t will not * be closed when the pool is destroyed. * APR_SENDFILE_ENABLED Open with appropriate platform semantics * for sendfile operations. Advisory only, * apr_sendfile does not check this flag. * </PRE> * @param perm Access permissions for file. * @param pool The pool to use. * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate * default permissions will be used. *arg1 must point to a valid file_t, * or NULL (in which case it will be allocated) */APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool);/** * Close the specified file. * @param file The file descriptor to close. */APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file);/** * delete the specified file. * @param path The full path to the file (using / on all systems) * @param cont The pool to use. * @remark If the file is open, it won't be removed until all instances are closed. */APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *cont);/** * rename the specified file. * @param from_path The full path to the original file (using / on all systems) * @param to_path The full path to the new file (using / on all systems) * @param pool The pool to use. * @warning If a file exists at the new location, then it will be overwritten. * Moving files or directories across devices may not be possible. */APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, const char *to_path, apr_pool_t *pool);/** * copy the specified file to another file. * @param from_path The full path to the original file (using / on all systems) * @param to_path The full path to the new file (using / on all systems) * @param perms Access permissions for the new file if it is created. * In place of the usual or'd combination of file permissions, the * value APR_FILE_SOURCE_PERMS may be given, in which case the source * file's permissions are copied. * @param pool The pool to use. * @remark The new file does not need to exist, it will be created if required. * @warning If the new file already exists, its contents will be overwritten. */APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, const char *to_path, apr_fileperms_t perms, apr_pool_t *pool);/** * append the specified file to another file. * @param from_path The full path to the source file (using / on all systems) * @param to_path The full path to the destination file (using / on all systems) * @param perms Access permissions for the destination file if it is created. * In place of the usual or'd combination of file permissions, the * value APR_FILE_SOURCE_PERMS may be given, in which case the source * file's permissions are copied. * @param pool The pool to use. * @remark The new file does not need to exist, it will be created if required. */APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, const char *to_path, apr_fileperms_t perms, apr_pool_t *pool);/** * Are we at the end of the file * @param fptr The apr file we are testing. * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. */APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr);/** * open standard error as an apr file pointer. * @param thefile The apr file to use as stderr. * @param cont The pool to allocate the file out of. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -