COSA
An Object-Oriented Platform for Arduino Programming
FAT16 Class Reference

#include <FAT16.hh>

Collaboration diagram for FAT16:
Collaboration graph

Classes

struct  bpb_t
 
union  cache16_t
 
union  date_t
 
struct  dir_t
 
struct  fbs_t
 
class  File
 
struct  mbr_t
 
struct  part_t
 
union  time_t
 

Public Types

enum  { LS_DATE = 1, LS_SIZE = 2 }
 

Static Public Member Functions

static bool begin (SD *sd, uint8_t partion)
 
static bool begin (SD *sd)
 
static void ls (IOStream &outs, uint8_t flags=0)
 
static bool rm (const char *fileName)
 

Protected Types

typedef uint16_t fat_t
 

Static Protected Member Functions

static uint8_t DIR_IS_LONG_NAME (const dir_t *dir)
 
static uint8_t DIR_IS_FILE (const dir_t *dir)
 
static uint8_t DIR_IS_SUBDIR (const dir_t *dir)
 
static uint8_t DIR_IS_FILE_OR_SUBDIR (const dir_t *dir)
 
static bool make83Name (const char *str, uint8_t *name)
 
static uint8_t blockOfCluster (uint32_t position)
 
static uint16_t cacheDataOffset (uint32_t position)
 
static dir_tcacheDirEntry (uint16_t index, uint8_t action=0)
 
static uint8_t cacheRawBlock (uint32_t blockNumber, uint8_t action=0)
 
static uint8_t cacheFlush (void)
 
static void cacheSetDirty (void)
 
static uint32_t dataBlockLba (fat_t cluster, uint8_t blockOfCluster)
 
static bool fatGet (fat_t cluster, fat_t *value)
 
static bool fatPut (fat_t cluster, fat_t value)
 
static bool read (dir_t *dir, uint16_t *index, uint8_t skip=DIR_ATT_SKIP)
 
static void printDirName (IOStream &outs, const dir_t &dir, uint8_t width)
 

Static Protected Attributes

static uint8_t const BOOTSIG0 = 0X55
 
static uint8_t const BOOTSIG1 = 0XAA
 
static uint16_t const EOC16 = 0XFFFF
 
static uint16_t const EOC16_MIN = 0XFFF8
 
static uint32_t const EOC32 = 0X0FFFFFFF
 
static uint32_t const EOC32_MIN = 0X0FFFFFF8
 
static uint32_t const ENTRY32_MASK = 0X0FFFFFFF
 
static uint8_t const DIR_NAME_0XE5 = 0X05
 
static uint8_t const DIR_NAME_DELETED = 0XE5
 
static uint8_t const DIR_NAME_FREE = 0X00
 
static uint8_t const DIR_ATT_READ_ONLY = 0X01
 
static uint8_t const DIR_ATT_HIDDEN = 0X02
 
static uint8_t const DIR_ATT_SYSTEM = 0X04
 
static uint8_t const DIR_ATT_VOLUME_ID = 0X08
 
static uint8_t const DIR_ATT_DIRECTORY = 0X10
 
static uint8_t const DIR_ATT_ARCHIVE = 0X20
 
static uint8_t const DIR_ATT_LONG_NAME = 0X0F
 
static uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F
 
static uint8_t const DIR_ATT_DEFINED_BITS = 0X3F
 
static uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
 
static uint8_t const DIR_ATT_SKIP = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
 
static const uint16_t DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1
 
static const uint16_t DEFAULT_TIME = (1 << 11)
 
static SDdevice = NULL
 
static bool volumeInitialized = 0
 
static uint8_t fatCount
 
static uint8_t blocksPerCluster
 
static uint16_t rootDirEntryCount
 
static fat_t blocksPerFat
 
static fat_t clusterCount
 
static uint32_t fatStartBlock
 
static uint32_t rootDirStartBlock
 
static uint32_t dataStartBlock
 
static uint8_t const CACHE_FOR_READ = 0
 
static uint8_t const CACHE_FOR_WRITE = 1
 
static cache16_t cacheBuffer
 
static uint32_t cacheBlockNumber = 0XFFFFFFFF
 
static uint8_t cacheDirty = 0
 
static uint32_t cacheMirrorBlock = 0
 
static void(* dateTime )(uint16_t *date, uint16_t *time) = NULL
 
static uint8_t const F_OFLAG = O_RDWR | O_APPEND | O_SYNC
 
static uint8_t const F_FILE_DIR_DIRTY = 0X80
 

Friends

IOStreamoperator<< (IOStream &outs, date_t &date)
 
IOStreamoperator<< (IOStream &outs, time_t &time)
 

Detailed Description

Definition at line 41 of file FAT16.hh.

Member Typedef Documentation

typedef uint16_t FAT16::fat_t
protected

FAT entry

Definition at line 463 of file FAT16.hh.

Member Enumeration Documentation

anonymous enum

The directory list function output selectors.

Enumerator
LS_DATE 
LS_SIZE 

Definition at line 713 of file FAT16.hh.

Member Function Documentation

bool FAT16::begin ( SD sd,
uint8_t  partion 
)
static

Initialize a FAT16 volume.

Parameters
[in]devSD device where the volume is located.
[in]partpartition to be used. Legal values for part are 1-4 to use the corresponding partition on a device formatted with a MBR, Master Boot Record, or zero if the device is formatted as a super floppy with the FAT boot sector in block zero.
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure. reasons for failure include not finding a valid FAT16 file system in the specified partition, a call to begin() after a volume has been successful initialized or an I/O error.

Definition at line 68 of file FAT16.cpp.

bool FAT16::begin ( SD sd)
static

Initialize a FAT16 volume. First try partition 1 then try super floppy format.

Parameters
[in]devSd device where the volume is located.
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure. reasons for failure include not finding a valid FAT16 file system, a call to begin() after a volume has been successful initialized or an I/O error.

Definition at line 115 of file FAT16.cpp.

static uint8_t FAT16::blockOfCluster ( uint32_t  position)
inlinestaticprotected

Definition at line 806 of file FAT16.hh.

static uint16_t FAT16::cacheDataOffset ( uint32_t  position)
inlinestaticprotected

Definition at line 810 of file FAT16.hh.

FAT16::dir_t * FAT16::cacheDirEntry ( uint16_t  index,
uint8_t  action = 0 
)
staticprotected

Definition at line 561 of file FAT16.cpp.

uint8_t FAT16::cacheFlush ( void  )
staticprotected

Definition at line 569 of file FAT16.cpp.

uint8_t FAT16::cacheRawBlock ( uint32_t  blockNumber,
uint8_t  action = 0 
)
staticprotected

Definition at line 587 of file FAT16.cpp.

static void FAT16::cacheSetDirty ( void  )
inlinestaticprotected

Definition at line 817 of file FAT16.hh.

static uint32_t FAT16::dataBlockLba ( fat_t  cluster,
uint8_t  blockOfCluster 
)
inlinestaticprotected

Definition at line 821 of file FAT16.hh.

static uint8_t FAT16::DIR_IS_FILE ( const dir_t dir)
inlinestaticprotected

Directory entry is for a file

Definition at line 441 of file FAT16.hh.

static uint8_t FAT16::DIR_IS_FILE_OR_SUBDIR ( const dir_t dir)
inlinestaticprotected

Directory entry is for a file or subdirectory

Definition at line 457 of file FAT16.hh.

static uint8_t FAT16::DIR_IS_LONG_NAME ( const dir_t dir)
inlinestaticprotected

Directory entry is part of a long name

Definition at line 433 of file FAT16.hh.

static uint8_t FAT16::DIR_IS_SUBDIR ( const dir_t dir)
inlinestaticprotected

Directory entry is for a subdirectory

Definition at line 449 of file FAT16.hh.

bool FAT16::fatGet ( fat_t  cluster,
fat_t value 
)
staticprotected

Definition at line 599 of file FAT16.cpp.

bool FAT16::fatPut ( fat_t  cluster,
fat_t  value 
)
staticprotected

Definition at line 611 of file FAT16.cpp.

void FAT16::ls ( IOStream outs,
uint8_t  flags = 0 
)
static

List directory contents to given iostream with selected information.

Parameters
[in]outsoutput stream.
[in]flagsThe inclusive OR of LS_DATE (file modification date) and LS_SIZE (file size).

Definition at line 506 of file FAT16.cpp.

bool FAT16::make83Name ( const char *  str,
uint8_t *  name 
)
staticprotected

Definition at line 25 of file FAT16.cpp.

void FAT16::printDirName ( IOStream outs,
const dir_t dir,
uint8_t  width 
)
staticprotected

Definition at line 483 of file FAT16.cpp.

bool FAT16::read ( dir_t dir,
uint16_t *  index,
uint8_t  skip = DIR_ATT_SKIP 
)
staticprotected

Definition at line 455 of file FAT16.cpp.

static bool FAT16::rm ( const char *  fileName)
inlinestatic

Remove a file. The directory entry and all data for the file are deleted.

Parameters
[in]fileNamename of the file to be removed.
Note
this function should not be used to delete the 8.3 version of a file that has a long name. For example if a file has the long name "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT".
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the file is read only, fileName is not found or an I/O error occurred.

Definition at line 767 of file FAT16.hh.

Friends And Related Function Documentation

IOStream& operator<< ( IOStream outs,
FAT16::date_t date 
)
friend

Output stream operator for FAT date value

Definition at line 638 of file FAT16.cpp.

IOStream& operator<< ( IOStream outs,
FAT16::time_t time 
)
friend

Output stream operator for FAT time value

Definition at line 651 of file FAT16.cpp.

Member Data Documentation

uint8_t FAT16::blocksPerCluster
staticprotected

Definition at line 781 of file FAT16.hh.

FAT16::fat_t FAT16::blocksPerFat
staticprotected

Definition at line 783 of file FAT16.hh.

uint8_t const FAT16::BOOTSIG0 = 0X55
staticprotected

Value for byte 510 of boot block or MBR

Definition at line 44 of file FAT16.hh.

uint8_t const FAT16::BOOTSIG1 = 0XAA
staticprotected

Value for byte 511 of boot block or MBR

Definition at line 47 of file FAT16.hh.

uint8_t const FAT16::CACHE_FOR_READ = 0
staticprotected

Definition at line 790 of file FAT16.hh.

uint8_t const FAT16::CACHE_FOR_WRITE = 1
staticprotected

Definition at line 791 of file FAT16.hh.

uint32_t FAT16::cacheBlockNumber = 0XFFFFFFFF
staticprotected

Definition at line 793 of file FAT16.hh.

FAT16::cache16_t FAT16::cacheBuffer
staticprotected

Definition at line 792 of file FAT16.hh.

uint8_t FAT16::cacheDirty = 0
staticprotected

Definition at line 794 of file FAT16.hh.

uint32_t FAT16::cacheMirrorBlock = 0
staticprotected

Definition at line 795 of file FAT16.hh.

FAT16::fat_t FAT16::clusterCount
staticprotected

Definition at line 784 of file FAT16.hh.

uint32_t FAT16::dataStartBlock
staticprotected

Definition at line 787 of file FAT16.hh.

void(* FAT16::dateTime)(uint16_t *date, uint16_t *time) = NULL
staticprotected

Definition at line 798 of file FAT16.hh.

const uint16_t FAT16::DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1
staticprotected

Default date for file timestamps is 1 Jan 2000

Definition at line 551 of file FAT16.hh.

const uint16_t FAT16::DEFAULT_TIME = (1 << 11)
staticprotected

Default time for file timestamp is 1 am

Definition at line 554 of file FAT16.hh.

SD * FAT16::device = NULL
staticprotected

Definition at line 776 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_ARCHIVE = 0X20
staticprotected

Old DOS archive bit for backup support

Definition at line 419 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_DEFINED_BITS = 0X3F
staticprotected

defined attribute bits

Definition at line 425 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_DIRECTORY = 0X10
staticprotected

Entry is for a directory

Definition at line 417 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
staticprotected

Mask for file/subdirectory tests

Definition at line 427 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_HIDDEN = 0X02
staticprotected

File should hidden in directory listings

Definition at line 411 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_LONG_NAME = 0X0F
staticprotected

Test value for long name entry

Definition at line 421 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_LONG_NAME_MASK = 0X3F
staticprotected

Test mask for long name entry

Definition at line 423 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_READ_ONLY = 0X01
staticprotected

file is read-only

Definition at line 409 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_SKIP = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
staticprotected

Definition at line 428 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_SYSTEM = 0X04
staticprotected

Entry is for a system file

Definition at line 413 of file FAT16.hh.

uint8_t const FAT16::DIR_ATT_VOLUME_ID = 0X08
staticprotected

Directory entry contains the volume label

Definition at line 415 of file FAT16.hh.

uint8_t const FAT16::DIR_NAME_0XE5 = 0X05
staticprotected

Type name for directoryEntry escape for name[0] = 0XE5

Definition at line 402 of file FAT16.hh.

uint8_t const FAT16::DIR_NAME_DELETED = 0XE5
staticprotected

name[0] value for entry that is free after being "deleted"

Definition at line 404 of file FAT16.hh.

uint8_t const FAT16::DIR_NAME_FREE = 0X00
staticprotected

name[0] value for entry that is free and no allocated entries follow

Definition at line 406 of file FAT16.hh.

uint32_t const FAT16::ENTRY32_MASK = 0X0FFFFFFF
staticprotected

Mask a for FAT32 entry. Entries are 28 bits.

Definition at line 332 of file FAT16.hh.

uint16_t const FAT16::EOC16 = 0XFFFF
staticprotected

FAT16 end of chain value used by Microsoft.

Definition at line 320 of file FAT16.hh.

uint16_t const FAT16::EOC16_MIN = 0XFFF8
staticprotected

Minimum value for FAT16 EOC. Use to test for EOC.

Definition at line 323 of file FAT16.hh.

uint32_t const FAT16::EOC32 = 0X0FFFFFFF
staticprotected

FAT32 end of chain value used by Microsoft.

Definition at line 326 of file FAT16.hh.

uint32_t const FAT16::EOC32_MIN = 0X0FFFFFF8
staticprotected

Minimum value for FAT32 EOC. Use to test for EOC.

Definition at line 329 of file FAT16.hh.

uint8_t const FAT16::F_FILE_DIR_DIRTY = 0X80
staticprotected

Definition at line 802 of file FAT16.hh.

uint8_t const FAT16::F_OFLAG = O_RDWR | O_APPEND | O_SYNC
staticprotected

Definition at line 801 of file FAT16.hh.

uint8_t FAT16::fatCount
staticprotected

Definition at line 780 of file FAT16.hh.

uint32_t FAT16::fatStartBlock
staticprotected

Definition at line 785 of file FAT16.hh.

uint16_t FAT16::rootDirEntryCount
staticprotected

Definition at line 782 of file FAT16.hh.

uint32_t FAT16::rootDirStartBlock
staticprotected

Definition at line 786 of file FAT16.hh.

bool FAT16::volumeInitialized = 0
staticprotected

Definition at line 779 of file FAT16.hh.


The documentation for this class was generated from the following files: