Functions

func open(String, Int32) (deprecated)

public func open(path: String, oflag: Int32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.

O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • oflag: Int32: file opening mode

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func open(String, Int32, UInt32) (deprecated)

public func open(path: String, oflag: Int32, flag: UInt32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails. path indicates the file path, and oflag indicates the file opening mode. O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.

O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • oflag: Int32: file opening mode
  • flag: UInt32: If oflag is set to O_CREAT and a new file needs to be created, the flag parameter indicates the permission on the new file. Otherwise, flag does not change the file permission.

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func access(String, Int32) (deprecated)

public func access(path: String, mode: Int32): Int32

Description: Checks whether a certain permission is granted on a file. If so, 0 is returned. Otherwise, -1 is returned.

mode indicates the specified permission. The input type is R_OK, W_OK, X_OK, or F_OK.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • mode: Int32: permission to be checked

Returns:

  • Int32: If the permission is granted on the file, 0 is returned. Otherwise, -1 is returned.

Throws:

func chdir(String) (deprecated)

public func chdir(path: String): Int32

Description: Changes the current working directory of the called process by specifying a path.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the setting is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func chmod(String, UInt32) (deprecated)

public func chmod(path: String, mode: UInt32): Int32

Description: Modifies the file access permission.

In the Windows environment:

  • All files and directories are readable. chmod() cannot change the read permission on files.
  • In the Windows environment, the execute permission on a file is set through the file name extension. All directories are executable, and chmod() cannot change the execute permission on files and directories.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • mode: UInt32: permission to be modified

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned. If mode is set to an invalid parameter, chmod ignores the parameter and 0 is returned.

Throws:

func chown(String, UInt32, UInt32) (deprecated)

public func chown(path: String, owner: UInt32, group: UInt32): Int32

Description: Modifies the file owner and the group to which the file owner belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • owner: UInt32: owner uid
  • group: UInt32: parameter specifying the gid

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func close(Int32) (deprecated)

public func close(fd: Int32): Int32

Description: Close a file, which triggers data writeback to the disk and releases resources occupied by the file.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

func creat(String, UInt32) (deprecated)

public func creat(path: String, flag: UInt32): Int32

Description: Creates a file and returns a file descriptor, or returns -1 when the operation fails.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • flag: UInt32: permission when creating a file

Returns:

  • Int32: A file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func dup(Int32) (deprecated)

public func dup(fd: Int32): Int32

Description: Copies and returns the file descriptor specified by the original fd parameter. The new file descriptor and the original fd parameter reference the same file, share the file states, and share all locks, read or write location, and permissions or flags.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor

Returns:

  • Int32: The smallest unused file descriptor is returned. If the execution fails, -1 is returned.

func dup2(Int32, Int32) (deprecated)

public func dup2(fd: Int32, fd2: Int32): Int32

Description: Copies the file descriptor specified by oldfd and returns it to the newfd parameter. If the newfd parameter is an open file descriptor, the file specified by newfd is closed first.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor specified by the oldfd parameter
  • fd2: Int32: file descriptor specified by the newfd parameter

Returns:

  • Int32: fd2 file descriptor

func faccessat(Int32, String, Int32, Int32) (deprecated)

public func faccessat(fd: Int32, path: String, mode: Int32, flag: Int32): Int32

Description: Checks whether a certain permission is granted on the file specified by fd. If so, 0 is returned. Otherwise, -1 is returned.

mode indicates the specified permission. The input type is R_OK, W_OK, X_OK, or F_OK.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • path: String: file path
  • mode: Int32: permission to be checked
  • flag: Int32: Obtains one or more of the following values by bitwise OR operation. The value (512) indicates that access check is performed using a valid user and group ID. By default, a valid ID is used. If the path name is a symbolic link (value (256)), the reference is not canceled but information about the link is returned.

Returns:

  • Int32: If the permission is granted on the file, 0 is returned. Otherwise, -1 is returned.

Throws:

func fchdir(Int32) (deprecated)

public func fchdir(fd: Int32): Int32

Description: Changes the current working directory of the called process by specifying the descriptor of a file path.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: descriptor of the changed file path

Returns:

  • Int32: If the setting is successful, 0 is returned. Otherwise, -1 is returned.

func fchmod(Int32, UInt32) (deprecated)

public func fchmod(fd: Int32, mode: UInt32): Int32

Description: Modifies the file access permission corresponding to the file descriptor.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • mode: UInt32: permission to be modified

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func fchmodat(Int32, String, UInt32, Int32) (deprecated)

public func fchmodat(fd: Int32, path: String, mode: UInt32, flag: Int32): Int32

Description: Modifies the file access permission corresponding to the file descriptor.

  • If path is a relative path and fd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If path is a relative path and fd is not AT_FDCWD, the path is relative to the directory to which the file referenced by fd belongs.
  • If path is an absolute path, the fd parameter is ignored.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • path: String: file path
  • mode: UInt32: permission to be modified
  • flag: Int32: The value can be 0 or (256) (the path name is a symbolic link, and the reference to it is not canceled, but information about the link is returned).

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func fchown(Int32, UInt32, UInt32) (deprecated)

public func fchown(fd: Int32, owner: UInt32, group: UInt32): Int32

Description: Modifies the file owner corresponding to fd and the group to which the file owner belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • owner: UInt32: owner uid
  • group: UInt32: parameter specifying the gid

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

func fchownat(Int32, String, UInt32, UInt32, Int32) (deprecated)

public func fchownat(fd: Int32, path: String, owner: UInt32, group: UInt32, flag: Int32): Int32

Description: Modifies the file owner corresponding to the file descriptor and the group to which the file owner belongs.

  • If path is a relative path and fd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If path is a relative path and fd is not AT_FDCWD, the path is relative to the directory to which the file referenced by fd belongs.
  • If path is an absolute path, the fd parameter is ignored.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • path: String: file path
  • owner: UInt32: owner uid
  • group: UInt32: parameter specifying the gid
  • flag: Int32: The value can be 0 or (256) (the path name is a symbolic link, and the reference to it is not canceled, but information about the link is returned).

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func getcwd() (deprecated)

public func getcwd(): String

Description: Obtains the absolute path of the working directory of the current process.

NOTE

This function will be deprecated in future releases.

Returns:

  • String: If the operation is successful, a string containing the path information is returned. Otherwise, an empty string is returned.

func getgid() (deprecated)

public func getgid(): UInt32

Description: Obtains the user group ID.

NOTE

This function will be deprecated in future releases.

Returns:

  • UInt32: current user group ID

func getgroups(Int32, CPointer<UInt32>) (deprecated)

public unsafe func getgroups(size: Int32, gidArray: CPointer<UInt32>): Int32

Description: Obtains codes of groups to which the current user belongs.

If the size parameter of gidArray is 0, the function returns only the number of groups to which the user belongs, and does not add gid into gidArray.

NOTE

This function will be deprecated in future releases.

Parameters:

  • size: Int32: gid quantity allowed in gidArray
  • gidArray: CPointer<UInt32>: array storing gid information

Returns:

  • Int32: If the execution is successful, the group code is returned. Otherwise, -1 is returned.

func gethostname() (deprecated)

public func gethostname(): String

Description: Obtains a host name, which is usually the name of a host on the TCP/IP network.

NOTE

This function will be deprecated in future releases.

Returns:

  • String: obtained host name string. If the host name fails to be obtained, an empty string is returned.

func getlogin() (deprecated)

public func getlogin(): String

Description: Obtains the current login name.

NOTE

This function will be deprecated in future releases.

Returns:

  • String: If the operation is successful, the login name is returned. Otherwise, an empty string is returned.

func getos() (deprecated)

public func getos(): String

Description: Obtains the Linux system information from the /proc/version file. Example: Linux version 4.15.0-142-generic (buildd@lgw01-amd64-036) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #146-Ubuntu SMP Tue Apr 13 01:11:19 UTC 2021.

NOTE

This function will be deprecated in future releases.

Returns:

  • String: obtained Linux system information string

func getpgid(Int32) (deprecated)

public func getpgid(pid: Int32): Int32

Description: Obtains PGID of the process specified by pid. If pid is 0, ID of the called process is returned.

NOTE

This function will be deprecated in future releases.

Parameters:

  • pid: Int32: target process ID

Returns:

  • Int32: If the execution is successful, the process group ID is returned. Otherwise, -1 is returned.

func getpgrp() (deprecated)

public func getpgrp(): Int32

Description: Obtains the parent process ID of the called process.

NOTE

This function will be deprecated in future releases.

Returns:

  • Int32: The parent process ID of the called process is returned.

func getpid() (deprecated)

public func getpid(): Int32

Description: Obtains ID(PID) of the called process.

NOTE

This function will be deprecated in future releases.

Returns:

  • Int32: The ID(PID) of the called process is returned.

func getppid() (deprecated)

public func getppid(): Int32

Description: Obtains the parent process ID of the called process.

NOTE

This function will be deprecated in future releases.

Returns:

  • Int32: The parent process ID of the called process is returned.

func getuid() (deprecated)

public func getuid(): UInt32

Description: Obtains the real user ID of the called process.

NOTE

This function will be deprecated in future releases.

Returns:

  • UInt32: current real user ID

func isBlk(String) (deprecated)

public func isBlk(path: String): Bool

Description: Checks whether the input object is a block device and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isChr(String) (deprecated)

public func isChr(path: String): Bool

Description: Checks whether the input object is a character device and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isDir(String) (deprecated)

public func isDir(path: String): Bool

Description: Checks whether the input object is a folder and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isFIFO(String) (deprecated)

public func isFIFO(path: String): Bool

Description: Checks whether the input object is an FIFO file and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isLnk(String) (deprecated)

public func isLnk(path: String): Bool

Description: Checks whether the input object is a soft link and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isReg(String) (deprecated)

public func isReg(path: String): Bool

Description: Checks whether the input object is a regular file and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isSock(String) (deprecated)

public func isSock(path: String): Bool

Description: Checks whether the input object is a socket file and returns a Boolean value.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If so, true is returned. Otherwise, false is returned.

func isType(String, UInt32) (deprecated)

public func isType(path: String, mode: UInt32): Bool

Description: Checks whether a file is in the specified mode. If so, true is returned. Otherwise, false is returned. Different types are determined based on different modes.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Bool: If the file is in a specified mode, true is returned. Otherwise, false is returned.

func isatty(Int32) (deprecated)

public func isatty(fd: Int32): Bool

Description: Tests whether a file descriptor references a terminal. If so, true is returned. Otherwise, false is returned.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor

Returns:

  • Bool: If the operation is successful, true is returned. Otherwise, false is returned.

func kill(Int32, Int32) (deprecated)

public func kill(pid: Int32, sig: Int32): Int32

Description: Sends any signal to any process group or process.

  • If pid is greater than 0, sig is sent to the process corresponding to pid.
  • If pid is equal to 0, sig is sent to each process in the process group to which the called process belongs.
  • If pid is equal to -1, sig is sent to each process to which the called process has permission to send signals.
  • If pid is less than -1, sig is sent to each process in the process group whose ID is -pid.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

func killpg(Int32, Int32) (deprecated)

public func killpg(pgid: Int32, sig: Int32): Int32

Description: Sends the signal sig to the process group pgrp. If pgrp is 0, killpg() sends the signal to the process group to which the called process belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

func lchown(String, UInt32, UInt32) (deprecated)

public func lchown(path: String, owner: UInt32, group: UInt32): Int32

Description: Modifies the file link owner and the group to which the owner belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path in string format
  • owner: UInt32: owner uid
  • group: UInt32: parameter specifying the gid

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func link(String, String) (deprecated)

public func link(path: String, newpath: String): Int32

Description: Creates a link for an existing file. A file can have multiple directory entries pointing to its i-node.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • newpath: String: another file path

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter path or newPath contains null characters, this exception is thrown.

func linkat(Int32, String, Int32, String, Int32) (deprecated)

public func linkat(fd: Int32, path: String, nfd: Int32, newPath: String, lflag: Int32): Int32

Description: Creates a file link relative to the directory file descriptor.

  • If path is a relative path and fd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If path is a relative path and fd is not AT_FDCWD, the path is relative to the directory to which the file referenced by fd belongs.
  • If path is an absolute path, the fd parameter is ignored.
  • newPath is similar to path. The only difference is that when newPath is a relative path, the path is the directory to which the file referenced by nfd belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • path: String: file path
  • nfd: Int32: another file descriptor
  • newPath: String: another file path. If newpath already exists, the existing file will not be overwritten.
  • lflag: Int32: AT_EMPTY_PATH, AT_SYMLINK_FOLLOW, or 0

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter path or newPath contains null characters, this exception is thrown.

func lseek(Int32, Int64, Int32) (deprecated)

public func lseek(fd: Int32, offset: Int64, whence: Int32): Int64

Description: Moves the read or write location in file reading or writing. This function is used to control the read or write location of a file. If the call is successful, the current read or write location, that is, the number of bytes from the start of the file, is returned. Otherwise, -1 is returned.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of an opened file
  • offset: Int64: offset
  • whence: Int32: control mode

Returns:

  • Int64: If the call is successful, the current read or write location, that is, the number of bytes from the start of the file, is returned.

func nice(Int32) (deprecated)

public func nice(inc: Int32): Int32

Description: Changes the priority of the current thread.

If the operation is successful, a new value is returned. Otherwise, -1 is returned. If the value of inc is greater than 19, 19 is returned.

Only the superuser can use a negative inc value, which indicates a higher priority and faster process execution. inc indicates the priority of the current process, ranging from +19 (low priority) to -20.

NOTE

This function will be deprecated in future releases.

Parameters:

  • inc: Int32: priority of the current process, ranging from +19 (low priority) to -20

Returns:

  • Int32: A new priority value is returned.

func open64(String, Int32) (deprecated)

public func open64(path: String, oflag: Int32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • oflag: Int32: file opening mode

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func open64(String, Int32, UInt32) (deprecated)

public func open64(path: String, oflag: Int32, flag: UInt32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • oflag: Int32: file opening mode
  • flag: UInt32: If oflag is set to O_CREAT and a new file needs to be created, the flag parameter indicates the permission on the new file. Otherwise, flag does not change the file permission.

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func openat(Int32, String, Int32) (deprecated)

public func openat(fd: Int32, path: String, oflag: Int32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of a path
  • path: String: file path
  • oflag: Int32: file opening mode

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func openat(Int32, String, Int32, UInt32) (deprecated)

public func openat(fd: Int32, path: String, oflag: Int32, flag: UInt32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of a path
  • path: String: file path
  • oflag: Int32: file opening mode
  • flag: UInt32: If oflag is set to O_CREAT and a new file needs to be created, the flag parameter indicates the permission on the new file. Otherwise, flag does not change the file permission.

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func openat64(Int32, String, Int32) (deprecated)

public func openat64(fd: Int32, path: String, oflag: Int32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of a path
  • path: String: file path
  • oflag: Int32: file opening mode

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func openat64(Int32, String, Int32, UInt32) (deprecated)

public func openat64(fd: Int32, path: String, oflag: Int32, flag: UInt32): Int32

Description: Opens a file and returns a new file descriptor, or returns -1 when the operation fails.

  • When the oflag parameter of the file opening mode is set to O_CREAT, file permissions can be set through parameters.
  • O_RDONLY, O_RDWR, and O_WRONLY are mutually exclusive for oflag, but can be used together with other operation identifiers, such as O_APPEND.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of a path
  • path: String: file path
  • oflag: Int32: file opening mode
  • flag: UInt32: If oflag is set to O_CREAT and a new file needs to be created, the flag parameter indicates the permission on the new file. Otherwise, flag does not change the file permission.

Returns:

  • Int32: A new file descriptor is returned. If the execution fails, -1 is returned.

Throws:

func pread(Int32, CPointer<UInt8>, UIntNative, Int32) (deprecated)

public unsafe func pread(fd: Int32, buffer: CPointer<UInt8>, nbyte: UIntNative, offset: Int32): IntNative

Description: Transfers nbyte of the file specified by fd to the memory specified by buffer. If nbyte is 0, the function does not work and 0 is returned. The returned value is the number of bytes that are actually read. If the returned value is 0, the end of the file is reached or data cannot be read. In addition, the read or write location of the file varies with the bytes read.

It is recommended that the size of nbyte be the same as that of buffer, and the size of buffer be less than or equal to 150,000 bytes.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of the file to be read
  • buffer: CPointer<UInt8>: buffer container
  • nbyte: UIntNative: number of bytes to be read. buffer.size is recommended.
  • offset: Int32: offset of the read location

Returns:

  • IntNative: The number of actually read bytes is returned. If the read operation is invalid, -1 is returned.

func pwrite(Int32, CPointer<UInt8>, UIntNative, Int32) (deprecated)

public unsafe func pwrite(fd: Int32, buffer: CPointer<UInt8>, nbyte: UIntNative, offset: Int32): IntNative

Description: Writes nbyte in the memory specified by buffer to the file specified by fd, starting from the specified offset location. The read or write location of the specified file change accordingly.

It is recommended that the size of nbyte be the same as that of buffer, and the size of buffer be less than or equal to 150,000 bytes.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of the file to be read
  • buffer: CPointer<UInt8>: buffer container
  • nbyte: UIntNative: number of bytes to be read. buffer.size is recommended.
  • offset: Int32: offset of the read location

Returns:

  • IntNative: The number of actually written bytes is returned. If the write operation fails, -1 is returned.

func read(Int32, CPointer<UInt8>, UIntNative) (deprecated)

public unsafe func read(fd: Int32, buffer: CPointer<UInt8>, nbyte: UIntNative): IntNative

Description: Transfers nbyte of the file specified by fd to the memory specified by buffer. If nbyte is 0, the function does not work and 0 is returned. The returned value is the number of bytes that are actually read. If the returned value is 0, the end of the file is reached or data cannot be read. In addition, the read or write location of the file varies with the bytes read.

It is recommended that the size of nbyte be the same as that of buffer, and the size of buffer be less than or equal to 150,000 bytes.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of the file to be read
  • buffer: CPointer<UInt8>: buffer container
  • nbyte: UIntNative: number of bytes to be read. buffer.size is recommended.

Returns:

  • IntNative: The number of actually read bytes is returned. If the read operation is invalid, -1 is returned.

func remove(String) (deprecated)

public func remove(path: String): Int32

Description: Deletes a file or directory.

  • For files, remove() is equivalent to unlink().
  • For directories, remove() is equivalent to rmdir().

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func rename(String, String) (deprecated)

public func rename(oldName: String, newName: String): Int32

Description: Renames a file, and moves the file to another directory when required. Any other hard links of the file are not affected. The file descriptors opened in the old path are not affected.

Constraints determine whether the rename operation is successful. The specific scenarios are as follows:

  • If newName already exists, it is replaced atomically so that another process trying to access newName does not find it lost, but there may be a window where both the old and new paths reference the file to be renamed.
  • If the old and new paths are existing hard links that reference the same file, the rename operation is not performed and success is returned.
  • If newName exists but the operation fails for some reason, the newName instance is retained.
  • oldName can specify a directory. In this case, newName must be unique or specify an empty directory.
  • If the old path references a symbolic link, the link is renamed. If the new path references a symbolic link, the link is overwritten.

NOTE

This function will be deprecated in future releases.

Parameters:

  • oldName: String: file name (including the path)
  • newName: String: file name (including the path)

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter oldName or newName contains null characters, this exception is thrown.

func renameat(Int32, String, Int32, String) (deprecated)

public func renameat(oldfd: Int32, oldName: String, newfd: Int32, newName: String): Int32

Description: Renames a file, and moves the file to another directory when required.

renameat() and rename() are processed in the same way. The following describes only the differences between them:

  • If oldName is a relative path and oldfd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If oldName is a relative path and oldfd is not AT_FDCWD, the path is relative to the directory to which the file referenced by oldfd belongs.
  • If oldName is an absolute path, the oldfd parameter is ignored.
  • newName is similar to oldName. The only difference is that when newName is a relative path, the path is the directory to which the file referenced by newfd belongs.

NOTE

This function will be deprecated in future releases.

Parameters:

  • oldfd: Int32: file descriptor
  • oldName: String: file name
  • newfd: Int32: file descriptor
  • newName: String: file name

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter oldName or newName contains null characters, this exception is thrown.

func setgid(UInt32) (deprecated)

public func setgid(id: UInt32): Int32

Description: Sets the valid group ID of the called process, which requires appropriate permissions.

NOTE

This function will be deprecated in future releases.

Parameters:

  • id: UInt32: valid group ID of the called process

Returns:

  • Int32: If the setting is successful, 0 is returned. Otherwise, -1 is returned.

func sethostname(String) (deprecated)

public func sethostname(buf: String): Int32

Description: Sets a host name. Only the superuser can call this function.

NOTE

This function will be deprecated in future releases.

Parameters:

  • buf: String: host name to be set

Returns:

  • Int32: If the setting is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func setpgid(Int32, Int32) (deprecated)

public func setpgid(pid: Int32, pgrp: Int32): Int32

Description: Sets the group ID specified by pid to the group pid specified by pgrp. If pid is set to 0, the group ID of the current process is used.

NOTE

This function will be deprecated in future releases.

Parameters:

  • pid: Int32: process ID
  • pgrp: Int32: process group ID

Returns:

  • Int32: If the execution is successful, the group ID is returned. Otherwise, -1 is returned.

func setpgrp() (deprecated)

public func setpgrp(): Int32

Description: Sets the group ID to which the current process belongs to the process ID of the current process. This function is equivalent to setpgid(0, 0).

NOTE

This function will be deprecated in future releases.

Returns:

  • Int32: If the execution is successful, the current process group ID is returned. Otherwise, -1 is returned.

func setuid(UInt32) (deprecated)

public func setuid(id: UInt32): Int32

Description: Sets the valid user ID of the called process, which requires appropriate permissions.

NOTE

This function will be deprecated in future releases.

Parameters:

  • id: UInt32: valid group ID of the called process

Returns:

  • Int32: If the setting is successful, 0 is returned. Otherwise, -1 is returned.

func symlink(String, String) (deprecated)

public func symlink(path: String, symPath: String): Int32

Description: Creates a link named symPath to the file specified by path.

  • A symbolic link is replaced by the actual file or directory when executed.
  • Symbolic links may contain .. path components. Such components (if used at the beginning of a link) reference the parent directory.
  • A symbolic link (also called a soft link) can point to an existing file or a file that does not exist. The latter is called a dangling link.
  • The permissions of symbolic links are unrelated. When a link is traced, the ownership is ignored. However, when a request for deleting or renaming the link is initiated and the link is in a directory with the sticky bit set, the ownership is checked.
  • If symPath already exists, the existing file is not overwritten.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter path or symPath contains null characters, this exception is thrown.

func symlinkat(String, Int32, String) (deprecated)

public func symlinkat(path: String, fd: Int32, symPath: String): Int32

Description: Creates a link named symPath to the file specified by path and fd.

  • If symPath is a relative path and fd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If symPath is a relative path and fd is not AT_FDCWD, the path is relative to the directory to which the file referenced by fd belongs.
  • If symPath is an absolute path, the fd parameter is ignored.

NOTE

This function will be deprecated in future releases.

Parameters:

  • path: String: file path
  • fd: Int32: file descriptor
  • symPath: String: linked file path

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

  • IllegalArgumentException: If the function parameter path or symPath contains null characters, this exception is thrown.

func ttyname(Int32) (deprecated)

public func ttyname(fd: Int32): String

Description: Returns the terminal name.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor

Returns:

  • String: If the operation is successful, the path name is returned. Otherwise, NULL is returned.

func umask(UInt32) (deprecated)

public func umask(cmask: UInt32): UInt32

Description: Sets a permission mask.

NOTE

This function will be deprecated in future releases.

Parameters:

  • cmask: UInt32: file permission parameter.

Returns:

  • UInt32: The previous mask of the file is returned.

func unlink(String) (deprecated)

public func unlink(path: String): Int32

Description: Deletes a file from the file system.

  • If path is the last link to a file and no process is using the file, the file is deleted and the space used by the file can be reused.
  • If path is the last link to a file but the file is still used by a process, the file exists until the last file descriptor that references it is closed.
  • If path references a symbolic link, the link is deleted.
  • If path references a socket, FIFO, or device, the file is deleted, but it may still be used by the process that opens the object.

NOTE

This function will be deprecated in future releases.

Parameters:

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func unlinkat(Int32, String, Int32) (deprecated)

public func unlinkat(fd: Int32, path: String, ulflag: Int32): Int32

Description: Deletes a file from the file system.

The system call method of this function is the same as that of unlink, except for the differences described below.

  • If path is a relative path and fd is set to a special value AT_FDCWD, the path is relative to the current working directory of the called process.
  • If path is a relative path and fd is not AT_FDCWD, the path is relative to the directory to which the file referenced by fd belongs.
  • If path is an absolute path, the fd parameter is ignored.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor
  • path: String: file path
  • ulflag: Int32: specified as 0 or set to a bitwise OR operation of the flag value that controls the unlinkat() operation Currently, the flag value can only be AT_REMOVEDIR.

Returns:

  • Int32: If the operation is successful, 0 is returned. Otherwise, -1 is returned.

Throws:

func write(Int32, CPointer<UInt8>, UIntNative) (deprecated)

public unsafe func write(fd: Int32, buffer: CPointer<UInt8>, nbyte: UIntNative): IntNative

Description: Writes nbyte in the memory specified by buffer to the file specified by fd. The read or write location of the specified file change accordingly.

It is recommended that the size of nbyte be the same as that of buffer, and the size of buffer be less than or equal to 150,000 bytes.

NOTE

This function will be deprecated in future releases.

Parameters:

  • fd: Int32: file descriptor of the file to be written to
  • buffer: CPointer<UInt8>: buffer container
  • nbyte: UIntNative: number of bytes to be read. buffer.size is recommended.

Returns:

  • IntNative: The number of actually read bytes is returned. If the read operation is invalid, -1 is returned.