llvm-mos-sdk
file.h
Go to the documentation of this file.
1 // Copyright 2024 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 #include <stdint.h>
7 
8 #ifndef _NEO_FILE_H
9 #define _NEO_FILE_H
10 
11 #include <neo6502.h>
12 #include "types.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef enum neo_file_mode {
24 
25 #define NEO_FILE_DESTINATION_GRAPHICS ((void*) 0xFFFF)
26 
27 typedef struct neo_file_stat {
31 
32 #define NEO_FIOATTR_DIR 0x01
33 #define NEO_FIOATTR_SYSTEM 0x02
34 #define NEO_FIOATTR_ARCHIVE 0x04
35 #define NEO_FIOATTR_READONLY 0x08
36 #define NEO_FIOATTR_HIDDEN 0x10
37 
38 #define NEO_FIOERROR_OK 0x00
39 #define NEO_FIOERROR_UNKNOWN 0x01
40 #define NEO_FIOERROR_EOF 0x02
41 #define NEO_FIOERROR_UNIMPLEMENTED 0x03
42 #define NEO_FIOERROR_NO_FILE 0x11
43 #define NEO_FIOERROR_NO_PATH 0x12
44 #define NEO_FIOERROR_INVALID_DRIVE 0x13
45 #define NEO_FIOERROR_INVALID_NAME 0x14
46 #define NEO_FIOERROR_INVALID_PARAMETER 0x15
47 #define NEO_FIOERROR_DENIED 0x21
48 #define NEO_FIOERROR_EXIST 0x22
49 #define NEO_FIOERROR_INVALID_OBJECT 0x23
50 #define NEO_FIOERROR_WRITE_PROTECTED 0x24
51 #define NEO_FIOERROR_LOCKED 0x25
52 #define NEO_FIOERROR_DISK_ERR 0x31
53 #define NEO_FIOERROR_INT_ERR 0x32
54 #define NEO_FIOERROR_NOT_READY 0x33
55 #define NEO_FIOERROR_NOT_ENABLED 0x34
56 #define NEO_FIOERROR_NO_FILESYSTEM 0x35
57 #define NEO_FIOERROR_MKFS_ABORTED 0x41
58 #define NEO_FIOERROR_TIMEOUT 0x42
59 #define NEO_FIOERROR_NOT_ENOUGH_CORE 0x43
60 #define NEO_FIOERROR_TOO_MANY_OPEN_FILES 0x44
61 
62 // Legacy synonyms.
63 #define NEO_FILE_ATTR_DIRECTORY NEO_FIOATTR_DIR
64 #define NEO_FILE_ATTR_SYSTEM NEO_FIOATTR_SYSTEM
65 #define NEO_FILE_ATTR_ARCHIVE NEO_FIOATTR_ARCHIVE
66 #define NEO_FILE_ATTR_READ_ONLY NEO_FIOATTR_READONLY
67 #define NEO_FILE_ATTR_HIDDEN NEO_FIOATTR_HIDDEN
68 
72 void neo_file_list_directory(void);
73 
84 void neo_file_load_p(const neo_pstring_t *filename, void *dest);
85 
96 void neo_file_load(const char *filename, void *dest);
97 
107 void neo_file_store_p(const neo_pstring_t *filename, const void *src, uint16_t len);
108 
118 void neo_file_store(const char *filename, const void *src, uint16_t len);
119 
129 void neo_file_open_p(uint8_t channel, const neo_pstring_t *filename, uint8_t mode);
130 
140 void neo_file_open(uint8_t channel, const char *filename, uint8_t mode);
141 
150 
160 
170 
184 
196 
206 
216 
225 void neo_file_rename_p(const neo_pstring_t *from, const neo_pstring_t *to);
226 
235 void neo_file_rename(const char *from, const char *to);
236 
247 void neo_file_delete_p(const neo_pstring_t *filename);
248 
259 void neo_file_delete(const char *filename);
260 
268 void neo_file_chdir_p(const neo_pstring_t *path);
269 
277 void neo_file_chdir(const char *path);
278 
286 void neo_file_mkdir_p(const neo_pstring_t *path);
287 
295 void neo_file_mkdir(const char *path);
296 
305 void neo_file_stat_p(const neo_pstring_t *path, neo_file_stat_t *st);
306 
315 void neo_file_stat(const char *path, neo_file_stat_t *st);
316 
324 void neo_file_opendir_p(const neo_pstring_t *path);
325 
333 void neo_file_opendir(const char *path);
334 
344 
353 void neo_file_readdir(char *path, neo_file_stat_t *st);
354 
360 void neo_file_closedir(void);
361 
370 void neo_file_copy_p(const neo_pstring_t *from, const neo_pstring_t *to);
371 
380 void neo_file_copy(const char *from, const char *to);
381 
390 void neo_file_set_attr_p(const neo_pstring_t *path, uint8_t attr);
391 
400 void neo_file_set_attr(const char *path, uint8_t attr);
401 
409 
416 void neo_file_get_cwd(char *buffer, uint8_t length);
417 
423 void neo_file_list_filtered_p(const neo_pstring_t *filter);
424 
430 void neo_file_list_filtered(const char *filter);
431 
432 #ifdef __cplusplus
433 }
434 #endif
435 
436 #endif
neo_file_stat
Definition: file.h:27
neo_file_open
void neo_file_open(uint8_t channel, const char *filename, uint8_t mode)
Open a file channel, using a C string for the filename.
neo_file_load_p
void neo_file_load_p(const neo_pstring_t *filename, void *dest)
Load a file into memory, using a Pascal string for the filename.
std::uint16_t
::uint16_t uint16_t
Definition: cstdint:22
neo_file_seek
void neo_file_seek(uint8_t channel, uint32_t pos)
Seek a file.
neo_file_mkdir_p
void neo_file_mkdir_p(const neo_pstring_t *path)
Create directory, using a Pascal string for the path.
types.h
neo_file_copy_p
void neo_file_copy_p(const neo_pstring_t *from, const neo_pstring_t *to)
Copy file, using Pascal strings for the filenames.
NEO_FILE_READ_WRITE
@ NEO_FILE_READ_WRITE
Definition: file.h:21
neo_file_list_filtered_p
void neo_file_list_filtered_p(const neo_pstring_t *filter)
Display a filtered listing of files in the current directory, using a Pascal string for the needle.
neo_file_chdir
void neo_file_chdir(const char *path)
Change current working directory, using a C string for the path.
neo_file_rename
void neo_file_rename(const char *from, const char *to)
Rename file, using C strings for the filenames.
neo_file_opendir
void neo_file_opendir(const char *path)
Open a directory for enumeration, using a C string for the path.
neo_file_load
void neo_file_load(const char *filename, void *dest)
Load a file into memory, using a C string for the filename.
neo_file_stat_t
struct neo_file_stat neo_file_stat_t
length
uint8_t uint16_t uint16_t length
Definition: bios.h:181
std::uint8_t
::uint8_t uint8_t
Definition: cstdint:21
to
char to
Definition: nesdoug.h:55
neo_file_write
uint32_t neo_file_write(uint8_t channel, const void *src, uint16_t len)
Write bytes to an open file.
attr
char char char attr
Definition: neslib.h:85
neo_file_chdir_p
void neo_file_chdir_p(const neo_pstring_t *path)
Change current working directory, using a Pascal string for the path.
neo_file_set_attr
void neo_file_set_attr(const char *path, uint8_t attr)
Set file attributes, using a C string for the filename.
neo_file_readdir
void neo_file_readdir(char *path, neo_file_stat_t *st)
Read the next file item from the directory, returning a C string for the path.
neo_file_rename_p
void neo_file_rename_p(const neo_pstring_t *from, const neo_pstring_t *to)
Rename file, using Pascal strings for the filenames.
NEO_FILE_CREATE
@ NEO_FILE_CREATE
Definition: file.h:22
neo_pstring
Definition: types.h:15
channel
char channel
Definition: famitone2.h:31
NEO_FILE_WRITE
@ NEO_FILE_WRITE
Definition: file.h:20
src
const void * src
Definition: memory.h:57
neo_file_list_filtered
void neo_file_list_filtered(const char *filter)
Display a filtered listing of files in the current directory, using a C string for the needle.
neo_file_readdir_p
void neo_file_readdir_p(neo_pstring_t *path, neo_file_stat_t *st)
Read the next file item from the directory, returning a Pascal string for the path.
neo_file_list_directory
void neo_file_list_directory(void)
Display the listing of files in the current directory.
NEO_FILE_READ
@ NEO_FILE_READ
Definition: file.h:19
neo_file_store_p
void neo_file_store_p(const neo_pstring_t *filename, const void *src, uint16_t len)
Store a file from memory, using a Pascal string for the filename.
neo_file_stat_p
void neo_file_stat_p(const neo_pstring_t *path, neo_file_stat_t *st)
Retrieve file information, using a Pascal string for the path.
neo_file_stat::size
uint32_t size
Definition: file.h:28
size
unsigned size
Definition: neslib.h:185
neo6502.h
neo_file_close
void neo_file_close(uint8_t channel)
Close a file channel.
neo_file_set_size
void neo_file_set_size(uint8_t channel, uint32_t size)
Set the file's size.
neo_file_eof
bool neo_file_eof(uint8_t channel)
Check if file is at end of file.
neo_file_size
uint32_t neo_file_size(uint8_t channel)
Get the file's size, in bytes.
neo_file_delete_p
void neo_file_delete_p(const neo_pstring_t *filename)
Delete file, using Pascal strings for the filename.
neo_file_mkdir
void neo_file_mkdir(const char *path)
Create directory, using a C string for the path.
neo_file_delete
void neo_file_delete(const char *filename)
Delete file, using C strings for the filename.
neo_file_tell
uint32_t neo_file_tell(uint8_t channel)
Tell a file's position.
neo_file_mode_t
enum neo_file_mode neo_file_mode_t
neo_file_set_attr_p
void neo_file_set_attr_p(const neo_pstring_t *path, uint8_t attr)
Set file attributes, using a Pascal string for the filename.
neo_file_stat::attr
uint8_t attr
Definition: file.h:29
neo_file_opendir_p
void neo_file_opendir_p(const neo_pstring_t *path)
Open a directory for enumeration, using a Pascal string for the path.
neo_file_mode
neo_file_mode
Definition: file.h:18
std::uint32_t
::uint32_t uint32_t
Definition: cstdint:23
neo_file_open_p
void neo_file_open_p(uint8_t channel, const neo_pstring_t *filename, uint8_t mode)
Open a file channel, using a Pascal string for the filename.
neo_file_copy
void neo_file_copy(const char *from, const char *to)
Copy file, using C strings for the filenames.
mode
const void uint16_t uint8_t mode
Definition: memory.h:58
neo_file_get_cwd
void neo_file_get_cwd(char *buffer, uint8_t length)
Retrieve the current working directory.
neo_file_closedir
void neo_file_closedir(void)
Close the directory opened with.
neo_file_read
uint16_t neo_file_read(uint8_t channel, void *dest, uint16_t len)
Read bytes from an open file.
neo_file_store
void neo_file_store(const char *filename, const void *src, uint16_t len)
Store a file from memory, using a C string for the filename.
len
char len
Definition: nesdoug.h:26
neo_file_stat
void neo_file_stat(const char *path, neo_file_stat_t *st)
Retrieve file information, using a C string for the path.