Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Unlink a file, deleting it if the number of hardlinks is 1
path_unlink_file (
fd: i32The file descriptor representing the base directory from which the path is understoodpath: i32A wasm pointer to a null-terminated string containing the path of the file to be unlinkedpath_len: i32The length of the path string
) =>
error: i32 

The path_unlink_file() function unlinks a file at the specified path. If the file has only one hardlink (i.e., its link count is 1), it will be deleted from the file system. It requires the PATH_UNLINK_FILE right on the base file descriptor.

On POSIX systems, a similar functionality is provided by the unlink() function. It removes the specified file from the file system. If the file has no other hardlinks, it is completely deleted. The unlink() function is part of the POSIX standard and is widely supported across different platforms.

Note

The path_unlink_file() function unlinks a file at the specified path, deleting it if the number of hardlinks is 1. It checks the necessary rights on the base file descriptor. On POSIX systems, a similar functionality is provided by the unlink() function.

Read More