Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

fs.h File Reference

File system declarations. More...

#include <types.h>
#include <fstream.h>

Go to the source code of this file.

Data Structures

struct  s_finfo
 File info struct. This is directly written as a file header in the file system. More...

struct  s_fpath
 File path specifier. More...


Defines

#define FS_TYPE_DF   0x38
 File type DF. More...

#define FS_TYPE_EF   0x00
 File type EF. More...

#define FS_TYPE_EF_TRANSP   0x00
 File type transparent EF. More...

#define FS_TYPE_EF_FIXED   0x01
 File type fixed record EF. More...

#define FS_HEADER_SIZE   sizeof(S_FINFO)
 Size of the file header, which is currently the same as S_FINFO. More...


Typedefs

typedef s_fpath S_FPATH
 File path specifier. More...

typedef s_finfo S_FINFO
 File info struct. This is directly written as a file header in the file system. More...


Functions

bool fs_init (void)
 Initialize file system variables. More...

bool fs_seek (iu16 fid, S_FSTREAM *fs, S_FINFO *fi, iu8 type)
 Look for a file in a stream. More...

bool fs_seekEnd (S_FSTREAM *fs)
 Look for the end of files in the stream. More...

bool fs_getData (S_FPATH *fp, S_FSTREAM *fs, S_FINFO *fi)
 Get stream and info for a file specified as a path. More...

bool fs_getFPath (iu16 fid, S_FPATH *fp, S_FSTREAM *fs, S_FINFO *fi)
 Get path, stream and info for a file specified as a FID. More...

bool fs_delete (iu16 fid)
 Delete file specified as fid. More...

bool fs_create (S_FINFO *fi)
 The function creates a file. More...


Variables

S_FPATH selected
 Path specified of the currently selected file. More...


Detailed Description

File system declarations.

SOSSE implements a very simple file system. Each file starts with following header:

Directly after that the content area is located. If the file is a DF, this content area is directly used to add header/content sequences.

After the content area of a file, a content size of 0 must be writen as an end of data marker. This means the data capacity of a MF or DF is the total content size of it minus 2.

Currently the file system support only one level of DFs, i.e. the maximum depth is MF:DF:EF.

There are probably a lot optimization possibilities in this file system, but I think this is not bad for my first designed and implemented file system.

Todo:
Here are certainly some optimizations possible to reduce code size.

Id:
fs.h,v 1.14 2003/05/10 17:26:58 m Exp


Define Documentation

#define FS_HEADER_SIZE   sizeof(S_FINFO)
 

Size of the file header, which is currently the same as S_FINFO.

#define FS_TYPE_DF   0x38
 

File type DF.

#define FS_TYPE_EF   0x00
 

File type EF.

#define FS_TYPE_EF_FIXED   0x01
 

File type fixed record EF.

#define FS_TYPE_EF_TRANSP   0x00
 

File type transparent EF.


Typedef Documentation

typedef struct s_finfo S_FINFO
 

File info struct. This is directly written as a file header in the file system.

typedef struct s_fpath S_FPATH
 

File path specifier.

Todo:
There is probably a potential for simplification, when the file type (DF/EF) is not handled so rigid.


Function Documentation

bool fs_create S_FINFO   fi
 

The function creates a file.

The functions creates a file with the data in fi. The current file must be a MF or DF. In case the current file is a DF, the file, which should be created, can't be a DF.

Parameters:
fi  Pointer to S_FINFO, which contains the data of the file to create.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool fs_delete iu16    fid
 

Delete file specified as fid.

The function looks for the fid in the current file, which must be a MF or DF. The file, which should be deleted must be the last one in the current MF or DF.

Parameters:
fid  ID of the file to delete.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool fs_getData S_FPATH   fp,
S_FSTREAM   fs,
S_FINFO   fi
 

Get stream and info for a file specified as a path.

Parameters:
fp  Pointer to S_FPATH, which is used to supply the information about the file wanted.
fs  Pointer to S_FSTREAM, which will be filled with data on success.
fi  Pointer to S_FINFO, which will be filled with data on success.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool fs_getFPath iu16    fid,
S_FPATH   fp,
S_FSTREAM   fs,
S_FINFO   fi
 

Get path, stream and info for a file specified as a FID.

The file is searched for in the order described in the SELECT FILE documentation on the main page.

Parameters:
fid  File ID to look for.
fp  Pointer to S_FPATH, which will be filled with data on success.
fs  Pointer to S_FSTREAM, which will be filled with data on success. This can be NULL when no data is wanted.
fi  Pointer to S_FINFO, which will be filled with data on success. This can be NULL when no data is wanted.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool fs_init void   
 

Initialize file system variables.

This looks e.g. for the start of the file system and it's size. It must be called after each reset.

Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool fs_seek iu16    fid,
S_FSTREAM   fs,
S_FINFO   fi,
iu8    type
 

Look for a file in a stream.

Parameters:
fid  File ID to look for.
fs  Pointer to S_FSTREAM, where the FID is searched for. It returns on success a stream on the file found.
fi  Pointer to S_FINFO, which will be filled with data on success.
type  Type of file wanted.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.
Todo:
There is probably a potential for simplification, when the file type is not handled so rigid.

bool fs_seekEnd S_FSTREAM   fs
 

Look for the end of files in the stream.

Parameters:
fs  Pointer to S_FSTREAM, which supplies a directory stream and which will be used to return the end position on success.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.


Variable Documentation

S_FPATH selected
 

Path specified of the currently selected file.

Todo:
Saving here a S_FINFO and/or S_FSTREAM of the selected file might reduce the code size.


Copyright 2002 by Matthias Bruestle. This is licensed under the GNU General Public License.