📄 os0file.h
字号:
os_file_tos_file_create_simple(/*==================*/ /* out, own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error */ const char* name, /* in: name of the file or path as a null-terminated string */ ulint create_mode,/* in: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), or OS_FILE_CREATE_PATH if new file (if exists, error) and subdirectories along its path are created (if needed)*/ ulint access_type,/* in: OS_FILE_READ_ONLY or OS_FILE_READ_WRITE */ ibool* success);/* out: TRUE if succeed, FALSE if error *//********************************************************************A simple function to open or create a file. */os_file_tos_file_create_simple_no_error_handling(/*====================================*/ /* out, own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error */ const char* name, /* in: name of the file or path as a null-terminated string */ ulint create_mode,/* in: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error) */ ulint access_type,/* in: OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or OS_FILE_READ_ALLOW_DELETE; the last option is used by a backup program reading the file */ ibool* success);/* out: TRUE if succeed, FALSE if error *//********************************************************************Opens an existing file or creates a new. */os_file_tos_file_create(/*===========*/ /* out, own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error */ const char* name, /* in: name of the file or path as a null-terminated string */ ulint create_mode,/* in: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), OS_FILE_OVERWRITE if a new file is created or an old overwritten; OS_FILE_OPEN_RAW, if a raw device or disk partition should be opened */ ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o is desired, OS_FILE_NORMAL, if any normal file; NOTE that it also depends on type, os_aio_.. and srv_.. variables whether we really use async i/o or unbuffered i/o: look in the function source code for the exact rules */ ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */ ibool* success);/* out: TRUE if succeed, FALSE if error *//***************************************************************************Deletes a file. The file has to be closed before calling this. */iboolos_file_delete(/*===========*/ /* out: TRUE if success */ const char* name); /* in: file path as a null-terminated string *//***************************************************************************Deletes a file if it exists. The file has to be closed before calling this. */iboolos_file_delete_if_exists(/*=====================*/ /* out: TRUE if success */ const char* name); /* in: file path as a null-terminated string *//***************************************************************************Renames a file (can also move it to another directory). It is safest that thefile is closed before calling this function. */iboolos_file_rename(/*===========*/ /* out: TRUE if success */ const char* oldpath, /* in: old file path as a null-terminated string */ const char* newpath); /* in: new file path *//***************************************************************************Closes a file handle. In case of error, error number can be retrieved withos_file_get_last_error. */iboolos_file_close(/*==========*/ /* out: TRUE if success */ os_file_t file); /* in, own: handle to a file *//***************************************************************************Closes a file handle. */iboolos_file_close_no_error_handling(/*============================*/ /* out: TRUE if success */ os_file_t file); /* in, own: handle to a file *//***************************************************************************Gets a file size. */iboolos_file_get_size(/*=============*/ /* out: TRUE if success */ os_file_t file, /* in: handle to a file */ ulint* size, /* out: least significant 32 bits of file size */ ulint* size_high);/* out: most significant 32 bits of size *//***************************************************************************Gets file size as a 64-bit integer ib_longlong. */ib_longlongos_file_get_size_as_iblonglong(/*===========================*/ /* out: size in bytes, -1 if error */ os_file_t file); /* in: handle to a file *//***************************************************************************Write the specified number of zeros to a newly created file. */iboolos_file_set_size(/*=============*/ /* out: TRUE if success */ const char* name, /* in: name of the file or path as a null-terminated string */ os_file_t file, /* in: handle to a file */ ulint size, /* in: least significant 32 bits of file size */ ulint size_high);/* in: most significant 32 bits of size *//***************************************************************************Truncates a file at its current position. */iboolos_file_set_eof(/*============*/ /* out: TRUE if success */ FILE* file); /* in: file to be truncated *//***************************************************************************Flushes the write buffers of a given file to the disk. */iboolos_file_flush(/*==========*/ /* out: TRUE if success */ os_file_t file); /* in, own: handle to a file *//***************************************************************************Retrieves the last error number if an error occurs in a file io function.The number should be retrieved before any other OS calls (because they mayoverwrite the error number). If the number is not known to this program,the OS error number + 100 is returned. */ulintos_file_get_last_error(/*===================*/ /* out: error number, or OS error number + 100 */ ibool report_all_errors); /* in: TRUE if we want an error message printed of all errors *//***********************************************************************Requests a synchronous read operation. */iboolos_file_read(/*=========*/ /* out: TRUE if request was successful, FALSE if fail */ os_file_t file, /* in: handle to a file */ void* buf, /* in: buffer where to read */ ulint offset, /* in: least significant 32 bits of file offset where to read */ ulint offset_high,/* in: most significant 32 bits of offset */ ulint n); /* in: number of bytes to read */ /***********************************************************************Rewind file to its start, read at most size - 1 bytes from it to str, andNUL-terminate str. All errors are silently ignored. This function ismostly meant to be used with temporary files. */voidos_file_read_string(/*================*/ FILE* file, /* in: file to read from */ char* str, /* in: buffer where to read */ ulint size); /* in: size of buffer *//***********************************************************************Requests a synchronous positioned read operation. This function does not doany error handling. In case of error it returns FALSE. */iboolos_file_read_no_error_handling(/*===========================*/ /* out: TRUE if request was successful, FALSE if fail */ os_file_t file, /* in: handle to a file */ void* buf, /* in: buffer where to read */ ulint offset, /* in: least significant 32 bits of file offset where to read */ ulint offset_high,/* in: most significant 32 bits of offset */ ulint n); /* in: number of bytes to read */ /***********************************************************************Requests a synchronous write operation. */iboolos_file_write(/*==========*/ /* out: TRUE if request was successful, FALSE if fail */ const char* name, /* in: name of the file or path as a null-terminated string */ os_file_t file, /* in: handle to a file */ const void* buf, /* in: buffer from which to write */ ulint offset, /* in: least significant 32 bits of file offset where to write */ ulint offset_high,/* in: most significant 32 bits of offset */ ulint n); /* in: number of bytes to write */ /***********************************************************************Check the existence and type of the given file. */iboolos_file_status(/*===========*/ /* out: TRUE if call succeeded */ const char* path, /* in: pathname of the file */ ibool* exists, /* out: TRUE if file exists */ os_file_type_t* type); /* out: type of the file (if it exists) *//********************************************************************The function os_file_dirname returns a directory component of anull-terminated pathname string. In the usual case, dirname returnsthe string up to, but not including, the final '/', and basenameis the component following the final '/'. Trailing '/' charac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -