summaryrefslogtreecommitdiff
path: root/include/user/kernel/iofilemgr
diff options
context:
space:
mode:
authorReiko Asakura2020-07-21 15:10:11 -0400
committerReiko Asakura2020-07-21 15:10:11 -0400
commit16f304f919c7a23e615ca1c045fc98a53ae01824 (patch)
tree9716d989df32a044d8fad807eaf669b06946a025 /include/user/kernel/iofilemgr
parentAdd doc and remove unneeded include (diff)
downloadvds-libraries-16f304f919c7a23e615ca1c045fc98a53ae01824.tar.gz
Refactor userland SceIofilemgr headers
Diffstat (limited to 'include/user/kernel/iofilemgr')
-rw-r--r--include/user/kernel/iofilemgr/dirent.h58
-rw-r--r--include/user/kernel/iofilemgr/stat.h89
2 files changed, 147 insertions, 0 deletions
diff --git a/include/user/kernel/iofilemgr/dirent.h b/include/user/kernel/iofilemgr/dirent.h
new file mode 100644
index 0000000..e343910
--- /dev/null
+++ b/include/user/kernel/iofilemgr/dirent.h
@@ -0,0 +1,58 @@
+#ifndef _DOLCESDK_PSP2_KERNEL_IOFILEMGR_DIRENT_H_
+#define _DOLCESDK_PSP2_KERNEL_IOFILEMGR_DIRENT_H_
+
+#include <psp2/kernel/iofilemgr/stat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Describes a single directory entry */
+typedef struct SceIoDirent {
+ SceIoStat d_stat; //!< File status
+ char d_name[256]; //!< File name (not file path)
+ void *d_private; //!< Reserved (set to 0)
+ int dummy; //!< Padding
+} SceIoDirent;
+
+/**
+ * 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DOLCESDK_PSP2_KERNEL_IOFILEMGR_DIRENT_H_ */
diff --git a/include/user/kernel/iofilemgr/stat.h b/include/user/kernel/iofilemgr/stat.h
new file mode 100644
index 0000000..03b880f
--- /dev/null
+++ b/include/user/kernel/iofilemgr/stat.h
@@ -0,0 +1,89 @@
+#ifndef _DOLCESDK_PSP2_KERNEL_IOFILEMGR_STAT_H_
+#define _DOLCESDK_PSP2_KERNEL_IOFILEMGR_STAT_H_
+
+#include <psp2/kernel/types.h>
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Filetypes and Protection bits */
+#define SCE_STM_FMT (0xf << 12)
+#define SCE_STM_FREG (0x2 << 12) /* regular file */
+#define SCE_STM_FDIR (0x1 << 12) /* directory */
+#define SCE_STM_ISREG(m) (((m) & SCE_STM_FMT) == SCE_STM_FREG)
+#define SCE_STM_ISDIR(m) (((m) & SCE_STM_FMT) == SCE_STM_FDIR)
+
+/* for SceMode */
+#define SCE_STM_RWU 00600
+#define SCE_STM_RU 00400
+
+/* for chstat cbit */
+#define SCE_CST_MODE 0x0001
+#define SCE_CST_ATTR 0x0000 /* not supported */
+#define SCE_CST_SIZE 0x0004
+#define SCE_CST_CT 0x0008
+#define SCE_CST_AT 0x0010
+#define SCE_CST_MT 0x0020
+
+/**
+ * See sceIoChstat(), sceIoGetstat(), sceIoChstatByFd(), sceIoGetstatByFd()
+ */
+typedef struct SceIoStat {
+ SceIoMode st_mode; //!< File access mode
+ unsigned int st_attr; //!< Device-specific attribute
+ SceOff st_size; //!< File size
+ SceDateTime st_ctime; //!< File creation time
+ SceDateTime st_atime; //!< File last accessed time
+ SceDateTime st_mtime; //!< File last modified time
+ unsigned int st_private[6]; //!< Reserved
+} SceIoStat;
+
+/**
+ * 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DOLCESDK_PSP2_KERNEL_IOFILEMGR_STAT_H_ */