PinCRT
|
Classes | |
struct | _OS_FILE_UNIQUE_ID |
struct | _OS_STRUCT_STAT |
Typedefs | |
typedef INT | OS_FILE_PERMISSION_TYPE |
typedef struct _OS_FILE_UNIQUE_ID | OS_FILE_UNIQUE_ID |
typedef struct _OS_STRUCT_STAT | OS_STRUCT_STAT |
typedef UINT64 | OS_PROCESS_WAITABLE_PROCESS |
Enumerations | |
enum | OS_FILE_OPEN_TYPE { OS_FILE_OPEN_TYPE_READ = (1 << 0), OS_FILE_OPEN_TYPE_WRITE = (1 << 1), OS_FILE_OPEN_TYPE_EXECUTE = (1 << 2), OS_FILE_OPEN_TYPE_APPEND = (1 << 3), OS_FILE_OPEN_TYPE_TRUNCATE = (1 << 4), OS_FILE_OPEN_TYPE_CREATE = (1 << 5), OS_FILE_OPEN_TYPE_CREATE_EXCL = (1 << 6), OS_FILE_OPEN_TYPE_DELETE = (1 << 7), OS_FILE_OPEN_TYPE_CLOSE_ON_EXEC = (1 << 8) } |
enum | OS_FILE_PERMISSION { OS_FILE_PERMISSION_TYPE_EXECUTE_OTHERS = 0001, OS_FILE_PERMISSION_TYPE_WRITE_OTHERS = 0002, OS_FILE_PERMISSION_TYPE_READ_OTHERS = 0004, OS_FILE_PERMISSION_TYPE_ALL_OTHERS = 0007, OS_FILE_PERMISSION_TYPE_EXECUTE_GROUP = 0010, OS_FILE_PERMISSION_TYPE_WRITE_GROUP = 0020, OS_FILE_PERMISSION_TYPE_READ_GROUP = 0040, OS_FILE_PERMISSION_TYPE_ALL_GROUP = 0070, OS_FILE_PERMISSION_TYPE_EXECUTE_USER = 0100, OS_FILE_PERMISSION_TYPE_WRITE_USER = 0200, OS_FILE_PERMISSION_TYPE_READ_USER = 0400, OS_FILE_PERMISSION_TYPE_ALL_USER = 0700 } |
enum | OS_FILE_SEEK_TYPE { OS_FILE_SEEK_SET = 0, OS_FILE_SEEK_CUR = (1 << 0), OS_FILE_SEEK_END = (1 << 1) } |
enum | OS_FILE_ATTRIBUTES { OS_FILE_ATTRIBUTES_NONE = 0, OS_FILE_ATTRIBUTES_EXIST = (1 << 0), OS_FILE_ATTRIBUTES_REGULAR = (1 << 1), OS_FILE_ATTRIBUTES_DIRECTORY = (1 << 2), OS_FILE_ATTRIBUTES_SYMLINK = (1 << 3) } |
enum | OS_PIPE_CREATE_FLAGS { OS_PIPE_CREATE_FLAGS_NONE = 0, OS_PIPE_CREATE_FLAGS_READ_SIDE_INHERITABLE = (1 << 0), OS_PIPE_CREATE_FLAGS_WRITE_SIDE_INHERITABLE = (1 << 1) } |
typedef INT OS_FILE_PERMISSION_TYPE |
Bit-mask of OS_FILE_PERMISSION's
typedef struct _OS_FILE_UNIQUE_ID OS_FILE_UNIQUE_ID |
Machine unique ID for file
typedef UINT64 OS_PROCESS_WAITABLE_PROCESS |
Opaque object that represents a process that we can wait for its termination
typedef struct _OS_STRUCT_STAT OS_STRUCT_STAT |
File status info
enum OS_FILE_ATTRIBUTES |
File permission modes
enum OS_FILE_OPEN_TYPE |
File open modes
enum OS_FILE_PERMISSION |
File access permission modes (not all enums apply in Windows)
enum OS_FILE_SEEK_TYPE |
enum OS_PIPE_CREATE_FLAGS |
Pipes creation flags
OS_RETURN_CODE OS_Chdir | ( | const CHAR * | dir, |
CHAR * | cwd, | ||
INT | len | ||
) |
Sets a new current directory. Optionally records the previous directory.
[in] | dir | The directory to move to. |
[out] | cwd | Buffer to receive the CWD. |
[in] | len | Max buffer length for cwd. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If current directory capture failed |
OS_RETURN_CODE_FILE_OPEN_FAILED | If the operation failed |
OS_RETURN_CODE OS_CloseFD | ( | NATIVE_FD | fd | ) |
Closes fd and removes references to it from the process.
[in] | fd | File descriptor |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_CLOSE_FAILED | If the operation failed |
OS_RETURN_CODE OS_Cwd | ( | CHAR * | cwd, |
INT | len | ||
) |
Retrieves size in bytes of fd.
[out] | cwd | Buffer to receive the CWD. |
[in] | len | Max buffer length. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_DeleteDirectory | ( | const CHAR * | name | ) |
Deletes a directory.
[in] | name | Directory file name to delete. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded. |
OS_RETURN_CODE_FILE_DELETE_FAILED | If the operation failed. |
OS_RETURN_CODE OS_DeleteFile | ( | const CHAR * | name | ) |
Delete a file by name
[in] | name | File path. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_DELETE_FAILED | If the operation failed |
OS_RETURN_CODE OS_DuplicateFD | ( | NATIVE_FD | fd, |
BOOL_T | dupCloseOnExec, | ||
NATIVE_FD * | outFd | ||
) |
Creates a copy of a file descriptor using the lowest available free file descriptor. This function considers the value returned from OS_GetLowestFileDescriptorToUse() when duplicating the descriptor.
[in] | fd | File descriptor to duplicate an ID. |
[in] | dupCloseOnExec | TRUE to duplicate the close-on-exec property of the descriptor, FALSE otherwise. |
[out] | outFd | Result duplicated file descriptor. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPERATION_FAILED | If the operation failed |
OS_RETURN_CODE OS_FilePermissionsFD | ( | NATIVE_FD | fd, |
OS_FILE_PERMISSION_TYPE * | permissions | ||
) |
Retrieve the current permissions for the specified file.
[in] | fd | File descriptor |
[out] | permissions | or'ed OS_FILE_PERMISSION_TYPE. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_FileSizeFD | ( | NATIVE_FD | fd, |
USIZE * | size | ||
) |
Retrieves size in bytes of fd.
[in] | fd | File descriptor |
[out] | size | Number of bytes. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_FileUniqueID | ( | NATIVE_FD | fd, |
OS_FILE_UNIQUE_ID * | uniqueId | ||
) |
Get unique ID for an opened file, identified by a file descriptor. Two opened file descriptors for the same physical file are guaranteed to have the same unique ID.
[in] | fd | File descriptor to calculate an ID. |
[out] | uniqueId | The calculate unique ID (opaque binary data) |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_FlushFD | ( | NATIVE_FD | fd | ) |
Flush the object referenced by the descriptor fd.
[in] | fd | File descriptor |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_FLUSH_FAILED | If the operation failed |
OS_RETURN_CODE OS_Fstat | ( | NATIVE_FD | fd, |
OS_STRUCT_STAT * | statbuf | ||
) |
Return information about the file pointed to by specified file descriptor in a buffer pointed to by statbuf.
[in] | fd | file descriptor. |
[in] | statbuf | Pointer to an information buffer about the file stats. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_Ftruncate | ( | NATIVE_FD | fd, |
INT64 | length | ||
) |
Truncates a file referenced by fd to a size of length bytes. If the original file size is bigger than length, the extra data is lost. If the original file size is smaller than length,the file extended.
[in] | fd | File descriptor to change his size. |
[in] | length | File new length. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPERATION_FAILED | If the operation failed |
OS_RETURN_CODE OS_GetFDAccessMode | ( | NATIVE_FD | fd, |
OS_FILE_OPEN_TYPE * | mode | ||
) |
Get the permissions type requested when fd was opened. This is useful to check whether we can read or write fd.
[in] | fd | File descriptor to check. |
[out] | mode | The permissions of the file descriptor. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded. |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed. |
OS_RETURN_CODE OS_GetFDAttributes | ( | NATIVE_FD | fd, |
OS_FILE_ATTRIBUTES * | attr | ||
) |
Query fd's file attributes
[in] | fd | File descriptor |
[out] | attr | File attributes |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_GetFileAttributes | ( | const CHAR * | path, |
OS_FILE_ATTRIBUTES * | attr | ||
) |
Query file attributes of the file denoted by path
[in] | path | Path to file |
[out] | attr | File attributes |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
NATIVE_FD OS_GetLowestFileDescriptorToUse | ( | ) |
Getter function to retrieve the lowest value of file descriptor that OS-APIs should use. OS-APIs will attempt to only use file descriptors which are larger or equal to the value that this function returns.
This function is implemented as a weak reference symbol so libraries linked with OS-APIs may provide their own implementation of this function and return a different value.
Lowest | file descriptor to use. |
OS_RETURN_CODE OS_IsConsoleFD | ( | NATIVE_FD | fd, |
INT * | isConsole | ||
) |
Check whether a file descriptor is the application's console. A file descriptor is the application's console if:
The practical implication of a console file descriptor is that every write operation to it needs to be flushed right away because the user on the other side expects to see output immediately.
[in] | fd | File descriptor to check. |
[out] | isConsole | non-zero if 'fd' is the application's console. Zero otherwise. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded. |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed. |
OS_RETURN_CODE OS_Lstat | ( | const char * | pathname, |
OS_STRUCT_STAT * | statbuf | ||
) |
identical to stat (see above), except that if pathname is a symbolic link, then the link itself is stat-ed, not the file that it refers to.
[in] | pathname | Path to the file. |
[in] | statbuf | Pointer to an information buffer about the file stats. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_MkDir | ( | const CHAR * | name, |
OS_FILE_PERMISSION_TYPE | mode | ||
) |
Creates a directory.
[in] | name | Directory file name to create. |
[in] | mode | File mode to create the directory. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded. |
OS_RETURN_CODE_FILE_EXIST | Directory exists. |
OS_RETURN_CODE_FILE_OPEN_FAILED | If the operation failed. |
OS_RETURN_CODE OS_OpenDirFD | ( | const CHAR * | name, |
NATIVE_FD * | fd | ||
) |
Opens a directory for browsing.
[in] | name | Directory file name to open. |
[out] | fd | Pointer to returned file descriptor. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPEN_FAILED | If the operation failed |
OS_RETURN_CODE OS_OpenFD | ( | const CHAR * | path, |
INT | flags, | ||
OS_FILE_PERMISSION_TYPE | mode, | ||
NATIVE_FD * | fd | ||
) |
The file name specified by path is opened for reading and/or writing, as specified by the argument flags.
[in] | path | File path. |
[in] | flags | or'ed OS_FILE_OPEN_TYPE. If mode OS_FILE_OPEN_TYPE_CREATE was given, the file is created with mode. |
[in] | mode | If a new file will be created as a result of this operation, this is the mode of this newly created file. This argument contains values from OS_FILE_PERMISSION_TYPE combined with bitwise OR. |
[out] | fd | Returned file descriptor |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPEN_FAILED | If the operation Failed |
OS_RETURN_CODE OS_ReadDirectoryFD | ( | NATIVE_FD | fd, |
USIZE * | count, | ||
VOID * | buffer | ||
) |
Attempts to read count bytes of data from the directory referenced by the descriptor fd to the buffer pointed to by buffer. A console file descriptor usually needs to be flushed after every read/write operation.
[in] | fd | File descriptor |
[in,out] | count | Bytes to read/Bytes read |
[out] | buffer | Output buffer |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_READ_FAILED | If the operation failed |
OS_RETURN_CODE OS_ReadFD | ( | NATIVE_FD | fd, |
USIZE * | count, | ||
VOID * | buffer | ||
) |
Attempts to read count bytes of data from the object referenced by the descriptor fd to the buffer pointed to by buffer.
[in] | fd | File descriptor |
[in,out] | count | Bytes to read |
[out] | buffer | Output buffer |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_READ_FAILED | If the operation failed |
OS_RETURN_CODE OS_ReadLink | ( | const CHAR * | path, |
CHAR * | buf, | ||
USIZE * | size | ||
) |
Reads the symbolic link pointed by path. Returns the path that the symlink points to.
[in] | path | Path to the symbolic link to read. |
[out] | buf | The path where the symlink points to. |
[in,out] | size | The number of bytes in buf, returns the number of bytes filled inside buf. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded. |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed. |
OS_RETURN_CODE OS_Realpath | ( | const char * | path, |
BOOL_T | checkPathExistence, | ||
char * | resolvedPath | ||
) |
Expands all symbolic links or junction points and resolves references to '.', '..' and extra '/' characters in the null-terminated string named by 'path' to produce a canonicalized absolute pathname.
[in] | path | path name. can be full or relative |
[in] | checkPathExistence | if TRUE - function checks if the canonical path exists and returns NULL in case it does not. if FALSE - function returns the canonical path (regardless of it's existence) |
[out] | resolvedPath | canonicalized absolute pathname |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPERATION_FAILED | If the operation failed |
void OS_RelocateAndReportFileOpen | ( | NATIVE_FD * | fd | ) |
Relocate the file descriptor to the range permitted according to OS_GetLowestFileDescriptorToUse(), then record a file descriptor as opened by OS-APIs. Later, we allow to query whether a certain file descriptor was opened by OS-APIs or not.
[in,out] | fd | File descriptor to relocate and record. |
OS_RETURN_CODE OS_RenameFile | ( | const CHAR * | oldPath, |
const CHAR * | newPath | ||
) |
Renamed the file oldPath to newPath
[in] | oldPath | Filename to rename |
[in] | newPath | New filename to rename to |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_OPERATION_FAILED | If the operation failed |
void OS_ReportFileClose | ( | NATIVE_FD | fd | ) |
Record that a file descriptor opened by OS-APIs is not longer valid, and it is closed. Later, we allow to query whether a certain file descriptor was opened by OS-APIs or not.
[in] | fd | File descriptor to record. |
void OS_ReportFileOpen | ( | NATIVE_FD | fd | ) |
Record a file descriptor as opened by OS-APIs. Later, we allow to query whether a certain file descriptor was opened by OS-APIs or not.
[in] | fd | File descriptor to record. |
OS_RETURN_CODE OS_SeekFD | ( | NATIVE_FD | fd, |
INT | whence, | ||
INT64 * | offset | ||
) |
Reposition the offset of the file descriptor fd to the an offset in, the file denoted by offset. The offset is measured with relation to a starting point determined by the directive whence.
[in] | fd | File descriptor |
[in] | whence | OS_FILE_SEEK_TYPE |
[in,out] | offset | Bytes to move |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_SEEK_FAILED | If the operation failed |
OS_RETURN_CODE OS_Stat | ( | const char * | pathname, |
OS_STRUCT_STAT * | statbuf | ||
) |
Return information about the file pointed to by specified pathname in a buffer pointed to by statbuf.
[in] | pathname | Path to the file. |
[in] | statbuf | Pointer to an information buffer about the file stats. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_QUERY_FAILED | If the operation failed |
Queries whether a certain file descriptor was opened by OS-APIs or not.
[in] | fd | File descriptor to query. |
OS_RETURN_CODE OS_WriteFD | ( | NATIVE_FD | fd, |
const VOID * | buffer, | ||
USIZE * | count | ||
) |
Attempts to write count bytes of data to the object referenced by the descriptor fd from the buffer pointed to by buffer.
[in] | fd | File descriptor |
[in] | buffer | Data buffer |
[in,out] | count | Bytes to write |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_FILE_WRITE_FAILED | If the operation failed |