@@ -7,6 +7,7 @@ Index of this file:
77// [SECTION] header mess
88// [SECTION] includes
99// [SECTION] APIs
10+ // [SECTION] defines
1011// [SECTION] forward declarations
1112// [SECTION] public apis
1213// [SECTION] enums
@@ -33,24 +34,36 @@ Index of this file:
3334//-----------------------------------------------------------------------------
3435
3536#define plAtomicsI_version {1, 0, 0}
36- #define plFileI_version {1, 0 , 0}
37+ #define plFileI_version {1, 1 , 0}
3738#define plNetworkI_version {1, 0, 0}
3839#define plThreadsI_version {1, 0, 1}
3940#define plVirtualMemoryI_version {1, 0, 0}
4041
42+ //-----------------------------------------------------------------------------
43+ // [SECTION] defines
44+ //-----------------------------------------------------------------------------
45+
46+ #ifndef PL_MAX_PATH_LENGTH
47+ #define PL_MAX_PATH_LENGTH 1024
48+ #endif
49+
4150//-----------------------------------------------------------------------------
4251// [SECTION] forward declarations
4352//-----------------------------------------------------------------------------
4453
45- // basic types (atomics ext )
54+ // basic types (atomics)
4655typedef struct _plAtomicCounter plAtomicCounter ; // opaque type
4756
48- // basic types (network ext)
57+ // basic types (file)
58+ typedef struct _plDirectoryEntry plDirectoryEntry ;
59+ typedef struct _plDirectoryInfo plDirectoryInfo ;
60+
61+ // basic types (network)
4962typedef struct _plSocket plSocket ; // opaque type (used by platform backends)
5063typedef struct _plNetworkAddress plNetworkAddress ; // opaque type (used by platform backends)
5164typedef struct _plSocketReceiverInfo plSocketReceiverInfo ;
5265
53- // basic types (threads ext )
66+ // basic types (threads)
5467typedef struct _plThread plThread ; // opaque type (used by platform backends)
5568typedef struct _plMutex plMutex ; // opaque type (used by platform backends)
5669typedef struct _plCriticalSection plCriticalSection ; // opaque type (used by platform backends)
@@ -61,18 +74,19 @@ typedef struct _plThreadKey plThreadKey; // opaque type (used by
6174
6275typedef void * (* plThreadProcedure )(void * ); // thread procedure signature
6376
64- // enums (atomics ext )
77+ // enums (atomics)
6578typedef int plAtomicsResult ; // -> enum _plAtomicsResult // Enum:
6679
67- // enums (file ext)
68- typedef int plFileResult ; // -> enum _plFileResult // Enum:
80+ // enums (file)
81+ typedef int plFileResult ; // -> enum _plFileResult // Enum:
82+ typedef int plDirectoryEntryType ; // -> enum _plDirectoryEntryType // Enum:
6983
70- // enums (network ext )
84+ // enums (network)
7185typedef int plNetworkAddressFlags ; // -> enum _plNetworkAddressFlags // Flags:
7286typedef int plSocketFlags ; // -> enum _plSocketFlags // Flags:
7387typedef int plNetworkResult ; // -> enum _plNetworkResult // Enum:
7488
75- // enums (thread ext )
89+ // enums (thread)
7690typedef int plThreadResult ; // -> enum _plThreadResult // Enum:
7791
7892//-----------------------------------------------------------------------------
@@ -104,6 +118,15 @@ typedef struct _plFileI
104118 plFileResult (* binary_read ) (const char * file , size_t * sizeOut , uint8_t * buffer ); // pass NULL for buffer to get size
105119 plFileResult (* binary_write )(const char * file , size_t , uint8_t * buffer );
106120
121+ // simple directory ops
122+ bool (* directory_exists )(const char * path );
123+ plFileResult (* create_directory )(const char * path );
124+ plFileResult (* remove_directory )(const char * path );
125+
126+ // directory info
127+ plFileResult (* get_directory_info ) (const char * path , plDirectoryInfo * infoOut );
128+ void (* cleanup_directory_info )(plDirectoryInfo * infoOut );
129+
107130} plFileI ;
108131
109132typedef struct _plNetworkI
@@ -221,7 +244,24 @@ enum _plAtomicsResult
221244enum _plFileResult
222245{
223246 PL_FILE_RESULT_FAIL = 0 ,
224- PL_FILE_RESULT_SUCCESS = 1
247+ PL_FILE_RESULT_SUCCESS = 1 ,
248+
249+ PL_FILE_DIRECTORY_NOT_EMPTY = 2 ,
250+ PL_FILE_DIRECTORY_ALREADY_EXIST = 3
251+ };
252+
253+ enum _plDirectoryEntryType
254+ {
255+ PL_DIRECTORY_ENTRY_TYPE_UNKNOWN = 0 ,
256+ PL_DIRECTORY_ENTRY_TYPE_DIRECTORY ,
257+ PL_DIRECTORY_ENTRY_TYPE_FILE ,
258+
259+ // Linux/MacOS only
260+ PL_DIRECTORY_ENTRY_TYPE_PIPE ,
261+ PL_DIRECTORY_ENTRY_TYPE_LINK ,
262+ PL_DIRECTORY_ENTRY_TYPE_SOCKET ,
263+ PL_DIRECTORY_ENTRY_TYPE_BLOCK_DEVICE ,
264+ PL_DIRECTORY_ENTRY_TYPE_CHARACTER_DEVICE ,
225265};
226266
227267enum _plNetworkAddressFlags
@@ -261,4 +301,18 @@ typedef struct _plSocketReceiverInfo
261301 char acServiceBuffer [100 ];
262302} plSocketReceiverInfo ;
263303
304+ typedef struct _plDirectoryEntry
305+ {
306+ plDirectoryEntryType tType ;
307+ char acName [PL_MAX_PATH_LENGTH ];
308+ } plDirectoryEntry ;
309+
310+ typedef struct _plDirectoryInfo
311+ {
312+ uint32_t uFileCount ;
313+ uint32_t uDirectoryCount ;
314+ uint32_t uEntryCount ;
315+ plDirectoryEntry * sbtEntries ;
316+ } plDirectoryInfo ;
317+
264318#endif // PL_PLATFORM_EXT_H
0 commit comments