Muteki
EABI code execution on Besta® RTOS devices.
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1/*
2 * Copyright 2021-present dogtopus
3 * SPDX-License-Identifier: MIT
4 */
5
10
11#ifndef __MUTEKI_FS_PATH_H__
12#define __MUTEKI_FS_PATH_H__
13
14#include "../common.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
25#define BXC_FS_PATH_MAX_CU 256u
26
30#define BXC_FIND_TS_YEAR(ts) ((ts >> 25) + 1980)
34#define BXC_FIND_TS_MONTH(ts) ((ts >> 21) & 0xf)
38#define BXC_FIND_TS_DAY(ts) ((ts >> 16) & 0x1f)
39
43#define BXC_FIND_TS_HOUR(ts) ((ts >> 11) & 0x1f)
47#define BXC_FIND_TS_MINUTE(ts) ((ts >> 5) & 0x3f)
51#define BXC_FIND_TS_SECOND(ts) ((ts & 0xf) * 4)
52
54#define BXC_FNSPLIT_LFN_PATHNAME_MAX 261u
56#define BXC_FNSPLIT_LFN_DRIVE_MAX 4u
58#define BXC_FNSPLIT_LFN_DIRNAME_MAX 257u
60#define BXC_FNSPLIT_LFN_BASENAME_MAX 257u
62#define BXC_FNSPLIT_LFN_SUFFIX_MAX 259u
63
65#define BXC_FNSPLIT_DOS_PATHNAME_MAX 81u
67#define BXC_FNSPLIT_DOS_DRIVE_MAX 4u
69#define BXC_FNSPLIT_DOS_DIRNAME_MAX 67u
71#define BXC_FNSPLIT_DOS_BASENAME_MAX 10u
73#define BXC_FNSPLIT_DOS_SUFFIX_MAX 9u
74
91 BXC_FS_ATTR_DEVICE = 0x40,
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;
171
197
223
231extern bool _aremove(const char *pathname);
232
240extern bool __wremove(const UTF16 *pathname);
241
254extern short _afindfirst(const char *fnmatch, bxc_find_context_t *ctx, int attrib_mask);
255
265
278extern short _wfindfirst(const UTF16 *fnmatch, bxc_find_context_t *ctx, int attrib_mask);
279
294
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, bxc_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_PATH_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
int _wfnsplit(const UTF16 *pathname, UTF16 *drive, UTF16 *dirname, UTF16 *basename, UTF16 *suffix)
Split an LFN pathname into parts.
short _wfsetattr(UTF16 *path, short attrs)
Set attributes of specific path.
short _wfgetattr(UTF16 *path)
Get attributes of specific path.
int _wrmdir(UTF16 *path)
Remove a directory.
#define BXC_FNSPLIT_LFN_BASENAME_MAX
Definition path.h:60
bool _aremove(const char *pathname)
Delete a file.
short _wgetcurdir(void *unk, UTF16 *buf)
Get system CWD value.
short _wfindnext(bxc_find_context_t *ctx)
Continue a previously started file/directory search.
#define BXC_FNSPLIT_DOS_DIRNAME_MAX
Definition path.h:69
#define BXC_FNSPLIT_DOS_PATHNAME_MAX
Definition path.h:65
int _amkdir(char *path)
Create a new directory.
#define BXC_FNSPLIT_DOS_SUFFIX_MAX
Definition path.h:73
int FSGetDiskRoomState(int fsid, bxc_fs_stat_t *fs_stat)
Get filesystem usage stats.
#define BXC_FNSPLIT_LFN_PATHNAME_MAX
Definition path.h:54
struct bxc_fs_parts_lfn_s bxc_fs_parts_lfn_t
All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge().
int _afnsplit(const char *pathname, char *drive, char *dirname, char *basename, char *suffix)
Split a DOS 8.3 pathname into parts.
#define BXC_FNSPLIT_LFN_DRIVE_MAX
Definition path.h:56
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 _afindfirst(const char *fnmatch, bxc_find_context_t *ctx, int attrib_mask)
Begin a file/directory search.
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 BXC_FNSPLIT_DOS_DRIVE_MAX
Definition path.h:67
short _afindnext(bxc_find_context_t *ctx)
Continue a previously started file/directory search.
short _wfindfirst(const UTF16 *fnmatch, bxc_find_context_t *ctx, int attrib_mask)
Begin a file/directory search (LFN support).
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 path.h:80
@ BXC_FS_ATTR_HIDDEN
Definition path.h:84
@ BXC_FS_ATTR_READONLY
Definition path.h:82
@ BXC_FS_ATTR_SYSTEM
Definition path.h:86
@ BXC_FS_ATTR_ARCHIVE
Definition path.h:90
@ BXC_FS_ATTR_DIR
Definition path.h:88
@ BXC_FS_ATTR_NONE
Definition path.h:93
struct bxc_fs_parts_dos_s bxc_fs_parts_dos_t
All-in-one struct that contain all parts used in _afnsplit() and _afnmerge().
#define BXC_FNSPLIT_LFN_SUFFIX_MAX
Definition path.h:62
short _arename(const char *old_path, const char *new_path)
Rename/move a file.
#define BXC_FNSPLIT_LFN_DIRNAME_MAX
Definition path.h:58
int _findclose(bxc_find_context_t *ctx)
Terminate a file/directory search.
int _armdir(char *path)
Remove a directory.
#define BXC_FNSPLIT_DOS_BASENAME_MAX
Definition path.h:71
int _wmkdir(UTF16 *path)
Create a new directory.
Structure for find context.
Definition path.h:99
char * filename
Definition path.h:111
char * filename2_alt
Seems to be a mirror of filename.
Definition path.h:116
UTF16 * filename_lfn
Definition path.h:109
void * unk0
Current file descriptor.
Definition path.h:103
unsigned char attrib_mask
Definition path.h:141
size_t size
Definition path.h:118
unsigned int atime
Access timestamp.
Definition path.h:139
unsigned char attrib
Definition path.h:143
void * unk4
Next file descriptor.
Definition path.h:107
unsigned int btime
Create/birth timestamp.
Definition path.h:134
unsigned int mtime
Modify timestamp.
Definition path.h:128
All-in-one struct that contain all parts used in _afnsplit() and _afnmerge().
Definition path.h:201
char pathname[BXC_FNSPLIT_DOS_PATHNAME_MAX]
Pathname.
Definition path.h:205
char basename[BXC_FNSPLIT_DOS_BASENAME_MAX]
Base name without suffix.
Definition path.h:217
char drive[BXC_FNSPLIT_DOS_DRIVE_MAX]
Drive.
Definition path.h:209
char suffix[BXC_FNSPLIT_DOS_SUFFIX_MAX]
Suffix.
Definition path.h:221
char dirname[BXC_FNSPLIT_DOS_DIRNAME_MAX]
Directory name.
Definition path.h:213
All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge().
Definition path.h:175
UTF16 suffix[BXC_FNSPLIT_LFN_SUFFIX_MAX]
Suffix.
Definition path.h:195
UTF16 basename[BXC_FNSPLIT_LFN_BASENAME_MAX]
Base name without suffix.
Definition path.h:191
UTF16 drive[BXC_FNSPLIT_LFN_DRIVE_MAX]
Drive.
Definition path.h:183
UTF16 dirname[BXC_FNSPLIT_LFN_DIRNAME_MAX]
Directory name.
Definition path.h:187
UTF16 pathname[BXC_FNSPLIT_LFN_PATHNAME_MAX]
Pathname.
Definition path.h:179
Filesystem usage statistics.
Definition path.h:149
size_t size3_kb
Definition path.h:155
unsigned long long free
Definition path.h:169
unsigned long long size2
Definition path.h:163
unsigned long long size3
Definition path.h:165
size_t size2_kb
Definition path.h:153
size_t size_kb
Definition path.h:151
unsigned long long used
Definition path.h:167
unsigned long long size
Definition path.h:161
size_t free_kb
Definition path.h:159
size_t used_kb
Definition path.h:157