muteki
Loading...
Searching...
No Matches
fs.h
Go to the documentation of this file.
1/*
2 * Copyright 2021-present dogtopus
3 * SPDX-License-Identifier: MIT
4 */
5
11#ifndef __MUTEKI_FS_H__
12#define __MUTEKI_FS_H__
13
14#include <muteki/common.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
25#define SYS_PATH_MAX_CU 256u
26
30#define FIND_TS_YEAR(ts) ((ts >> 25) + 1980)
34#define FIND_TS_MONTH(ts) ((ts >> 21) & 0xf)
38#define FIND_TS_DAY(ts) ((ts >> 16) & 0x1f)
39
43#define FIND_TS_HOUR(ts) ((ts >> 11) & 0x1f)
47#define FIND_TS_MINUTE(ts) ((ts >> 5) & 0x3f)
51#define FIND_TS_SECOND(ts) ((ts & 0xf) * 4)
52
54#define FNSPLIT_LFN_PATHNAME_MAX 261u
56#define FNSPLIT_LFN_DRIVE_MAX 4u
58#define FNSPLIT_LFN_DIRNAME_MAX 257u
60#define FNSPLIT_LFN_BASENAME_MAX 257u
62#define FNSPLIT_LFN_SUFFIX_MAX 259u
63
65#define FNSPLIT_DOS_PATHNAME_MAX 81u
67#define FNSPLIT_DOS_DRIVE_MAX 4u
69#define FNSPLIT_DOS_DIRNAME_MAX 67u
71#define FNSPLIT_DOS_BASENAME_MAX 10u
73#define FNSPLIT_DOS_SUFFIX_MAX 9u
74
88 ATTR_DIR = 0x10,
91 ATTR_DEVICE = 0x40,
93 ATTR_NONE = 0x80,
94};
95
99typedef struct {
103 void *unk0; // 0x0
107 void *unk4; // 0x4
111 char *filename; // 0xc
116 char *filename2_alt; // 0x10
118 size_t size; // 0x14
128 unsigned int mtime; // 0x18
134 unsigned int btime; // 0x1c
139 unsigned int atime; // 0x20
141 unsigned char attrib_mask; // 0x24
143 unsigned char attrib; // 0x25
145
149typedef struct {
151 size_t size_kb;
153 size_t size2_kb;
155 size_t size3_kb;
157 size_t used_kb;
159 size_t free_kb;
161 unsigned long long SYS_DWORD size;
163 unsigned long long SYS_DWORD size2;
165 unsigned long long SYS_DWORD size3;
167 unsigned long long SYS_DWORD used;
169 unsigned long long SYS_DWORD free;
170} fs_stat_t;
171
197
223
231extern bool _aremove(const char *pathname);
232
240extern bool __wremove(const UTF16 *pathname);
241
254extern short _afindfirst(const char *fnmatch, find_context_t *ctx, int attrib_mask);
255
264extern short _afindnext(find_context_t *ctx);
265
278extern short _wfindfirst(const UTF16 *fnmatch, find_context_t *ctx, int attrib_mask);
279
293extern short _wfindnext(find_context_t *ctx);
294
301extern int _findclose(find_context_t *ctx);
302
311extern short _wfgetattr(UTF16 *path);
312
322extern short _wfsetattr(UTF16 *path, short attrs);
323
332extern short _afgetattr(char *path);
333
343extern short _afsetattr(char *path, short attrs);
344
352extern int _wmkdir(UTF16 *path);
353
361extern int _amkdir(char *path);
362
371extern int _wrmdir(UTF16 *path);
372
381extern int _armdir(char *path);
382
391extern short _agetcurdir(void *unk, char *buf);
392
401extern short _wgetcurdir(void *unk, UTF16 *buf);
402
410extern short _achdir(const char *path);
411
419extern short _wchdir(const UTF16 *path);
420
429extern short _arename(const char *old_path, const char *new_path);
430
439extern short _wrename(const UTF16 *old_path, const UTF16 *new_path);
440
448extern int FSGetDiskRoomState(int fsid, fs_stat_t *fs_stat);
449
466extern int _afnsplit(const char *pathname, char *drive, char *dirname, char *basename, char *suffix);
467
481extern int _afnmerge(char *pathname, const char *drive, const char *dirname, const char *basename, const char *suffix);
482
508extern int _wfnsplit(const UTF16 *pathname, UTF16 *drive, UTF16 *dirname, UTF16 *basename, UTF16 *suffix);
509
533extern int _wfnmerge(UTF16 *pathname, const UTF16 *drive, const UTF16 *dirname, const UTF16 *basename, const UTF16 *suffix);
534
535#ifdef __cplusplus
536} // extern "C"
537#endif
538
539#endif // __MUTEKI_FS_H__
Common include file for all muteki-shims headers.
#define UTF16
"Portable" Besta UTF-16 type used by other headers.
Definition common.h:54
#define SYS_DWORD
Attribute for structure fields that are DWORD (64-bit), that are used by system calls.
Definition common.h:80
#define FNSPLIT_LFN_BASENAME_MAX
Definition fs.h:60
#define FNSPLIT_DOS_SUFFIX_MAX
Definition fs.h:73
int _wfnsplit(const UTF16 *pathname, UTF16 *drive, UTF16 *dirname, UTF16 *basename, UTF16 *suffix)
Split an LFN pathname into parts.
#define FNSPLIT_LFN_DRIVE_MAX
Definition fs.h:56
short _wfsetattr(UTF16 *path, short attrs)
Set attributes of specific path.
#define FNSPLIT_LFN_PATHNAME_MAX
Definition fs.h:54
short _wfgetattr(UTF16 *path)
Get attributes of specific path.
int _wrmdir(UTF16 *path)
Remove a directory.
bool _aremove(const char *pathname)
Delete a file.
short _wgetcurdir(void *unk, UTF16 *buf)
Get system CWD value.
#define FNSPLIT_LFN_DIRNAME_MAX
Definition fs.h:58
int _amkdir(char *path)
Create a new directory.
struct fn_parts_dos_s fs_parts_dos_t
All-in-one struct that contain all parts used in _afnsplit() and _afnmerge()
short _wfindfirst(const UTF16 *fnmatch, find_context_t *ctx, int attrib_mask)
Begin a file/directory search (LFN support).
#define FNSPLIT_DOS_BASENAME_MAX
Definition fs.h:71
int _afnsplit(const char *pathname, char *drive, char *dirname, char *basename, char *suffix)
Split a DOS 8.3 pathname into parts.
struct fn_parts_lfn_s fs_parts_lfn_t
All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge()
int _afnmerge(char *pathname, const char *drive, const char *dirname, const char *basename, const char *suffix)
Build an DOS 8.3 pathname from parts.
bool __wremove(const UTF16 *pathname)
Delete a file.
short _afsetattr(char *path, short attrs)
Set attributes of specific path.
short _afgetattr(char *path)
Get attributes of specific path.
int _wfnmerge(UTF16 *pathname, const UTF16 *drive, const UTF16 *dirname, const UTF16 *basename, const UTF16 *suffix)
Build an LFN pathname from parts.
short _wchdir(const UTF16 *path)
Change system working directory to a new path.
short _wrename(const UTF16 *old_path, const UTF16 *new_path)
Rename/move a file.
#define FNSPLIT_LFN_SUFFIX_MAX
Definition fs.h:62
#define FNSPLIT_DOS_DIRNAME_MAX
Definition fs.h:69
short _achdir(const char *path)
Change system working directory to a new path.
short _agetcurdir(void *unk, char *buf)
Get system CWD value.
fs_attribute_e
File/directory attributes.
Definition fs.h:80
@ ATTR_SYSTEM
Definition fs.h:86
@ ATTR_READONLY
Definition fs.h:82
@ ATTR_NONE
Definition fs.h:93
@ ATTR_DIR
Definition fs.h:88
@ ATTR_HIDDEN
Definition fs.h:84
@ ATTR_ARCHIVE
Definition fs.h:90
short _afindnext(find_context_t *ctx)
Continue a previously started file/directory search.
int _findclose(find_context_t *ctx)
Terminate a file/directory search.
short _arename(const char *old_path, const char *new_path)
Rename/move a file.
#define FNSPLIT_DOS_DRIVE_MAX
Definition fs.h:67
int FSGetDiskRoomState(int fsid, fs_stat_t *fs_stat)
Get filesystem usage stats.
short _afindfirst(const char *fnmatch, find_context_t *ctx, int attrib_mask)
Begin a file/directory search.
int _armdir(char *path)
Remove a directory.
short _wfindnext(find_context_t *ctx)
Continue a previously started file/directory search.
#define FNSPLIT_DOS_PATHNAME_MAX
Definition fs.h:65
int _wmkdir(UTF16 *path)
Create a new directory.
Structure for find context.
Definition fs.h:99
char * filename2_alt
Seems to be a mirror of filename.
Definition fs.h:116
void * unk4
Next file descriptor.
Definition fs.h:107
unsigned int btime
Create/birth timestamp.
Definition fs.h:134
void * unk0
Current file descriptor.
Definition fs.h:103
unsigned int mtime
Modify timestamp.
Definition fs.h:128
char * filename
Definition fs.h:111
unsigned int atime
Access timestamp.
Definition fs.h:139
UTF16 * filename_lfn
Definition fs.h:109
unsigned char attrib_mask
Definition fs.h:141
unsigned char attrib
Definition fs.h:143
size_t size
Definition fs.h:118
All-in-one struct that contain all parts used in _afnsplit() and _afnmerge()
Definition fs.h:201
char pathname[FNSPLIT_DOS_PATHNAME_MAX]
Pathname.
Definition fs.h:205
char suffix[FNSPLIT_DOS_SUFFIX_MAX]
Suffix.
Definition fs.h:221
char drive[FNSPLIT_DOS_DRIVE_MAX]
Drive.
Definition fs.h:209
char dirname[FNSPLIT_DOS_DIRNAME_MAX]
Directory name.
Definition fs.h:213
char basename[FNSPLIT_DOS_BASENAME_MAX]
Base name without suffix.
Definition fs.h:217
All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge()
Definition fs.h:175
UTF16 suffix[FNSPLIT_LFN_SUFFIX_MAX]
Suffix.
Definition fs.h:195
UTF16 pathname[FNSPLIT_LFN_PATHNAME_MAX]
Pathname.
Definition fs.h:179
UTF16 drive[FNSPLIT_LFN_DRIVE_MAX]
Drive.
Definition fs.h:183
UTF16 basename[FNSPLIT_LFN_BASENAME_MAX]
Base name without suffix.
Definition fs.h:191
UTF16 dirname[FNSPLIT_LFN_DIRNAME_MAX]
Directory name.
Definition fs.h:187
Filesystem usage statistics.
Definition fs.h:149
unsigned long long size3
Definition fs.h:165
unsigned long long size
Definition fs.h:161
unsigned long long free
Definition fs.h:169
size_t size3_kb
Definition fs.h:155
unsigned long long used
Definition fs.h:167
size_t size_kb
Definition fs.h:151
size_t free_kb
Definition fs.h:159
unsigned long long size2
Definition fs.h:163
size_t used_kb
Definition fs.h:157
size_t size2_kb
Definition fs.h:153