summaryrefslogtreecommitdiff
path: root/include/kernel/kernel/iofilemgr
diff options
context:
space:
mode:
Diffstat (limited to 'include/kernel/kernel/iofilemgr')
-rw-r--r--include/kernel/kernel/iofilemgr/async.h93
-rw-r--r--include/kernel/kernel/iofilemgr/dirent.h82
-rw-r--r--include/kernel/kernel/iofilemgr/stat.h101
3 files changed, 276 insertions, 0 deletions
diff --git a/include/kernel/kernel/iofilemgr/async.h b/include/kernel/kernel/iofilemgr/async.h
new file mode 100644
index 0000000..4584bb7
--- /dev/null
+++ b/include/kernel/kernel/iofilemgr/async.h
@@ -0,0 +1,93 @@
+#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_
+#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_
+
+#include <psp2common/kernel/iofilemgr/async.h>
+#include <psp2kern/kernel/threadmgr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Async IO operations are scheduled automatically, similar to FIOS2.
+ * You can make calls to sceIoOpenAsync(), sceIoReadAsync(),
+ * sceIoCloseAsync() right after each other, they will be put in a schedule
+ * and performed automatically.
+ *
+ * All async IO functions return UID of operation handle, not file descriptor UID.
+ */
+
+/**
+ * Cancel an asynchronous operation.
+ *
+ * @param opHandle - The operation handle to perform cancel on.
+ *
+ * @return < 0 on error. If operation has been canceled(finished) already, returns 0x80010002
+ */
+int sceIoCancel(SceUID opHandle);
+
+/**
+ * Complete an asynchronous operation.
+ *
+ * @param opHandle - The operation handle to complete.
+ *
+ * @return < 0 on error.
+ */
+int sceIoComplete(SceUID opHandle);
+
+/**
+ * Wait until asynchronous operation has been finished.
+ *
+ * @param opHandle - The operation handle to wait for.
+ *
+ * @return < 0 on error.
+ */
+inline
+int sceIoWaitAsync(SceUID opHandle)
+{
+ int ret = sceKernelWaitEvent(opHandle, 1, NULL, NULL, NULL);
+ if (ret == 0)
+ return sceIoComplete(opHandle);
+ else
+ return ret;
+}
+
+/**
+ * Wait until asynchronous operation has been finished with callbacks.
+ *
+ * @param opHandle - The operation handle to wait for.
+ *
+ * @return < 0 on error.
+ */
+inline
+int sceIoWaitAsyncCB(SceUID opHandle)
+{
+ int ret = sceKernelWaitEventCB(opHandle, 1, NULL, NULL, NULL);
+ if (ret == 0)
+ return sceIoComplete(opHandle);
+ else
+ return ret;
+}
+
+/**
+ * Poll asynchronous operation status.
+ *
+ * @param opHandle - The operation handle to poll status for.
+ *
+ * @return < 0 on error or if operation is not finished.
+ */
+inline
+int sceIoPollAsync(SceUID opHandle)
+{
+ int ret = sceKernelPollEvent(opHandle, 1, NULL, NULL);
+ if (ret == 0)
+ return sceIoComplete(opHandle);
+ else
+ return ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ */
diff --git a/include/kernel/kernel/iofilemgr/dirent.h b/include/kernel/kernel/iofilemgr/dirent.h
new file mode 100644
index 0000000..4bfc584
--- /dev/null
+++ b/include/kernel/kernel/iofilemgr/dirent.h
@@ -0,0 +1,82 @@
+#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_
+#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_
+
+#include <psp2common/kernel/iofilemgr/dirent.h>
+#include <psp2kern/kernel/iofilemgr/async.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Open a directory
+ *
+ * @par Example:
+ * @code
+ * int dfd;
+ * dfd = sceIoDopen("device:/");
+ * if(dfd >= 0)
+ * { Do something with the file descriptor }
+ * @endcode
+ * @param dirname - The directory to open for reading.
+ * @return If >= 0 then a valid file descriptor, otherwise a Sony error code.
+ */
+SceUID sceIoDopen(const char *dirname);
+
+/**
+ * Close an opened directory file descriptor
+ *
+ * @param fd - Already opened file descriptor (using ::sceIoDopen)
+ * @return < 0 on error
+ */
+int sceIoDclose(SceUID fd);
+
+/**
+ * Reads an entry from an opened file descriptor.
+ *
+ * @param fd - Already opened file descriptor (using ::sceIoDopen)
+ * @param buf - Pointer to a ::SceIoDirent structure to hold the file information
+ *
+ * @return Read status
+ * - 0 - No more directory entries left
+ * - > 0 - More directory entries to go
+ * - < 0 - Error
+ */
+int sceIoDread(SceUID fd, SceIoDirent *buf);
+
+/**
+ * Open a directory (asynchronous)
+ *
+ * @param dirname - The directory to open for reading.
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return If >= 0 then a valid op handle, otherwise a Sony error code.
+ */
+SceUID sceIoDopenAsync(const char *dirname, SceIoAsyncParam* asyncParam);
+
+/**
+ * Reads an entry from an opened file descriptor (asynchronous)
+ *
+ * @param fd - Already opened file descriptor (using ::sceIoDopen or ::sceIoDopenAsync)
+ * @param dir - Pointer to a ::SceIoDirent structure to hold the file information
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return If >= 0 then a valid op handle, otherwise a Sony error code.
+ */
+SceUID sceIoDreadAsync(SceUID fd, SceIoDirent *dir, SceIoAsyncParam* asyncParam);
+
+/**
+ * Close an opened directory file descriptor (asynchronous)
+ *
+ * @param fd - Already opened file descriptor (using ::sceIoDopen or ::sceIoDopenAsync)
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return If >= 0 then a valid op handle, otherwise a Sony error code.
+ */
+SceUID sceIoDcloseAsync(SceUID fd, SceIoAsyncParam* asyncParam);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ */
diff --git a/include/kernel/kernel/iofilemgr/stat.h b/include/kernel/kernel/iofilemgr/stat.h
new file mode 100644
index 0000000..c9096e2
--- /dev/null
+++ b/include/kernel/kernel/iofilemgr/stat.h
@@ -0,0 +1,101 @@
+#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_
+#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_
+
+#include <psp2common/kernel/iofilemgr/stat.h>
+#include <psp2kern/kernel/iofilemgr/async.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Change the status of a file.
+ *
+ * @param name - The path to the file.
+ * @param buf - A pointer to a ::SceIoStat structure.
+ * @param cbit - Bitmask defining which bits to change.
+ *
+ * @return < 0 on error.
+ */
+int sceIoChstat(const char *name, const SceIoStat *buf, unsigned int cbit);
+
+/**
+ * Get the status of a file.
+ *
+ * @param name - The path to the file.
+ * @param buf - A pointer to a ::SceIoStat structure.
+ *
+ * @return < 0 on error.
+ */
+int sceIoGetstat(const char *name, SceIoStat *buf);
+
+/**
+ * Get the status of a file descriptor.
+ *
+ * @param fd - The file descriptor.
+ * @param buf - A pointer to a ::SceIoStat structure.
+ *
+ * @return < 0 on error.
+ */
+int sceIoGetstatByFd(SceUID fd, SceIoStat *buf);
+
+/**
+ * Change the status of a file descriptor.
+ *
+ * @param fd - The file descriptor.
+ * @param buf - A pointer to an io_stat_t structure.
+ * @param cbit - Bitmask defining which bits to change.
+ *
+ * @return < 0 on error.
+ */
+int sceIoChstatByFd(SceUID fd, const SceIoStat *buf, unsigned int cbit);
+
+/**
+ * Make a directory file (asynchronous)
+ *
+ * @param dir - The path to the directory
+ * @param mode - Access mode (One or more ::SceIoAccessMode).
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return A non-negative integer is a valid op handle, anything else an error
+ */
+SceUID sceIoMkdirAsync(const char *dir, SceMode mode, SceIoAsyncParam* asyncParam);
+
+/**
+ * Remove a directory file (asynchronous)
+ *
+ * @param path - Removes a directory file pointed by the string path
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return A non-negative integer is a valid op handle, anything else an error
+ */
+SceUID sceIoRmdirAsync(const char *path, SceIoAsyncParam* asyncParam);
+
+/**
+ * Get the status of a file (asynchronous)
+ *
+ * @param file - The path to the file.
+ * @param stat - A pointer to a ::SceIoStat structure.
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return A non-negative integer is a valid op handle, anything else an error
+ */
+SceUID sceIoGetstatAsync(const char *file, SceIoStat *stat, SceIoAsyncParam* asyncParam);
+
+/**
+ * Change the status of a file (asynchronous)
+ *
+ * @param file - The path to the file.
+ * @param stat - A pointer to a ::SceIoStat structure.
+ * @param bits - Bitmask defining which bits to change.
+ * @param asyncParam - parameters related to async operation.
+ *
+ * @return A non-negative integer is a valid op handle, anything else an error
+ */
+SceUID sceIoChstatAsync(const char *file, SceIoStat *stat, int bits, SceIoAsyncParam* asyncParam);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_ */