SWILIB API (SG)    
Loading...
Searching...
No Matches
File

Detailed Description

Functions for working with filesystem.

Usage: #include <swilib.h> or #include <swilib/file.h>

Data Structures

struct  DIR_ENTRY
 Directory entry. More...
 
struct  FSTATS
 Information about a file or directory. More...
 
struct  FILE_PROP
 Extended file properties. More...
 
struct  TWavLen
 .wav duration info. More...
 
struct  FS_OPS
 File system driver methods (see FS_DRIVER and FS_DRIVE). More...
 
struct  FS_DRIVER
 File system driver (see RamFsDrivers). More...
 
struct  FS_DRIVE
 File system drive (see RamFsDrives). More...
 

Typedefs

typedef struct DIR_ENTRY DIR_ENTRY
 
typedef struct FSTATS FSTATS
 
typedef struct FILE_PROP FILE_PROP
 
typedef struct TWavLen TWavLen
 
typedef struct FS_DRIVE FS_DRIVE
 
typedef struct FS_DRIVER FS_DRIVER
 
typedef struct FS_OPS FS_OPS
 

Enumerations

enum  FileAttributes {
  FA_READONLY = 0x0001 ,
  FA_HIDDEN = 0x0002 ,
  FA_SYSTEM = 0x0004 ,
  FA_DIRECTORY = 0x0010 ,
  FA_ARCHIVE = 0x0020
}
 Attributes for a file or directory. More...
 
enum  FileSeekOrigin {
  S_SET = 0 ,
  S_CUR = 1 ,
  S_END = 2
}
 Modes for seek() More...
 
enum  FilePermissionMode {
  P_WRITE = 0x100 ,
  P_READ = 0x080
}
 Request permissions for file operations. More...
 
enum  FilePropTypeID {
  FILE_PROP_TYPE_VIDEO = 0x4000 ,
  FILE_PROP_TYPE_PICTURE = 0x8000 ,
  FILE_PROP_TYPE_AUDIO = 0x2000
}
 
enum  FileAccessMode {
  A_ReadOnly = 0x0000 ,
  A_WriteOnly = 0x0001 ,
  A_ReadWrite = 0x0002 ,
  A_NoShare = 0x0004 ,
  A_Append = 0x0008 ,
  A_Exclusive = 0x0010 ,
  A_MMCStream = 0x0020 ,
  A_Create = 0x0100 ,
  A_Truncate = 0x0200 ,
  A_FailCreateOnExist = 0x0400 ,
  A_FailOnReopen = 0x0800 ,
  A_TXT = 0x4000 ,
  A_BIN = 0x8000
}
 File access mode. More...
 

Functions

int sys_open (const char *path, uint32_t mode, uint32_t permission, uint32_t *err)
 Open the file.
 
int sys_read (int fd, void *buffer, int length, uint32_t *err)
 Read data from a file.
 
int sys_write (int fd, const void *buffer, int length, uint32_t *err)
 Write data to a file.
 
int sys_close (int fd, uint32_t *err)
 Close file descriptor.
 
int sys_fflush (int fd, uint32_t *err)
 Force write data from the OS write buffer.
 
long sys_lseek (int fd, int32_t offset, uint32_t origin, uint32_t *err, uint32_t *err2)
 Move to the desired position within the file.
 
int sys_mkdir (const char *dirname, uint32_t *err)
 Create a new directory.
 
int sys_mkdir_ws (const WSHDR *dirname, uint32_t *err)
 Create a new directory.
 
int sys_rmdir (const char *dirname, uint32_t *err)
 Remove directory.
 
int sys_rmdir_ws (const WSHDR *path, uint32_t *err)
 Remove directory.
 
int sys_rename (const char *old_name, const char *new_name, uint32_t *err)
 Rename file or directory.
 
int sys_rename_ws (const WSHDR *old_name, const WSHDR *new_name, uint32_t *err)
 Rename file or directory.
 
int sys_unlink (const char *path, uint32_t *err)
 Remove file.
 
int sys_unlink_ws (const WSHDR *path, uint32_t *err)
 Remove file.
 
int sys_truncate (int fd, int length, uint32_t *err)
 Truncate the file to the given size.
 
int sys_stat (const char *path, FSTATS *stat, uint32_t *err)
 Get information about the file or directory.
 
int sys_stat_ws (const WSHDR *path, FSTATS *stat, uint32_t *err)
 Get information about the file or directory.
 
int sys_fstat (int fd, FSTATS *stat, uint32_t *err)
 Get information about the file or directory by fd.
 
int sys_format (uint16_t drive, uint32_t *err)
 Format drive by index.
 
int sys_mount (uint16_t drive, uint32_t *err)
 Mount drive by index.
 
int sys_unmount (uint16_t drive, uint32_t *err)
 Unmount drive by index.
 
int setfilesize (int fd, uint32_t length, uint32_t *err)
 Truncate or grow the file to the given size.
 
int setfiletime (int fd, uint16_t date, uint16_t time, uint32_t *err)
 Set file date and time.
 
int fmove (const char *old_name, const char *new_name, uint32_t *err)
 Rename file or directory.
 
int isdir (const char *path, uint32_t *err)
 Check whether a directory exists at the given path.
 
int isdir_ws (const WSHDR *path, uint32_t *err)
 Check whether a directory exists at the given path.
 
int fexists (WSHDR *path)
 Check if a regular file exists.
 
int GetFileAttrib (const char *path, uint8_t *attr, uint32_t *err)
 Get attributes of the file or directory.
 
int GetFileAttrib_ws (const WSHDR *path, uint8_t *attr, uint32_t *err)
 Get attributes of the file or directory.
 
int SetFileAttrib (const char *path, uint8_t attr, uint32_t *err)
 Set attributes for the file or directory.
 
int SetFileAttrib_ws (const WSHDR *path, uint8_t attr, uint32_t *err)
 Set attributes for the file or directory.
 
int GetFileProp (FILE_PROP *props, const WSHDR *file, const WSHDR *path)
 Get extended file properties.
 
int GetWavLen (TWavLen *wav_info)
 Get duration of the .wav file.
 
int FindFirstFile (DIR_ENTRY *dir_entry, const char *mask, uint32_t *err)
 Open search session and get first result.
 
int FindFirstFile_ws (DIR_ENTRY *dir_entry, const WSHDR *mask, uint32_t *err)
 Open search session and get first result.
 
int FindNextFile (DIR_ENTRY *dir_entry, uint32_t *err)
 Continue searching for files and get next result.
 
int GetPathOfFoundFile (DIR_ENTRY *dir_entry, void *file_info)
 Convert a directory-search result to the SG/X75 file-list record.
 
int FindClose (DIR_ENTRY *dir_entry, uint32_t *err)
 Close search session.
 
int GetFreeFlexSpace (int drive, uint32_t *err)
 Get free space on a specified disk.
 
int GetTotalFlexSpace (int drive, uint32_t *err)
 Get total space on a specified disk.
 

Legacy names for old GCC code.

These functions have a bad underscore name, which is bad for the public API.

int GetFileStats (const char *path, FSTATS *stat, uint32_t *err)
 Get information about the file or directory.
 
int _open (const char *path, uint32_t mode, uint32_t permission, uint32_t *err)
 Open the file.
 
int _read (int fd, void *buffer, int length, uint32_t *err)
 Read data from a file.
 
int _write (int fd, const void *buffer, int length, uint32_t *err)
 Write data to a file.
 
int _close (int fd, uint32_t *err)
 Close file descriptor.
 
int _flush (int fd, uint32_t *err)
 Force write data from the OS write buffer.
 
long _lseek (int fd, uint32_t offset, uint32_t origin, uint32_t *err, uint32_t *err2)
 Move to the desired position within the file.
 
int _mkdir (const char *dirname, uint32_t *err)
 Create a new directory.
 
int _rmdir (const char *dirname, uint32_t *err)
 Remove directory.
 
int _unlink (const char *path, uint32_t *err)
 Remove file.
 
int _truncate (int fd, int length, uint32_t *err)
 Truncate the file to the given size.
 

File system drivers

void * FS_MemAlloc (int size)
 Allocate memory from the file system heap.
 
FS_DRIVER * RamFsDrivers (void)
 Get the file system driver table.
 
FS_DRIVE * RamFsDrives (void)
 Get the file system drive table.
 

Legacy names for old IAR code.

These functions are disabled by default, because they have ambiguous names which conflict with stdio.h api.

But you can always enable these functions using the -DSWILIB_LEGACY_COMPAT define.

int fopen (const char *path, uint32_t mode, uint32_t permission, uint32_t *err)
 Open the file.
 
int fread (int fd, void *buffer, int length, uint32_t *err)
 Read data from a file.
 
int fclose (int fd, uint32_t *err)
 Close file descriptor.
 
int fflush (int fd, uint32_t *err)
 Force write data from the OS write buffer.
 
int fwrite (int fd, const void *buffer, int length, uint32_t *err)
 Write data to a file.
 
long lseek (int fd, uint32_t offset, uint32_t origin, uint32_t *err, uint32_t *err2)
 Move to the desired position within the file.
 
int mkdir (const char *dirname, uint32_t *err)
 Create a new directory.
 
int rmdir (const char *dirname, uint32_t *err)
 Remove directory.
 
int unlink (const char *path, uint32_t *err)
 Remove file.
 
int truncate (int fd, int length, uint32_t *err)
 Truncate the file to the given size.
 

Data Structure Documentation

◆ DIR_ENTRY

struct DIR_ENTRY

◆ FSTATS

struct FSTATS

◆ FILE_PROP

struct FILE_PROP

◆ TWavLen

struct TWavLen

◆ FS_OPS

struct FS_OPS

◆ FS_DRIVER

struct FS_DRIVER

◆ FS_DRIVE

struct FS_DRIVE

Typedef Documentation

◆ DIR_ENTRY

typedef struct DIR_ENTRY DIR_ENTRY

Definition at line 18 of file file.h.

◆ FSTATS

typedef struct FSTATS FSTATS

Definition at line 19 of file file.h.

◆ FILE_PROP

typedef struct FILE_PROP FILE_PROP

Definition at line 20 of file file.h.

◆ TWavLen

typedef struct TWavLen TWavLen

Definition at line 21 of file file.h.

◆ FS_DRIVE

typedef struct FS_DRIVE FS_DRIVE

Definition at line 22 of file file.h.

◆ FS_DRIVER

typedef struct FS_DRIVER FS_DRIVER

Definition at line 23 of file file.h.

◆ FS_OPS

typedef struct FS_OPS FS_OPS

Definition at line 24 of file file.h.

Enumeration Type Documentation

◆ FileAttributes

Attributes for a file or directory.

Enumerator
FA_READONLY 

File is read-only

FA_HIDDEN 

File is hidden

FA_SYSTEM 

Unused

FA_DIRECTORY 

This is folder

FA_ARCHIVE 

Unused

Definition at line 29 of file file.h.

◆ FileSeekOrigin

Modes for seek()

Enumerator
S_SET 

cur_offset = offset

S_CUR 

cur_offset = cur_offset + offset

S_END 

cur_offset = file_size + offset

Definition at line 40 of file file.h.

◆ FilePermissionMode

Request permissions for file operations.

Enumerator
P_WRITE 

Permission for writing

P_READ 

Permission for reading

Definition at line 49 of file file.h.

◆ FilePropTypeID

Enumerator
FILE_PROP_TYPE_VIDEO 

Video info.

FILE_PROP_TYPE_PICTURE 

Picture info.

FILE_PROP_TYPE_AUDIO 

Audio info.

Definition at line 100 of file file.h.

◆ FileAccessMode

File access mode.

Enumerator
A_ReadOnly 

Read-only

A_WriteOnly 

Write-only

A_ReadWrite 

Read + Write

A_NoShare 

Unknown

A_Append 

Each write() appends data to the end of the file (atomic)

A_Exclusive 

Unknown

A_MMCStream 

Allow access to MMC (SGold)

A_Create 

Create a file, if it does not exist.

A_Truncate 

Truncate the file to 0 bytes.

A_FailCreateOnExist 

Return an error if the file was not created by this open() call

A_FailOnReopen 

Unknown

A_TXT 

Mode for text files

A_BIN 

Mode for binary files

Definition at line 156 of file file.h.

Function Documentation

◆ sys_open()

int sys_open ( const char * path,
uint32_t mode,
uint32_t permission,
uint32_t * err )

Open the file.

Parameters
pathpath to the file
modebitmask from FileAccessMode
permissionbitmask from FilePermissionMode
errerror code
Returns
file descriptor or error (< 0)

◆ sys_read()

int sys_read ( int fd,
void * buffer,
int length,
uint32_t * err )

Read data from a file.

Parameters
fdfile descriptor
bufferpointer to a buffer for the read data
lengthmaximum size for read
[out]errerror code
Returns
count of read bytes or error (< 0)
Builtin on platforms:
X75, SG

◆ sys_write()

int sys_write ( int fd,
const void * buffer,
int length,
uint32_t * err )

Write data to a file.

Parameters
fdfile descriptor
bufferpointer to a buffer with data to be written
lengthmaximum size for write
[out]errerror code
Returns
count of written bytes or error (< 0)
Builtin on platforms:
X75, SG

◆ sys_close()

int sys_close ( int fd,
uint32_t * err )

Close file descriptor.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error

◆ sys_fflush()

int sys_fflush ( int fd,
uint32_t * err )

Force write data from the OS write buffer.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error

◆ sys_lseek()

long sys_lseek ( int fd,
int32_t offset,
uint32_t origin,
uint32_t * err,
uint32_t * err2 )

Move to the desired position within the file.

Parameters
fdfile descriptor
offsetsigned offset
originsee FileSeekOrigin
[out]errerror code
[out]err2error code
Returns
resulting file position, or -1 on error

◆ sys_mkdir()

int sys_mkdir ( const char * dirname,
uint32_t * err )

Create a new directory.

Parameters
dirnamepath of the new directory
[out]errerror code
Returns
0 or error

◆ sys_mkdir_ws()

int sys_mkdir_ws ( const WSHDR * dirname,
uint32_t * err )

Create a new directory.

Parameters
dirnamepath of the new directory
[out]errerror code
Returns
0 or error

◆ sys_rmdir()

int sys_rmdir ( const char * dirname,
uint32_t * err )

Remove directory.

Parameters
dirnamepath to the directory
[out]errerror code
Returns
0 or error

◆ sys_rmdir_ws()

int sys_rmdir_ws ( const WSHDR * path,
uint32_t * err )

Remove directory.

Parameters
dirnamepath to the directory
[out]errerror code
Returns
0 or error

◆ sys_rename()

int sys_rename ( const char * old_name,
const char * new_name,
uint32_t * err )

Rename file or directory.

Parameters
old_nameold file/dir name (full path)
new_namenew file/dir name (full path)
errerror code
Returns
0 or error

◆ sys_rename_ws()

int sys_rename_ws ( const WSHDR * old_name,
const WSHDR * new_name,
uint32_t * err )

Rename file or directory.

Parameters
old_nameold file/dir name (full path)
new_namenew file/dir name (full path)
errerror code
Returns
0 or error

◆ sys_unlink()

int sys_unlink ( const char * path,
uint32_t * err )

Remove file.

Parameters
pathpath to the file
[out]errerror code
Returns
0 or error

◆ sys_unlink_ws()

int sys_unlink_ws ( const WSHDR * path,
uint32_t * err )

Remove file.

Parameters
pathpath to the file
[out]errerror code
Returns
0 or error

◆ sys_truncate()

int sys_truncate ( int fd,
int length,
uint32_t * err )

Truncate the file to the given size.

Parameters
fdfile descriptor
lengthnew size of the file
[out]errerror code
Returns
0 or error

◆ sys_stat()

int sys_stat ( const char * path,
FSTATS * stat,
uint32_t * err )

Get information about the file or directory.

Parameters
pathpath to the file or directory.
statpointer where the information will be written (FSTATS)
[out]errerror code
Returns
0 or error

◆ sys_stat_ws()

int sys_stat_ws ( const WSHDR * path,
FSTATS * stat,
uint32_t * err )

Get information about the file or directory.

Parameters
pathpath to the file or directory.
statpointer where the information will be written (FSTATS)
[out]errerror code
Returns
0 or error

◆ sys_fstat()

int sys_fstat ( int fd,
FSTATS * stat,
uint32_t * err )

Get information about the file or directory by fd.

Parameters
fdfile descriptor
statpointer where the information will be written (FSTATS)
[out]errerror code
Returns
0 or error

◆ sys_format()

int sys_format ( uint16_t drive,
uint32_t * err )

Format drive by index.

Parameters
drivedrive index (0 - 0:, 1 - 1:, 2 - 2:, 3 - 4:)
[out]errerror code
Returns
0 or error

◆ sys_mount()

int sys_mount ( uint16_t drive,
uint32_t * err )

Mount drive by index.

Parameters
drivedrive number (only drive 4 is supported)
[out]errerror code
Returns
0 or error

◆ sys_unmount()

int sys_unmount ( uint16_t drive,
uint32_t * err )

Unmount drive by index.

Parameters
drivedrive number (only drive 4 is supported)
[out]errerror code
Returns
0 or error

◆ setfilesize()

int setfilesize ( int fd,
uint32_t length,
uint32_t * err )

Truncate or grow the file to the given size.

Parameters
fdfile descriptor
lengthnew size of the file
[out]errerror code
Returns
0 or error

◆ setfiletime()

int setfiletime ( int fd,
uint16_t date,
uint16_t time,
uint32_t * err )

Set file date and time.

Parameters
fdfile descriptor
datedate in DOS (FAT) format
timetime in DOS (FAT) format
[out]errerror code
Returns
0 or error

◆ fmove()

int fmove ( const char * old_name,
const char * new_name,
uint32_t * err )

Rename file or directory.

Parameters
old_nameold file/dir name (full path)
new_namenew file/dir name (full path)
errerror code
Returns
0 or error
Deprecated
Use sys_rename instead.

◆ isdir()

int isdir ( const char * path,
uint32_t * err )

Check whether a directory exists at the given path.

Parameters
paththe path we are checking
[out]errerror code
Returns
1 if the path exists and is a directory, 0 if the directory does not exist (or path is not a directory)

◆ isdir_ws()

int isdir_ws ( const WSHDR * path,
uint32_t * err )

Check whether a directory exists at the given path.

Parameters
paththe path we are checking
[out]errerror code
Returns
1 if the path exists and is a directory, 0 if the directory does not exist (or path is not a directory)

◆ fexists()

int fexists ( WSHDR * path)

Check if a regular file exists.

Directories return 0.

Parameters
pathpath to the file
Returns
1 or 0

◆ GetFileAttrib()

int GetFileAttrib ( const char * path,
uint8_t * attr,
uint32_t * err )

Get attributes of the file or directory.

Parameters
pathpath to the file or directory.
attrpointer where the attributes will be written
[out]errerror code
Returns
1: success, 0: error

◆ GetFileAttrib_ws()

int GetFileAttrib_ws ( const WSHDR * path,
uint8_t * attr,
uint32_t * err )

Get attributes of the file or directory.

Parameters
pathpath to the file or directory.
attrpointer where the attributes will be written
[out]errerror code
Returns
1: success, 0: error

◆ SetFileAttrib()

int SetFileAttrib ( const char * path,
uint8_t attr,
uint32_t * err )

Set attributes for the file or directory.

Parameters
pathpath to the file or directory.
attrbitmask: FileAttributes
[out]errerror code
Returns
0 or error

◆ SetFileAttrib_ws()

int SetFileAttrib_ws ( const WSHDR * path,
uint8_t attr,
uint32_t * err )

Set attributes for the file or directory.

Parameters
pathpath to the file or directory.
attrbitmask: FileAttributes
[out]errerror code
Returns
0 or error

◆ GetFileProp()

int GetFileProp ( FILE_PROP * props,
const WSHDR * file,
const WSHDR * path )

Get extended file properties.

See description of FILE_PROP for additional information.

Parameters
[out]propspointer to the extended properties structure
filename of the file, example: "beans_recipe.jpg"
pathpath to the file, example: "0:\\Pictures\\"
Returns
1: success, 0: error

◆ GetWavLen()

int GetWavLen ( TWavLen * wav_info)

Get duration of the .wav file.

Parameters
[out]wav_infopath to the TWavLen
Returns
1: success, 0: error
Deprecated
Different function signatures across platforms! Always use: GetFileProp

◆ FindFirstFile()

int FindFirstFile ( DIR_ENTRY * dir_entry,
const char * mask,
uint32_t * err )

Open search session and get first result.

DIR_ENTRY is both a search result and an search session.

Parameters
dir_entrypointer to the search session
masksearch mask (pattern with * as wildcard)
[out]errerror code
Returns
1: success, dir_entry contains first result of the search
0: no files found

◆ FindFirstFile_ws()

int FindFirstFile_ws ( DIR_ENTRY * dir_entry,
const WSHDR * mask,
uint32_t * err )

Open search session and get first result.

DIR_ENTRY is both a search result and an search session.

Parameters
dir_entrypointer to the search session
masksearch mask (pattern with * as wildcard)
[out]errerror code
Returns
1: success, dir_entry contains first result of the search
0: no files found

◆ FindNextFile()

int FindNextFile ( DIR_ENTRY * dir_entry,
uint32_t * err )

Continue searching for files and get next result.

Parameters
dir_entrypointer to the search session
[out]errerror code
Returns
1: success, dir_entry contains next result of the search
0: search is done

◆ GetPathOfFoundFile()

int GetPathOfFoundFile ( DIR_ENTRY * dir_entry,
void * file_info )

Convert a directory-search result to the SG/X75 file-list record.

Parameters
dir_entrydirectory-search result
[out]file_infooutput buffer of at least 0x110 bytes
Returns
1 on success, 0 if the entry cannot be converted
Available on platforms:
X75, SG

◆ FindClose()

int FindClose ( DIR_ENTRY * dir_entry,
uint32_t * err )

Close search session.

Parameters
dir_entrypointer to the search session
[out]errerror code
Returns
0 or error

◆ GetFreeFlexSpace()

int GetFreeFlexSpace ( int drive,
uint32_t * err )

Get free space on a specified disk.

Parameters
drivenumber of the drive: 0-4
[out]errerror code
Returns
bytes count

◆ GetTotalFlexSpace()

int GetTotalFlexSpace ( int drive,
uint32_t * err )

Get total space on a specified disk.

Parameters
drivenumber of the drive: 0-4
errunused
Returns
bytes count

◆ GetFileStats()

int GetFileStats ( const char * path,
FSTATS * stat,
uint32_t * err )

Get information about the file or directory.

Parameters
pathpath to the file or directory.
statpointer where the information will be written (FSTATS)
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_stat instead.

◆ _open()

int _open ( const char * path,
uint32_t mode,
uint32_t permission,
uint32_t * err )

Open the file.

Parameters
pathpath to the file
modebitmask from FileAccessMode
permissionbitmask from FilePermissionMode
errerror code
Returns
file descriptor or error (< 0)
Deprecated
For compatibility with old GCC code. Use sys_open instead.

◆ _read()

int _read ( int fd,
void * buffer,
int length,
uint32_t * err )

Read data from a file.

Parameters
fdfile descriptor
bufferpointer to a buffer for the read data
lengthmaximum size for read
[out]errerror code
Returns
count of read bytes or error (< 0)
Builtin on platforms:
X75, SG
Deprecated
For compatibility with old GCC code. Use sys_read instead.

◆ _write()

int _write ( int fd,
const void * buffer,
int length,
uint32_t * err )

Write data to a file.

Parameters
fdfile descriptor
bufferpointer to a buffer with data to be written
lengthmaximum size for write
[out]errerror code
Returns
count of written bytes or error (< 0)
Builtin on platforms:
X75, SG
Deprecated
For compatibility with old GCC code. Use sys_write instead.

◆ _close()

int _close ( int fd,
uint32_t * err )

Close file descriptor.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_close instead.

◆ _flush()

int _flush ( int fd,
uint32_t * err )

Force write data from the OS write buffer.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_fflush instead.

◆ _lseek()

long _lseek ( int fd,
uint32_t offset,
uint32_t origin,
uint32_t * err,
uint32_t * err2 )

Move to the desired position within the file.

Parameters
fdfile descriptor
offsetsigned offset
originsee FileSeekOrigin
[out]errerror code
[out]err2error code
Returns
resulting file position, or -1 on error
Deprecated
For compatibility with old GCC code. Use sys_lseek instead.

◆ _mkdir()

int _mkdir ( const char * dirname,
uint32_t * err )

Create a new directory.

Parameters
dirnamepath of the new directory
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_mkdir instead.

◆ _rmdir()

int _rmdir ( const char * dirname,
uint32_t * err )

Remove directory.

Parameters
dirnamepath to the directory
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_rmdir instead.

◆ _unlink()

int _unlink ( const char * path,
uint32_t * err )

Remove file.

Parameters
pathpath to the file
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_unlink instead.

◆ _truncate()

int _truncate ( int fd,
int length,
uint32_t * err )

Truncate the file to the given size.

Parameters
fdfile descriptor
lengthnew size of the file
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old GCC code. Use sys_truncate instead.

◆ FS_MemAlloc()

void * FS_MemAlloc ( int size)

Allocate memory from the file system heap.

Asynchronous file system calls answer with message 0x1A2 whose payload +4 points to such a block {callback, u16 error, result}; the receiver frees it.

Parameters
sizesize in bytes
Returns
pointer to the memory (the firmware asserts when the heap is exhausted)

◆ RamFsDrivers()

FS_DRIVER * RamFsDrivers ( void )

Get the file system driver table.

Returns
3 entries
Note
Entry 0 is the default driver and uses the FFS methods; entries 1 and 2 are taken in registration order.
FFS uses handles 100..123 on NSG/ELKA and 1000..1023 on SG/X75.
The memory card driver uses handles 0..24 on NSG/ELKA and 0..140 on SG/X75 (only some SG/X75 models have it).

◆ RamFsDrives()

FS_DRIVE * RamFsDrives ( void )

Get the file system drive table.

Returns
5 entries

◆ fopen()

int fopen ( const char * path,
uint32_t mode,
uint32_t permission,
uint32_t * err )

Open the file.

Parameters
pathpath to the file
modebitmask from FileAccessMode
permissionbitmask from FilePermissionMode
errerror code
Returns
file descriptor or error (< 0)
Deprecated
For compatibility with old IAR code. Use sys_open instead.

◆ fread()

int fread ( int fd,
void * buffer,
int length,
uint32_t * err )

Read data from a file.

Parameters
fdfile descriptor
bufferpointer to a buffer for the read data
lengthmaximum size for read
[out]errerror code
Returns
count of read bytes or error (< 0)
Builtin on platforms:
X75, SG
Deprecated
For compatibility with old IAR code. Use sys_read instead.

◆ fclose()

int fclose ( int fd,
uint32_t * err )

Close file descriptor.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_close instead.

◆ fflush()

int fflush ( int fd,
uint32_t * err )

Force write data from the OS write buffer.

Parameters
fdfile descriptor
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_fflush instead.

◆ fwrite()

int fwrite ( int fd,
const void * buffer,
int length,
uint32_t * err )

Write data to a file.

Parameters
fdfile descriptor
bufferpointer to a buffer with data to be written
lengthmaximum size for write
[out]errerror code
Returns
count of written bytes or error (< 0)
Builtin on platforms:
X75, SG
Deprecated
For compatibility with old IAR code. Use sys_write instead.

◆ lseek()

long lseek ( int fd,
uint32_t offset,
uint32_t origin,
uint32_t * err,
uint32_t * err2 )

Move to the desired position within the file.

Parameters
fdfile descriptor
offsetsigned offset
originsee FileSeekOrigin
[out]errerror code
[out]err2error code
Returns
resulting file position, or -1 on error
Deprecated
For compatibility with old IAR code. Use sys_lseek instead.

◆ mkdir()

int mkdir ( const char * dirname,
uint32_t * err )

Create a new directory.

Parameters
dirnamepath of the new directory
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_mkdir instead.

◆ rmdir()

int rmdir ( const char * dirname,
uint32_t * err )

Remove directory.

Parameters
dirnamepath to the directory
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_rmdir instead.

◆ unlink()

int unlink ( const char * path,
uint32_t * err )

Remove file.

Parameters
pathpath to the file
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_unlink instead.

◆ truncate()

int truncate ( int fd,
int length,
uint32_t * err )

Truncate the file to the given size.

Parameters
fdfile descriptor
lengthnew size of the file
[out]errerror code
Returns
0 or error
Deprecated
For compatibility with old IAR code. Use sys_truncate instead.