Library:  adsFS

Installing   PV reference   Samples

Warning

The Name parameter should be a null terminated string. Its value is currently never checked so attention must be paid. Beside, never take for granted that functions that returns a name put a null character at the end of the string, you should use functions like 'strncmp'. I will fix everything later.

In order to keep things working it is recommended to run and recommend the memory management every now and then. It should be done with or without adsFS.

I won't explain the reason for every error code. Any doubt, send an email.


int adsFileError(char *msg);

Every function returns -1 when it fails. If that happens adsFileError returns the last error code and fills the 'msg' buffer with a message referring to it. 'msg' must be 32 bytes long or more.

Error codes:

  • ADSFS_SUCCESS
  • ADSFS_ERROR_PARTITION_INVALID
  • ADSFS_ERROR_PARTITION_EXISTS
  • ADSFS_ERROR_SEARCH
  • ADSFS_ERROR_SAVE
  • ADSFS_ERROR_ENTRY
  • ADSFS_ERROR_READ
  • ADSFS_ERROR_WRITE
  • ADSFS_ERROR_BUFFER
  • ADSFS_ERROR_FILE_EXISTS
  • ADSFS_ERROR_FILE_NOTFOUND
  • ADSFS_ERROR_FULL
  • ADSFS_ERROR_MAP

int adsCreatePartition(char *Partition);

This is a key function for the whole file system. Always call this function before any other file system function. It does more than creating a partition. If the partition does not exist it creates it with the name specified by Partition, if it exists the function performs some initialization anyway. Formatting a partition takes some time to complete. Valid partition names ranges from "a" to "z".


int adsFileList(char *Partition, adsDirEntry *List, int *FileCount);

This lists the files name and size in the specified Partition. List must be an array of 256 elements of 'adsDirEntry' type. FileCount returns the number of files the partition contains


int adsFileSave(char *Partition, char *Name, byte *pData, int Size);

Stores the buffer pData whose size is Size in the partition Partition under the name Name. Name must be 8 characters long or less, plus the zero string terminator.


int adsFileLoad(char *Partition, char *Name, byte *pData, int Size);

Loads the file whose name is Name, size is Size into the buffer pData. Name must be 8 characters long or less, plus the zero string terminator.


int adsFileRemove(char *Partition, char *Name);

Deletes the file whose name is Name under partition Partition


int adsFileFind(char *Partition, char *Name, adsDirEntry *Entry);

Finds the files whose name is Name under partition Partition. If the file exists iot fills the structure pointed by Entry with its name and 'Size'. Entry.Name is a zero length string if the file is not found.


int adsFileFreeSpace(char *Partition, long *Space);

Returns into Space the space left in the specified partition, expressed in bytes.



typedef struct
{
	char Name[8];
	word Size;
} adsDirEntry;