2022-03-15 20:56:32 +00:00
|
|
|
#pragma once
|
2023-02-17 20:52:03 +00:00
|
|
|
#include <stdint.h>
|
2023-02-19 22:38:32 +00:00
|
|
|
#include "../../CoreLib/Path.h"
|
2023-02-19 21:14:58 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
#define FS_FILE 0
|
|
|
|
#define FS_DIRECTORY 1
|
|
|
|
#define FS_INVALID 2
|
|
|
|
#define DEVICE_MAX 26
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
typedef struct _FILE {
|
|
|
|
char name [32];
|
|
|
|
uint32_t flags;
|
|
|
|
uint32_t filelength;
|
|
|
|
uint32_t id;
|
|
|
|
uint32_t eof;
|
|
|
|
uint32_t position;
|
|
|
|
uint32_t currentCluster;
|
|
|
|
uint32_t device;
|
|
|
|
}FILE, *PFILE;
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
typedef struct _FILE_SYSTEM{
|
|
|
|
char name[8];
|
|
|
|
FILE (*Directory) (const char* Directoryname);
|
|
|
|
void (*Mount) ();
|
|
|
|
void (*Read) (PFILE file, unsigned char* buffer, unsigned int length);
|
|
|
|
void (Close) (PFILE);
|
|
|
|
FILE (*Open) (const char* filename);
|
|
|
|
}FILESYSTEM, *PFILESYSTEM;
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
typedef struct _MOUNT_INFO{
|
|
|
|
uint32_t numSectors;
|
|
|
|
uint32_t fatOffset;
|
|
|
|
uint32_t numRootEntries;
|
|
|
|
uint32_t rootOffset;
|
|
|
|
uint32_t rootSize;
|
|
|
|
uint32_t fatSize;
|
|
|
|
uint32_t fatEntrySize;
|
|
|
|
}MOUNT_INFO, *PMOUNT_INFO;
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
typedef struct _DIRECTORY{
|
|
|
|
uint8_t Filename[8];
|
|
|
|
uint8_t Ext[3];
|
|
|
|
uint8_t Attrib;
|
|
|
|
uint8_t Reserved;
|
|
|
|
uint8_t TimeCreatedMs;
|
|
|
|
uint16_t TimeCreated;
|
|
|
|
uint16_t DateCreated;
|
|
|
|
uint16_t DateLastAccessed;
|
|
|
|
uint16_t FirstClusterHiBytes;
|
|
|
|
uint16_t LastModTime;
|
|
|
|
uint16_t LastModDate;
|
|
|
|
uint16_t FirstCluster;
|
|
|
|
uint32_t FileSize;
|
|
|
|
}DIRECTORY, *PDIRECTORY;
|
|
|
|
// Date Format
|
|
|
|
// [0..4] Day
|
|
|
|
// [5..8] Month
|
|
|
|
// [9..15] Year
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
// Time Format
|
|
|
|
// [0..4] Seconds
|
|
|
|
// [5..10] Minute
|
|
|
|
// [11..15] Hour
|
|
|
|
extern PFILESYSTEM _filesystems[DEVICE_MAX];
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
FILE volOpenFile(const char* fname);
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
void volCloseFile(PFILE file);
|
|
|
|
void volRegisterFilesystem(PFILESYSTEM, unsigned int deviceID);
|
|
|
|
void volUnregisterFilesystem(PFILESYSTEM);
|
|
|
|
void volUnregisterFileSystemByID(unsigned int deviceID);
|
|
|
|
|
|
|
|
|
|
|
|
class FileSystem{
|
|
|
|
public:
|
|
|
|
static void initialize();
|
|
|
|
|
2023-02-19 21:14:58 +00:00
|
|
|
static void ResolvePath(Path& path);
|
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
};
|