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)

Definition at line 32 of file filesystem.h.

32  {
33  F_RDO = 0x01,
34  F_HID = 0x02,
35  F_SYS = 0x04,
36  F_DIR = 0x10,
37  F_ARC = 0x20
File has the archive flag set (probably unused)
Definition: filesystem.h:37
File is a system file.
Definition: filesystem.h:35
File is hidden.
Definition: filesystem.h:34
It's a directory and not a file.
Definition: filesystem.h:36
FILE_ATTRIBUTES
Definition: filesystem.h:32
File is readonly. You cannot write to it.
Definition: filesystem.h:33

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.

Definition at line 90 of file filesystem.h.

90  {
91  F_OK,
92  F_EOF,
93  F_EACCESS,
96 } FILE_STATUS;
The write/read operation tried to write/read past the end of the file. This is not a fatal error...
Definition: filesystem.h:92
You passed invalid parameters to the function.
Definition: filesystem.h:94
A lowlevel disk-error occoured. This is a fatal error.
Definition: filesystem.h:95
Everything ok.
Definition: filesystem.h:91
The file can not be read/written due to access problems. This is a fatal error.
Definition: filesystem.h:93
FILE_STATUS
Definition: filesystem.h:90

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().

Definition at line 28 of file filesystem.c.

29 {
31 }
void ll_filesystem_dir_close(DIRECTORY_STRUCT *dir)

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

Definition at line 23 of file filesystem.c.

24 {
25  return ll_filesystem_dir_open(path);
26 }
DIRECTORY_STRUCT * ll_filesystem_dir_open(const char *path)

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()

Definition at line 38 of file filesystem.c.

39 {
41 }
void ll_filesystem_file_close(FILE_HANDLE *handle)

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.

Definition at line 33 of file filesystem.c.

34 {
35  return ll_filesystem_file_open(filename);
36 }
FILE_HANDLE * ll_filesystem_file_open(const char *filename)

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.

Definition at line 48 of file filesystem.c.

49 {
50  return ll_filesystem_file_read(handle, buf, size);
51 }
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)

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.

Definition at line 43 of file filesystem.c.

44 {
45  return ll_filesystem_file_seek(handle, offset);
46 }
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)

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.

Definition at line 53 of file filesystem.c.

54 {
55  return ll_filesystem_file_write(handle, buf, size);
56 }
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)

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

Definition at line 18 of file filesystem.c.

19 {
20  return ll_filesystem_init();
21 }
bool ll_filesystem_init()

Here is the call graph for this function:

Here is the caller graph for this function: