discoverpixy
Data Structures | Enumerations | Functions
Filesystem

Data Structures

struct  FILE_DATE_STRUCT
 
struct  FILE_TIME_STRUCT
 
struct  FILE_STRUCT
 
struct  DIRECTORY_STRUCT
 
struct  FILE_HANDLE
 

Enumerations

enum  FILE_ATTRIBUTES {
  F_RDO =0x01, F_HID =0x02, F_SYS =0x04, F_DIR =0x10,
  F_ARC =0x20
}
 
enum  FILE_STATUS {
  F_OK, F_EOF, F_EACCESS, F_INVALIDPARAM,
  F_DISKERROR
}
 

Functions

bool filesystem_init ()
 
DIRECTORY_STRUCTfilesystem_dir_open (const char *path)
 
void filesystem_dir_close (DIRECTORY_STRUCT *dir)
 
FILE_HANDLEfilesystem_file_open (const char *filename)
 
void filesystem_file_close (FILE_HANDLE *handle)
 
FILE_STATUS filesystem_file_seek (FILE_HANDLE *handle, uint32_t offset)
 
FILE_STATUS filesystem_file_read (FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
 
FILE_STATUS filesystem_file_write (FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
 

Detailed Description

The Filesystem Module provides access to files and directories of a the native filesystem.

Enumeration Type Documentation

File Attributes used by implementation See http://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#attributes for detailed description

Enumerator
F_RDO 

File is readonly. You cannot write to it.

F_HID 

File is hidden.

F_SYS 

File is a system file.

F_DIR 

It's a directory and not a file.

F_ARC 

File has the archive flag set (probably unused)

Enum to represent the success or error-code of the filesystem_file_* functions

Enumerator
F_OK 

Everything ok.

F_EOF 

The write/read operation tried to write/read past the end of the file. This is not a fatal error.

F_EACCESS 

The file can not be read/written due to access problems. This is a fatal error.

F_INVALIDPARAM 

You passed invalid parameters to the function.

F_DISKERROR 

A lowlevel disk-error occoured. This is a fatal error.

Function Documentation

void filesystem_dir_close ( DIRECTORY_STRUCT dir)

Closes a previously opened directory. Free's all allocated resources.

Parameters
dirA Pointer to a DIRECTORY_STRUCT obtained by filesystem_dir_open().

Here is the call graph for this function:

Here is the caller graph for this function:

DIRECTORY_STRUCT* filesystem_dir_open ( const char *  path)

Opens a directory and returns a structure which contains all files/subdirectories.

See also
filesystem_dir_close()
Parameters
pathThe absolute path to the directory to open/read
Returns
A Pointer to an initialized DIRECTORY_STRUCT on success, NULL on error

Here is the call graph for this function:

Here is the caller graph for this function:

void filesystem_file_close ( FILE_HANDLE handle)

Closes a file.

Parameters
handleThe FILE_HANDLE obtained by filesystem_file_open()

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_HANDLE* filesystem_file_open ( const char *  filename)

Opens a file for read/writing.

Note
Depending on the implementation you may only open one file at a time
Parameters
filenameThe absolute file path
Returns
A Pointer to a FILE_HANDLE on success, NULL on error.

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_STATUS filesystem_file_read ( FILE_HANDLE handle,
uint8_t *  buf,
uint32_t  size 
)

Reads some bytes from an open file.

Parameters
handleThe FILE_HANDLE obtained by filesystem_file_open()
bufThe Buffer to write the bytes to
sizeThe number of bytes to read
Returns
F_OK on success, F_EOF if less than size bytes could be read, an error Code otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_STATUS filesystem_file_seek ( FILE_HANDLE handle,
uint32_t  offset 
)

Set's the read/write position to a new position

Parameters
handleThe FILE_HANDLE obtained by filesystem_file_open()
offsetThe new read/write position in bytes (absolute).
Returns
F_OK on success, an error Code otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_STATUS filesystem_file_write ( FILE_HANDLE handle,
uint8_t *  buf,
uint32_t  size 
)

Writes some bytes to a open file.

Note
Depending on the implementation the file may not be shrinked or expanded.
Parameters
handleThe FILE_HANDLE obtained by filesystem_file_open()
bufThe Buffer to take the bytes from
sizeThe number of bytes to write
Returns
F_OK on success, F_EOF if less than size bytes could be written, an error Code otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

bool filesystem_init ( )

Initializes the filesystem. Call this method before using any filesystem_* functions

Returns
true on success

Here is the call graph for this function:

Here is the caller graph for this function: