clib_wrap Module

atomic rename/replace (same filesystem) unlink a file or remove an empty directory create one directory (mode 0777 & umask on POSIX) does the path exist? recursively remove a directory tree flush a file's data to stable storage flush a directory's entries to stable storage set a file's length (shrink or grow) try (non-blocking) to take an advisory lock release an advisory lock and close its handle downgrade an exclusive advisory lock to shared is standard input a terminal?


Used by


Interfaces

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_rename(oldpath, newpath) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: oldpath

    Existing path

    character(len=*), intent(in) :: newpath

    Destination path (replaced if it exists)

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_remove(path) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Path to remove

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_mkdir(path) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Directory to create

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_path_exists(path) result(yes)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Path to test

    Return Value logical

    .true. if the path exists

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_rmtree(path) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Root of the tree to remove

    Return Value integer

    0 on success, nonzero on partial failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_fsync_path(path) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    File to flush

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_fsync_dir(path) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Directory to flush

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_truncate(path, length) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    File to resize

    integer(kind=c_int64_t), intent(in) :: length

    New length in bytes

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_lock_share(tok) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int64_t), intent(in) :: tok

    A held lock token

    Return Value integer

    0 on success, nonzero on failure

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module function c_isatty_stdin() result(yes)

    Arguments

    None

    Return Value logical

    .true. if stdin is a TTY

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module subroutine c_lock_try(path, exclusive, tok, ierr)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: path

    Lock-file path

    logical, intent(in) :: exclusive

    Write lock if .true.

    integer(kind=c_int64_t), intent(out) :: tok

    Held token, or -1

    integer, intent(out) :: ierr

    0 ok / 1 contended / 2 error

interface

Atomically rename/replace oldpath to newpath (same filesystem). Returns 0 on success, nonzero on failure. Unlink a file or remove an empty directory. Returns 0 on success, nonzero on failure. Create one directory (mode 0777 & umask on POSIX). Returns 0 on success, nonzero on failure (including "already exists"). Test whether path exists (access(F_OK) / _access). Depth-first removal of path and everything under it. Returns 0 if the tree was removed or the path did not exist; nonzero if a remove failed partway. Flush a file's data to stable storage (fsync / _commit). flush the owning Fortran unit first so the runtime buffer has reached the OS before this call drives the OS cache to disk. Returns 0 on success, nonzero on failure. Flush a directory's entries to stable storage, making a file creation/deletion within it durable. A no-op on Windows (NTFS journals directory metadata). Returns 0 on success. Set a file's length to length bytes, shrinking or growing it (truncate / _chsize_s). Returns 0 on success, nonzero on failure. Try (non-blocking) to take an advisory lock on path, which is created if absent. exclusive selects a write lock; otherwise a shared (read) lock that coexists with other shared holders. On success ierr is 0 and tok holds the lock (an opaque token — a POSIX fd or a Win32 HANDLE — pass it to c_lock_release). On contention ierr is 1 and tok is -1; on a genuine open/create failure ierr is 2. The lock lives only as long as tok is held, and is dropped automatically if the process dies. Release a lock taken by c_lock_try and close its descriptor or handle. A no-op for an unheld (-1) token; resets tok to -1. Downgrade an exclusive lock to shared so other read-only connections may attach. Returns 0 on success, nonzero on failure. .true. when standard input (fd 0) is a terminal, so an interactive prompt is appropriate. Wraps POSIX isatty / CRT _isatty.

  • public module subroutine c_lock_release(tok)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int64_t), intent(inout) :: tok

    Token to release (set to -1)