newfile()

newfile()#

newfile() creates a new file with the specified permissions, optionally overwriting an existing file.

Prototype

int newfile(
    const char *path,
    int         permission,
    BOOL        overwrite
);

Parameters

Key

Type

Description

path

const char *

The file path to create.

permission

int

The file permission mode (e.g., 0660).

overwrite

BOOL

If TRUE, an existing file will be truncated; otherwise, creation fails if the file exists.


Return Value

Returns a file descriptor on success, or -1 on failure.

Notes

This function sets umask(0) to ensure the specified permissions are applied.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples