File access utility routines.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | FILE_PATH_LEN | = | 2048 |
Maximum file path length. |
| integer, | public, | parameter | :: | FILE_TYPE_NONE | = | 0 |
Unknown type. |
| integer, | public, | parameter | :: | FILE_TYPE_BLOCK | = | 1 |
Block device. |
| integer, | public, | parameter | :: | FILE_TYPE_CHAR | = | 2 |
Character device. |
| integer, | public, | parameter | :: | FILE_TYPE_DIR | = | 3 |
Directory. |
| integer, | public, | parameter | :: | FILE_TYPE_FIFO | = | 4 |
FIFO or pipe. |
| integer, | public, | parameter | :: | FILE_TYPE_FILE | = | 5 |
Regular file. |
| integer, | public, | parameter | :: | FILE_TYPE_LINK | = | 6 |
Symbolic link. |
| integer, | public, | parameter | :: | FILE_TYPE_SOCKET | = | 7 |
Socket. |
Abstraction of C struct stat(2) that stores parts of a file
status. The file mode is usually an unsigned type (uint32_t on
Linux, uint16_t on FreeBSD), and is therefore converted to signed
integer after the syscall.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | type | = | FILE_TYPE_NONE |
File type. |
|
| integer(kind=i8), | public | :: | mode | = | 0 |
File mode as signed integer. |
|
| integer(kind=i8), | public | :: | size | = | 0_i8 |
File size in bytes. |
|
| integer(kind=i8), | public | :: | a_time | = | 0_i8 |
Time of last access [Epoch]. |
|
| integer(kind=i8), | public | :: | m_time | = | 0_i8 |
Time of last modification [Epoch]. |
|
| integer(kind=i8), | public | :: | c_time | = | 0_i8 |
Time of last status change [Epoch]. |
Returns .true. if file at given file path exists.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns .true. if file at given file path is a directory.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns .true. if current user has execute permission.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns .true. if file at given file path is a named pipe.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns .true. if current user has read permission.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns .true. if current user has write permission.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns number of lines in given file by counting new lines. Sets
error to E_IO if opening the file failed, and to E_EMPTY if
the file has no lines.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Returns file size in file storage units (usually, bytes). On error,
size is 0 and the error code E_NOT_FOUND is returned in dummy
argument error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Returns status of file at given path in status. The function
returns E_SYSTEM on error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
||
| type(file_status_type), | intent(out) | :: | status |
File status type. |
Returns size of file tree path (directory including all
sub-directories).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File tree path. |
||
| integer(kind=i8), | intent(out) | :: | size |
File tree size [Byte]. |
Deletes file at given file path. Returns E_IO on error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File to delete. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Creates empty file at given file path. Returns E_IO on error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File to create. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Reads file contents as byte stream into allocatable character string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
||
| character(len=:), | intent(out), | allocatable | :: | content |
Byte string. |
|
| integer(kind=i8), | intent(out), | optional | :: | size |
Content size. |
|
| integer, | intent(out), | optional | :: | error |
Error code. |
Writes content to given file (ASCII or binary).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
Output file path. |
||
| character(len=*), | intent(in) | :: | content |
Bytes to write. |
||
| logical, | intent(in), | optional | :: | raw |
Unformatted output if true. |
|
| integer, | intent(out), | optional | :: | error |
Error code. |