Package ej.wasi.io.file
Class WasiDirStub
- java.lang.Object
-
- ej.wasi.io.file.WasiDirStub
-
- All Implemented Interfaces:
WasiDir,WasiIO,WasiConstants,Closeable,AutoCloseable
public class WasiDirStub extends Object implements WasiDir
-
-
Field Summary
-
Fields inherited from interface ej.wasi.WasiConstants
AF_INET, AF_INET6, BLOCKING_CONNECT_TIMEOUT, BUFFERED_INPUT_STREAM_SIZE, CLOCK_MONOTONIC, CLOCK_REALTIME, DIRENT_COOKIE_OFFSET, DIRENT_ENTRY_NAME_LENGTH_OFFSET, DIRENT_FILE_TYPE_OFFSET, DIRENT_INODE_OFFSET, DIRENT_SIZE, ERRNO_ACCES, ERRNO_ADDRINUSE, ERRNO_ADDRNOTAVAIL, ERRNO_AFNOSUPPORT, ERRNO_AGAIN, ERRNO_BADF, ERRNO_CONNREFUSED, ERRNO_EXIST, ERRNO_FAULT, ERRNO_HOSTUNREACH, ERRNO_INPROGRESS, ERRNO_INTR, ERRNO_INVAL, ERRNO_IO, ERRNO_ISCONN, ERRNO_ISDIR, ERRNO_MSGSIZE, ERRNO_NAMETOOLONG, ERRNO_NOENT, ERRNO_NOMEM, ERRNO_NOSYS, ERRNO_NOTCONN, ERRNO_NOTDIR, ERRNO_NOTEMPTY, ERRNO_NOTSOCK, ERRNO_NOTSUP, ERRNO_OVERFLOW, ERRNO_SPIPE, ERRNO_SUCCESS, EVENT_AVAILABLE_BYTE_OFFSET, EVENT_ERROR_OFFSET, EVENT_EVENT_TYPE_OFFSET, EVENT_READ_WRITE_HANGUP_OFFSET, EVENT_SIZE, EVENT_USER_DATA_OFFSET, FDFLAGS_APPEND_MASK, FDFLAGS_NON_BLOCK_MASK, FDSTAT_BASE_RIGHTS_OFFSET, FDSTAT_FILE_TYPE_OFFSET, FDSTAT_FLAGS_OFFSET, FDSTAT_INHERITING_RIGHTS_OFFSET, FILESTAT_FILESIZE_OFFSET, FILESTAT_FILETYPE_OFFSET, FILESTAT_INODE_OFFSET, FILESTAT_LAST_MODIFIED_TIME_OFFSET, IFF_LOOPBACK, IFF_RUNNING, IFF_UP, IOVEC_BUFFER_INDEX, IOVEC_BUFFER_LENGTH_INDEX, IOVEC_SIZE, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_TTL, IPPROTO_IP, IPPROTO_IPV6, IPv4AddressSize, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPv6AddressSize, LOOKUPFLAGS_SYMLINK_FOLLOW_MASK, MILLIS_TO_NANO, NON_BLOCKING_TIMEOUT, OFLAGS_CREAT_MASK, OFLAGS_DIRECTORY_MASK, OFLAGS_EXCL_MASK, OFLAGS_TRUNC_MASK, POLLING_TIMEOUT, PREOPENTYPE_DIR, PREOPENTYPE_UNKNOWN, PRESTAT_PREOPEN_DIRNAME_OFFSET, PRESTAT_PREOPEN_TAG_OFFSET, RIFLAGS_MSG_PEEK_MASK, RIFLAGS_WAITALL_MASK, RIGHTS_ALL, RIGHTS_DIR, SDFLAGS_READ, SDFLAGS_WRITE, SO_BROADCAST, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SOCK_CLOEXEC, SOCK_NONBLOCK, SOCKET_LEVEL, UDP_PEEK_BUFFER_MAX_SIZE
-
-
Constructor Summary
Constructors Constructor Description WasiDirStub(String dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this stream and releases any system resources associated with it.voiddelete()StringgetCanonicalPath()StringgetDirname()FileTypegetType()Gets the WasiIO file descriptor type.longlastModidied()WasiDiropenDir(String path)WasiFileopenFile(String filename)WasiIOopenFileOrDir(String path)voidrenameTo(WasiDir newFile)intwasiCreateDirectory(int pathPtr, int pathLen, byte[] memory)Creates a directory in the same way that the posix mkdir() function wouldintwasiFilestatsSetTimes(int flags, int pathPtr, int pathLen, long accessTime, long modifiedTime, int fstFlags, byte[] memory)Adjust the timestamps of a file or directory.intwasigetPathFileStat(int flags, int pathPtr, int pathLen, int filestatPtr, byte[] memory)intwasiOpenPath(WasiIORegistry registry, int dirflags, int pathPtr, int pathLen, int oflags, int fdPtr, byte[] memory)intwasiReadDir(int bufPtr, int bufLen, long cookie, int resPtr, byte[] memory)
-
-
-
Constructor Detail
-
WasiDirStub
public WasiDirStub(String dir) throws IOException
- Throws:
IOException
-
-
Method Detail
-
close
public void close() throws IOExceptionDescription copied from interface:CloseableCloses this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
lastModidied
public long lastModidied()
- Specified by:
lastModidiedin interfaceWasiDir
-
getCanonicalPath
public String getCanonicalPath() throws IOException
- Specified by:
getCanonicalPathin interfaceWasiDir- Throws:
IOException
-
openFile
public WasiFile openFile(String filename) throws IOException
- Specified by:
openFilein interfaceWasiDir- Throws:
IOException
-
getType
public FileType getType()
Description copied from interface:WasiIOGets the WasiIO file descriptor type.
-
getDirname
public String getDirname()
- Specified by:
getDirnamein interfaceWasiDir
-
wasiReadDir
public int wasiReadDir(int bufPtr, int bufLen, long cookie, int resPtr, byte[] memory)- Specified by:
wasiReadDirin interfaceWasiDir
-
wasigetPathFileStat
public int wasigetPathFileStat(int flags, int pathPtr, int pathLen, int filestatPtr, byte[] memory)- Specified by:
wasigetPathFileStatin interfaceWasiDir
-
wasiFilestatsSetTimes
public int wasiFilestatsSetTimes(int flags, int pathPtr, int pathLen, long accessTime, long modifiedTime, int fstFlags, byte[] memory)Adjust the timestamps of a file or directory. Note: This is similar to utimensat in POSIX. Note: Currently only sets the modified time, and does nothing when trying to change access time.- Specified by:
wasiFilestatsSetTimesin interfaceWasiDir- Parameters:
flags- Flags determining the method of how the path is resolved.pathPtr- pointer to path stringpathLen- length of pathaccessTime- The desired values of the data access timestamp.modifiedTime- The desired values of the data modification timestamp.fstFlags- A bitmask indicating which timestamps to adjust. Bit 0 = Adjust the last data access timestamp to the value stored in accessTime Bit 1 = Adjust the last data access timestamp to the time of clock Bit 2 = Adjust the last data modification timestamp to the value stored in modifiedTime Bit 3 = Adjust the last data modification timestamp to the time of clockmemory- WASI memory- Returns:
- an ERRNO.
-
wasiOpenPath
public int wasiOpenPath(WasiIORegistry registry, int dirflags, int pathPtr, int pathLen, int oflags, int fdPtr, byte[] memory)
- Specified by:
wasiOpenPathin interfaceWasiDir
-
wasiCreateDirectory
public int wasiCreateDirectory(int pathPtr, int pathLen, byte[] memory)Creates a directory in the same way that the posix mkdir() function would- Specified by:
wasiCreateDirectoryin interfaceWasiDir- Parameters:
pathPtr- Pointer to a null-terminated string.pathLen- The length of the path string.memory- WASI memory- Returns:
- Errno number.
-
openDir
public WasiDir openDir(String path) throws IOException
- Specified by:
openDirin interfaceWasiDir- Throws:
IOException
-
delete
public void delete() throws WasiIOException- Specified by:
deletein interfaceWasiDir- Throws:
WasiIOException
-
openFileOrDir
public WasiIO openFileOrDir(String path) throws IOException
- Specified by:
openFileOrDirin interfaceWasiDir- Throws:
IOException
-
renameTo
public void renameTo(WasiDir newFile) throws IOException
- Specified by:
renameToin interfaceWasiDir- Throws:
IOException
-
-