C Language Development Kit/Application development/File system

From OptiWiki

Jump to: navigation, search

General

The file system emulates a disk drive in RAM. The file system has a flat directory structure, like in MS-DOS version 1.00. The file names are in MS-DOS 8.3 format, that is from 1 to 8 characters for the name, and 3 characters or less for the extension. The maximum number of files that can exist in the file system is 50. The maximum number of files that can be open at the same time is 17, plus stdin, stdout and stderr.

The file system does not store time and date information.

There is not a hard-coded boundary between memory used for the file system and memory used for the memory pool. The file system and the memory pool share the same memory space. The advantage is that memory can be allocated to files or allocated to the application by malloc() exactly as needed.

When a file is stored in the file system, blocks are dynamically allocated as the file is growing. Each block has a fixed size, the default 'sector' size of the RAM disk.

Because of the dynamic nature of the file system it relies heavily on malloc(). This also means that the file system can be corrupted, when malloc() and free() are used incorrectly. So, the application developer is advised to be careful when using free() and malloc().

OPH1003 SD card

The file system used on the internal SD card is very similar to that used for the RAM disk. Therefore, also the SD card has a flat directory structure and file names on the SD card are also in MS-DOS 8.3 format. To specify the location of a file (e.g. if the file should come from the RAM disk or from the SD card), the following convention is used:

When a file name starts with:

File goes to
A: or A:\ RAM disk
C: or C:\ SD card

Please note that in a C-program, a back slash is written as a double back slash, eg A:\TEST.DAT is written as "A:\\TEST.DAT"

Default drive

When a 'regular' file name is used, e.g. "test.dat", the file is located on the default drive. This is the SD card, or the drive that is set with the function set_default_drive().

Views
Personal tools