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_FILE_ATTR_DIRECTORY 0x01
33 #define NEO_FILE_ATTR_SYSTEM 0x02
34 #define NEO_FILE_ATTR_ARCHIVE 0x04
35 #define NEO_FILE_ATTR_READ_ONLY 0x08
36 #define NEO_FILE_ATTR_HIDDEN 0x10
37 
41 void neo_file_list_directory(void);
42 
53 void neo_file_load_p(const neo_pstring_t *filename, void *dest);
54 
65 void neo_file_load(const char *filename, void *dest);
66 
76 void neo_file_store_p(const neo_pstring_t *filename, const void *src, uint16_t len);
77 
87 void neo_file_store(const char *filename, const void *src, uint16_t len);
88 
99 
109 void neo_file_open(uint8_t channel, const char *filename, uint8_t mode);
110 
119 
129 
139 
153 
165 
175 
185 
194 void neo_file_rename_p(const neo_pstring_t *from, const neo_pstring_t *to);
195 
204 void neo_file_rename(const char *from, const char *to);
205 
216 void neo_file_delete_p(const neo_pstring_t *filename);
217 
228 void neo_file_delete(const char *filename);
229 
237 void neo_file_chdir_p(const neo_pstring_t *path);
238 
246 void neo_file_chdir(const char *path);
247 
255 void neo_file_mkdir_p(const neo_pstring_t *path);
256 
264 void neo_file_mkdir(const char *path);
265 
274 void neo_file_stat_p(const neo_pstring_t *path, neo_file_stat_t *st);
275 
284 void neo_file_stat(const char *path, neo_file_stat_t *st);
285 
293 void neo_file_opendir_p(const neo_pstring_t *path);
294 
302 void neo_file_opendir(const char *path);
303 
313 
322 void neo_file_readdir(char *path, neo_file_stat_t *st);
323 
329 void neo_file_closedir(void);
330 
339 void neo_file_copy_p(const neo_pstring_t *from, const neo_pstring_t *to);
340 
349 void neo_file_copy(const char *from, const char *to);
350 
359 void neo_file_set_attr_p(const neo_pstring_t *path, uint8_t attr);
360 
369 void neo_file_set_attr(const char *path, uint8_t attr);
370 
376 void neo_file_list_filtered_p(const neo_pstring_t *filter);
377 
383 void neo_file_list_filtered(const char *filter);
384 
385 #ifdef __cplusplus
386 }
387 #endif
388 
389 #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
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_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_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.