Asynchronous access to the file system. More...
Data Structures | |
struct | uv_timespec_t |
Portable structure to hold time stamps. More... | |
struct | uv_stat_t |
Portable structure for file information. More... | |
struct | uv_dirent_t |
Directory entries. More... | |
Macros | |
#define | using_fs_scandir(scandir) |
Use a nodec_scandir_t in a scope. More... | |
#define | R_OK |
Permission mode for (user) reading. | |
#define | W_OK |
Permission mode for (user) writing. | |
#define | X_OK |
Permission mode for (user) execute. | |
Typedefs | |
typedef uv_fs_t | nodec_scandir_t |
Used to iterate over the contents of a directory. | |
typedef lh_value() | nodec_file_fun(uv_file file, const char *path, lh_value arg) |
Type of scoped file functions. | |
typedef struct _uv_file * | uv_file |
A platform independent file handle. | |
Enumerations | |
enum | nodec_open_flags_t { UV_FS_O_APPEND, UV_FS_O_CREAT, UV_FS_O_EXCL, UV_FS_O_RANDOM, UV_FS_O_RDONLY, UV_FS_O_RDWR, UV_FS_O_SEQUENTIAL, UV_FS_O_SHORT_LIVED, UV_FS_O_TEMPORARY, UV_FS_O_TRUNC, UV_FS_O_WRONLY, UV_FS_O_DIRECT, UV_FS_O_DIRECTORY, UV_FS_O_DSYNC, UV_FS_O_EXLOCK, UV_FS_O_NOATIME, UV_FS_O_NOCTTY, UV_FS_O_NOFOLLOW, UV_FS_O_NONBLOCK, UV_FS_O_SYMLINK, UV_FS_O_SYNC } |
File open modes, see open2(). More... | |
enum | uv_dirent_type_t { UV_DIRENT_UNKNOWN, UV_DIRENT_FILE, UV_DIRENT_DIR, UV_DIRENT_LINK, UV_DIRENT_FIFO, UV_DIRENT_SOCKET, UV_DIRENT_CHAR, UV_DIRENT_BLOCK } |
Directory entry types. More... | |
Functions | |
uv_errno_t | asyncx_fs_stat (const char *path, uv_stat_t *stat) |
Stat a file without raising an exception on failure. More... | |
uv_stat_t | async_fs_stat (const char *path) |
Stat a file. More... | |
uv_stat_t | async_fs_fstat (uv_file file) |
Stat a file handle. More... | |
uv_file | async_fs_open (const char *path, nodec_open_flags_t flags, int permissions) |
Open a file. More... | |
uv_errno_t | asyncx_fs_open (const char *path, nodec_open_flags_t flags, int permissions, uv_file *file) |
Open a file. More... | |
void | async_fs_close (uv_file file) |
Close a file. More... | |
size_t | async_fs_read_into (uv_file file, uv_buf_t buf, int64_t file_offset) |
Read a file into a buffer. More... | |
uv_buf_t | async_fs_read_buf (uv_file file, size_t max, int64_t file_offset) |
Read part of a file. More... | |
uv_buf_t | async_fs_read_buf_all (uv_file file, size_t max) |
Read an entire file (or up to max bytes) More... | |
nodec_scandir_t * | async_fs_scandir (const char *path) |
Initiate scanning a directory. More... | |
bool | async_fs_scandir_next (nodec_scandir_t *scanreq, uv_dirent_t *dirent) |
Iterate over the directory contents. More... | |
char * | async_fs_read_from (const char *path) |
Read full contents of a file as a string. More... | |
uv_buf_t | async_fs_read_buf_from (const char *path) |
Read full contents of a file as a buffer. More... | |
lh_value | using_async_fs_open (const char *path, nodec_open_flags_t flags, int permissions, nodec_file_fun *action, lh_value arg) |
Safely open a file, use it, and close it again. More... | |
uv_errno_t | using_asyncx_fs_open (const char *path, nodec_open_flags_t flags, int permissions, nodec_file_fun *action, lh_value arg, lh_value *result) |
Safely open a file, use it, and close it again. More... | |
Asynchronous access to the file system.
struct uv_timespec_t |
struct uv_stat_t |
Portable structure for file information.
Data Fields | ||
---|---|---|
uv_timespec_t | st_atim | Last access time. |
uv_timespec_t | st_birthtim | Creation time. |
uint64_t | st_blksize | Block size used for I/O operations. |
uint64_t | st_blocks | Blocks allocated for this file. |
uv_timespec_t | st_ctim | Last time the file status changed. |
uint64_t | st_dev | Device id of the file. |
uint64_t | st_flags | |
uint64_t | st_gen | |
uint64_t | st_gid | Group ID associated with this file. |
uint64_t | st_ino | INODE number of the file. |
uint64_t | st_mode | File type and permission mode. |
uv_timespec_t | st_mtim | Last modified time. |
uint64_t | st_nlink | Number of hard links that point to this file. |
uint64_t | st_rdev | |
uint64_t | st_size | Size of the file in bytes. |
uint64_t | st_uid | User ID associated with this file. |
struct uv_dirent_t |
Directory entries.
Data Fields | ||
---|---|---|
const char * | name | Name of the entry. |
uv_dirent_type_t | type | Type of the entry. |
#define using_fs_scandir | ( | scandir | ) |
Use a nodec_scandir_t in a scope.
scandir | A nodec_scandir_t returned from async_scandir() |
enum nodec_open_flags_t |
File open modes, see open2().
The open mode must always include one of UV_FS_O_RDONLY
, UV_FS_O_WRONLY
, or UV_FS_O_RDWR
.
enum uv_dirent_type_t |
void async_fs_close | ( | uv_file | file | ) |
Close a file.
file | The file handle to be closed. |
Stat a file handle.
file | The opened file handle. |
uv_file async_fs_open | ( | const char * | path, |
nodec_open_flags_t | flags, | ||
int | permissions | ||
) |
Open a file.
path | The file path |
flags | The file open flags. |
mode | The file permissions mode if it is created (using UV_FS_O_CREAT). |
Read part of a file.
Most efficient way to read files.
file | The file to read from. |
max | The maximum number of bytes to read. |
file_offset | The offset to read from in the file. |
Read an entire file (or up to max
bytes)
file | The file to read from. |
max | The maximum number of bytes to read. |
uv_buf_t async_fs_read_buf_from | ( | const char * | path | ) |
Read full contents of a file as a buffer.
path | The file path |
char* async_fs_read_from | ( | const char * | path | ) |
Read full contents of a file as a string.
path | The file path. |
Read a file into a buffer.
file | The file handle |
buf | The buffer to read into. |
file_offset | The offset to read from in the file. |
nodec_scandir_t* async_fs_scandir | ( | const char * | path | ) |
Initiate scanning a directory.
path | The directory path. |
bool async_fs_scandir_next | ( | nodec_scandir_t * | scanreq, |
uv_dirent_t * | dirent | ||
) |
Iterate over the directory contents.
[in,out] | scanreq | The iteration state. |
[out] | dirent | The directory entry information if successful. |
uv_stat_t async_fs_stat | ( | const char * | path | ) |
Stat a file.
path | The file path. |
uv_errno_t asyncx_fs_open | ( | const char * | path, |
nodec_open_flags_t | flags, | ||
int | permissions, | ||
uv_file * | file | ||
) |
Open a file.
Returns an error code instead of throwing an exception.
path | The file path | |
flags | The file open flags. | |
mode | The file permissions mode if it is created (using UV_FS_O_CREAT). | |
[out] | file | Set to the file handle on success |
uv_errno_t asyncx_fs_stat | ( | const char * | path, |
uv_stat_t * | stat | ||
) |
Stat a file without raising an exception on failure.
path | The file path. |
stat | The result file information. |
lh_value using_async_fs_open | ( | const char * | path, |
nodec_open_flags_t | flags, | ||
int | permissions, | ||
nodec_file_fun * | action, | ||
lh_value | arg | ||
) |
Safely open a file, use it, and close it again.
path | The file path |
flags | The file open flags. |
mode | The file permissions mode if it is created (using UV_FS_O_CREAT). |
action | The file open action: called with the opened file handle. |
arg | Extra argument passed to action . |
action
. uv_errno_t using_asyncx_fs_open | ( | const char * | path, |
nodec_open_flags_t | flags, | ||
int | permissions, | ||
nodec_file_fun * | action, | ||
lh_value | arg, | ||
lh_value * | result | ||
) |
Safely open a file, use it, and close it again.
Does not throw an exception on a file open error but returns an uv_errno_t
instead.
path | The file path | |
flags | The file open flags. | |
mode | The file permissions mode if it is created (using UV_FS_O_CREAT). | |
action | The file open action: called with the opened file handle. | |
arg | Extra argument passed to action . | |
[out] | result | The return value of action . |