llvm-mos-sdk
Classes | Macros | Typedefs | Enumerations | Functions
file.h File Reference
#include <stdint.h>
#include <neo6502.h>
#include "types.h"
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  neo_file_stat
 

Macros

#define NEO_FILE_DESTINATION_GRAPHICS   ((void*) 0xFFFF)
 
#define NEO_FIOATTR_DIR   0x01
 
#define NEO_FIOATTR_SYSTEM   0x02
 
#define NEO_FIOATTR_ARCHIVE   0x04
 
#define NEO_FIOATTR_READONLY   0x08
 
#define NEO_FIOATTR_HIDDEN   0x10
 
#define NEO_FIOERROR_OK   0x00
 
#define NEO_FIOERROR_UNKNOWN   0x01
 
#define NEO_FIOERROR_EOF   0x02
 
#define NEO_FIOERROR_UNIMPLEMENTED   0x03
 
#define NEO_FIOERROR_NO_FILE   0x11
 
#define NEO_FIOERROR_NO_PATH   0x12
 
#define NEO_FIOERROR_INVALID_DRIVE   0x13
 
#define NEO_FIOERROR_INVALID_NAME   0x14
 
#define NEO_FIOERROR_INVALID_PARAMETER   0x15
 
#define NEO_FIOERROR_DENIED   0x21
 
#define NEO_FIOERROR_EXIST   0x22
 
#define NEO_FIOERROR_INVALID_OBJECT   0x23
 
#define NEO_FIOERROR_WRITE_PROTECTED   0x24
 
#define NEO_FIOERROR_LOCKED   0x25
 
#define NEO_FIOERROR_DISK_ERR   0x31
 
#define NEO_FIOERROR_INT_ERR   0x32
 
#define NEO_FIOERROR_NOT_READY   0x33
 
#define NEO_FIOERROR_NOT_ENABLED   0x34
 
#define NEO_FIOERROR_NO_FILESYSTEM   0x35
 
#define NEO_FIOERROR_MKFS_ABORTED   0x41
 
#define NEO_FIOERROR_TIMEOUT   0x42
 
#define NEO_FIOERROR_NOT_ENOUGH_CORE   0x43
 
#define NEO_FIOERROR_TOO_MANY_OPEN_FILES   0x44
 
#define NEO_FILE_ATTR_DIRECTORY   NEO_FIOATTR_DIR
 
#define NEO_FILE_ATTR_SYSTEM   NEO_FIOATTR_SYSTEM
 
#define NEO_FILE_ATTR_ARCHIVE   NEO_FIOATTR_ARCHIVE
 
#define NEO_FILE_ATTR_READ_ONLY   NEO_FIOATTR_READONLY
 
#define NEO_FILE_ATTR_HIDDEN   NEO_FIOATTR_HIDDEN
 

Typedefs

typedef enum neo_file_mode neo_file_mode_t
 
typedef struct neo_file_stat neo_file_stat_t
 

Enumerations

enum  neo_file_mode { NEO_FILE_READ = 0, NEO_FILE_WRITE = 1, NEO_FILE_READ_WRITE = 2, NEO_FILE_CREATE = 3 }
 

Functions

void neo_file_list_directory (void)
 Display the listing of files in the current directory. More...
 
void neo_file_load_p (const neo_pstring_t *filename, void *dest)
 Load a file into memory, using a Pascal string for the filename. More...
 
void neo_file_load (const char *filename, void *dest)
 Load a file into memory, using a C string for the filename. More...
 
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. More...
 
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. More...
 
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. More...
 
void neo_file_open (uint8_t channel, const char *filename, uint8_t mode)
 Open a file channel, using a C string for the filename. More...
 
void neo_file_close (uint8_t channel)
 Close a file channel. More...
 
void neo_file_seek (uint8_t channel, uint32_t pos)
 Seek a file. More...
 
uint32_t neo_file_tell (uint8_t channel)
 Tell a file's position. More...
 
uint16_t neo_file_read (uint8_t channel, void *dest, uint16_t len)
 Read bytes from an open file. More...
 
uint32_t neo_file_write (uint8_t channel, const void *src, uint16_t len)
 Write bytes to an open file. More...
 
uint32_t neo_file_size (uint8_t channel)
 Get the file's size, in bytes. More...
 
void neo_file_set_size (uint8_t channel, uint32_t size)
 Set the file's size. More...
 
void neo_file_rename_p (const neo_pstring_t *from, const neo_pstring_t *to)
 Rename file, using Pascal strings for the filenames. More...
 
void neo_file_rename (const char *from, const char *to)
 Rename file, using C strings for the filenames. More...
 
void neo_file_delete_p (const neo_pstring_t *filename)
 Delete file, using Pascal strings for the filename. More...
 
void neo_file_delete (const char *filename)
 Delete file, using C strings for the filename. More...
 
void neo_file_chdir_p (const neo_pstring_t *path)
 Change current working directory, using a Pascal string for the path. More...
 
void neo_file_chdir (const char *path)
 Change current working directory, using a C string for the path. More...
 
void neo_file_mkdir_p (const neo_pstring_t *path)
 Create directory, using a Pascal string for the path. More...
 
void neo_file_mkdir (const char *path)
 Create directory, using a C string for the path. More...
 
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. More...
 
void neo_file_stat (const char *path, neo_file_stat_t *st)
 Retrieve file information, using a C string for the path. More...
 
void neo_file_opendir_p (const neo_pstring_t *path)
 Open a directory for enumeration, using a Pascal string for the path. More...
 
void neo_file_opendir (const char *path)
 Open a directory for enumeration, using a C string for the path. More...
 
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. More...
 
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. More...
 
void neo_file_closedir (void)
 Close the directory opened with. More...
 
void neo_file_copy_p (const neo_pstring_t *from, const neo_pstring_t *to)
 Copy file, using Pascal strings for the filenames. More...
 
void neo_file_copy (const char *from, const char *to)
 Copy file, using C strings for the filenames. More...
 
void neo_file_set_attr_p (const neo_pstring_t *path, uint8_t attr)
 Set file attributes, using a Pascal string for the filename. More...
 
void neo_file_set_attr (const char *path, uint8_t attr)
 Set file attributes, using a C string for the filename. More...
 
bool neo_file_eof (uint8_t channel)
 Check if file is at end of file. More...
 
void neo_file_get_cwd (char *buffer, uint8_t length)
 Retrieve the current working directory. More...
 
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. More...
 
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. More...
 

Macro Definition Documentation

◆ NEO_FILE_ATTR_ARCHIVE

#define NEO_FILE_ATTR_ARCHIVE   NEO_FIOATTR_ARCHIVE

◆ NEO_FILE_ATTR_DIRECTORY

#define NEO_FILE_ATTR_DIRECTORY   NEO_FIOATTR_DIR

◆ NEO_FILE_ATTR_HIDDEN

#define NEO_FILE_ATTR_HIDDEN   NEO_FIOATTR_HIDDEN

◆ NEO_FILE_ATTR_READ_ONLY

#define NEO_FILE_ATTR_READ_ONLY   NEO_FIOATTR_READONLY

◆ NEO_FILE_ATTR_SYSTEM

#define NEO_FILE_ATTR_SYSTEM   NEO_FIOATTR_SYSTEM

◆ NEO_FILE_DESTINATION_GRAPHICS

#define NEO_FILE_DESTINATION_GRAPHICS   ((void*) 0xFFFF)

◆ NEO_FIOATTR_ARCHIVE

#define NEO_FIOATTR_ARCHIVE   0x04

◆ NEO_FIOATTR_DIR

#define NEO_FIOATTR_DIR   0x01

◆ NEO_FIOATTR_HIDDEN

#define NEO_FIOATTR_HIDDEN   0x10

◆ NEO_FIOATTR_READONLY

#define NEO_FIOATTR_READONLY   0x08

◆ NEO_FIOATTR_SYSTEM

#define NEO_FIOATTR_SYSTEM   0x02

◆ NEO_FIOERROR_DENIED

#define NEO_FIOERROR_DENIED   0x21

◆ NEO_FIOERROR_DISK_ERR

#define NEO_FIOERROR_DISK_ERR   0x31

◆ NEO_FIOERROR_EOF

#define NEO_FIOERROR_EOF   0x02

◆ NEO_FIOERROR_EXIST

#define NEO_FIOERROR_EXIST   0x22

◆ NEO_FIOERROR_INT_ERR

#define NEO_FIOERROR_INT_ERR   0x32

◆ NEO_FIOERROR_INVALID_DRIVE

#define NEO_FIOERROR_INVALID_DRIVE   0x13

◆ NEO_FIOERROR_INVALID_NAME

#define NEO_FIOERROR_INVALID_NAME   0x14

◆ NEO_FIOERROR_INVALID_OBJECT

#define NEO_FIOERROR_INVALID_OBJECT   0x23

◆ NEO_FIOERROR_INVALID_PARAMETER

#define NEO_FIOERROR_INVALID_PARAMETER   0x15

◆ NEO_FIOERROR_LOCKED

#define NEO_FIOERROR_LOCKED   0x25

◆ NEO_FIOERROR_MKFS_ABORTED

#define NEO_FIOERROR_MKFS_ABORTED   0x41

◆ NEO_FIOERROR_NO_FILE

#define NEO_FIOERROR_NO_FILE   0x11

◆ NEO_FIOERROR_NO_FILESYSTEM

#define NEO_FIOERROR_NO_FILESYSTEM   0x35

◆ NEO_FIOERROR_NO_PATH

#define NEO_FIOERROR_NO_PATH   0x12

◆ NEO_FIOERROR_NOT_ENABLED

#define NEO_FIOERROR_NOT_ENABLED   0x34

◆ NEO_FIOERROR_NOT_ENOUGH_CORE

#define NEO_FIOERROR_NOT_ENOUGH_CORE   0x43

◆ NEO_FIOERROR_NOT_READY

#define NEO_FIOERROR_NOT_READY   0x33

◆ NEO_FIOERROR_OK

#define NEO_FIOERROR_OK   0x00

◆ NEO_FIOERROR_TIMEOUT

#define NEO_FIOERROR_TIMEOUT   0x42

◆ NEO_FIOERROR_TOO_MANY_OPEN_FILES

#define NEO_FIOERROR_TOO_MANY_OPEN_FILES   0x44

◆ NEO_FIOERROR_UNIMPLEMENTED

#define NEO_FIOERROR_UNIMPLEMENTED   0x03

◆ NEO_FIOERROR_UNKNOWN

#define NEO_FIOERROR_UNKNOWN   0x01

◆ NEO_FIOERROR_WRITE_PROTECTED

#define NEO_FIOERROR_WRITE_PROTECTED   0x24

Typedef Documentation

◆ neo_file_mode_t

◆ neo_file_stat_t

Enumeration Type Documentation

◆ neo_file_mode

Enumerator
NEO_FILE_READ 
NEO_FILE_WRITE 
NEO_FILE_READ_WRITE 
NEO_FILE_CREATE 

Function Documentation

◆ neo_file_chdir()

void neo_file_chdir ( const char *  path)

Change current working directory, using a C string for the path.

Parameters
pathPath (C string)

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathPath (Pascal string)

Check errors with

See also
neo_api_error

◆ neo_file_close()

void neo_file_close ( uint8_t  channel)

Close a file channel.

Parameters
channelFile channel ID

Check errors with

See also
neo_api_error

◆ neo_file_closedir()

void neo_file_closedir ( void  )

Close the directory opened with.

See also
neo_file_opendir .

Check errors with

See also
neo_api_error

◆ neo_file_copy()

void neo_file_copy ( const char *  from,
const char *  to 
)

Copy file, using C strings for the filenames.

Parameters
fromOld filename (C string)
toNew filename (C string)

Check errors with

See also
neo_api_error

◆ 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.

Parameters
fromOld filename (Pascal string)
toNew filename (Pascal string)

Check errors with

See also
neo_api_error

◆ neo_file_delete()

void neo_file_delete ( const char *  filename)

Delete file, using C strings for the filename.

Note that deleting an open file is undefined behaviour. In addition, directories can only be deleted if empty.

Parameters
filenameFilename (C string)

Check errors with

See also
neo_api_error

◆ neo_file_delete_p()

void neo_file_delete_p ( const neo_pstring_t filename)

Delete file, using Pascal strings for the filename.

Note that deleting an open file is undefined behaviour. In addition, directories can only be deleted if empty.

Parameters
filenameFilename (Pascal string)

Check errors with

See also
neo_api_error

◆ neo_file_eof()

bool neo_file_eof ( uint8_t  channel)

Check if file is at end of file.

Parameters
channelFile channel ID
Returns
True if file is at end of file.

◆ neo_file_get_cwd()

void neo_file_get_cwd ( char *  buffer,
uint8_t  length 
)

Retrieve the current working directory.

Parameters
bufferBuffer to write the current working directory to.
lengthLength of buffer, in bytes.

◆ neo_file_list_directory()

void neo_file_list_directory ( void  )

Display the listing of files in the current directory.

◆ 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.

Parameters
filterFilename search needle (C string)

◆ 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.

Parameters
filterFilename search needle (Pascal string)

◆ neo_file_load()

void neo_file_load ( const char *  filename,
void *  dest 
)

Load a file into memory, using a C string for the filename.

To load a file into graphics memory, use

See also
NEO_FILE_DESTINATION_GRAPHICS .
Parameters
filenameFilename (C string)
destDestination

Check errors with

See also
neo_api_error

◆ 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.

To load a file into graphics memory, use

See also
NEO_FILE_DESTINATION_GRAPHICS .
Parameters
filenameFilename (Pascal string)
destDestination

Check errors with

See also
neo_api_error

◆ neo_file_mkdir()

void neo_file_mkdir ( const char *  path)

Create directory, using a C string for the path.

Parameters
pathPath (C string)

Check errors with

See also
neo_api_error

◆ neo_file_mkdir_p()

void neo_file_mkdir_p ( const neo_pstring_t path)

Create directory, using a Pascal string for the path.

Parameters
pathPath (Pascal string)

Check errors with

See also
neo_api_error

◆ 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.

Parameters
channelFile channel ID
filenameFilename (C string)
modeMode
See also
neo_file_mode_t

Check errors with

See also
neo_api_error

◆ 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.

Parameters
channelFile channel ID
filenameFilename (Pascal string)
modeMode
See also
neo_file_mode_t

Check errors with

See also
neo_api_error

◆ neo_file_opendir()

void neo_file_opendir ( const char *  path)

Open a directory for enumeration, using a C string for the path.

Parameters
pathPath (C string)

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathPath (Pascal string)

Check errors with

See also
neo_api_error

◆ neo_file_read()

uint16_t neo_file_read ( uint8_t  channel,
void *  dest,
uint16_t  len 
)

Read bytes from an open file.

To read into graphics memory, use

See also
NEO_FILE_DESTINATION_GRAPHICS .
Parameters
channelFile channel ID
destDestination
lenLength, in bytes
Returns
Amount of data actually read

Check errors with

See also
neo_api_error

◆ 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.

Parameters
filenameReturned filename (C string)
stStat information structure

Check errors with

See also
neo_api_error

◆ 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.

Parameters
filenameReturned filename (Pascal string)
stStat information structure

Check errors with

See also
neo_api_error

◆ neo_file_rename()

void neo_file_rename ( const char *  from,
const char *  to 
)

Rename file, using C strings for the filenames.

Parameters
fromOld filename (C string)
toNew filename (C string)

Check errors with

See also
neo_api_error

◆ 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.

Parameters
fromOld filename (Pascal string)
toNew filename (Pascal string)

Check errors with

See also
neo_api_error

◆ neo_file_seek()

void neo_file_seek ( uint8_t  channel,
uint32_t  pos 
)

Seek a file.

Parameters
channelFile channel ID
posNew file position

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathFilename (C string)
attrNew attributes

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathFilename (Pascal string)
attrNew attributes

Check errors with

See also
neo_api_error

◆ neo_file_set_size()

void neo_file_set_size ( uint8_t  channel,
uint32_t  size 
)

Set the file's size.

Parameters
channelFile channel ID
sizeNew file size, in bytes

Check errors with

See also
neo_api_error

◆ neo_file_size()

uint32_t neo_file_size ( uint8_t  channel)

Get the file's size, in bytes.

Parameters
channelFile channel ID
Returns
File size, in bytes

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathPath (C string)
stStat information structure

Check errors with

See also
neo_api_error

◆ 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.

Parameters
pathPath (Pascal string)
stStat information structure

Check errors with

See also
neo_api_error

◆ 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.

Parameters
filenameFilename (Pascal string)
srcSource
lenLength, in bytes

Check errors with

See also
neo_api_error

◆ 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.

Parameters
filenameFilename (Pascal string)
srcSource
lenLength, in bytes

Check errors with

See also
neo_api_error

◆ neo_file_tell()

uint32_t neo_file_tell ( uint8_t  channel)

Tell a file's position.

Parameters
channelFile channel ID
Returns
Current file position

Check errors with

See also
neo_api_error

◆ neo_file_write()

uint32_t neo_file_write ( uint8_t  channel,
const void *  src,
uint16_t  len 
)

Write bytes to an open file.

Parameters
channelFile channel ID
srcSource
lenLength, in bytes
Returns
Amount of data actually written

Check errors with

See also
neo_api_error