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

#include <FAT16.hh>

Inheritance diagram for FAT16::File:
Inheritance graph
Collaboration diagram for FAT16::File:
Collaboration graph

Public Member Functions

 File ()
 
bool open (const char *fileName, uint8_t oflag)
 
bool is_open (void) const
 
bool sync ()
 
bool remove ()
 
bool close ()
 
bool seek (uint32_t pos, uint8_t whence=SEEK_SET)
 
uint32_t tell ()
 
void rewind ()
 
uint32_t size ()
 
bool truncate (uint32_t size)
 
virtual int putchar (char c)
 
virtual int write (const void *buf, size_t size)
 
virtual int getchar ()
 
virtual int read (void *buf, size_t size)
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int available ()
 
virtual int room ()
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int write (const iovec_t *vec)
 
virtual int write_P (const void *buf, size_t size)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual char * gets (char *s, size_t count)
 
virtual int read (iovec_t *vec)
 
virtual int flush ()
 
virtual void empty ()
 

Protected Member Functions

bool addCluster ()
 
bool freeChain (fat_t cluster)
 
bool open (uint16_t entry, uint8_t oflag)
 
bool dirEntry (dir_t *dir)
 

Static Protected Member Functions

static uint8_t isEOC (fat_t cluster)
 

Protected Attributes

uint8_t m_flags
 
int16_t m_dirEntryIndex
 
fat_t m_firstCluster
 
uint32_t m_fileSize
 
fat_t m_curCluster
 
uint32_t m_curPosition
 
bool m_blocking
 
Mode m_eol
 

Detailed Description

Definition at line 558 of file FAT16.hh.

Constructor & Destructor Documentation

FAT16::File::File ( )
inline

Construct file access instance. Must be use open() before any operation are possible.

Definition at line 564 of file FAT16.hh.

Member Function Documentation

bool FAT16::File::addCluster ( )
protected

Definition at line 529 of file FAT16.cpp.

int IOStream::Device::available ( )
virtualinherited

Number of bytes available (possible to read).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, Soft::UART, UART, IOBuffer< SIZE >, and CC3000::Driver.

Definition at line 24 of file IOStream_Device.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

bool FAT16::File::close ( )
inline

Close a file and force cached data and directory information to be written to the storage device.

Returns
bool, true if successful otherwise false for failure. Reasons for failure include the file is not open for write or an I/O error occurred.

Definition at line 613 of file FAT16.hh.

bool FAT16::File::dirEntry ( FAT16::dir_t dir)
protected

Definition at line 445 of file FAT16.cpp.

void IOStream::Device::empty ( )
virtualinherited

Empty internal device buffers.

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 175 of file IOStream_Device.cpp.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

int IOStream::Device::flush ( )
virtualinherited

Flush internal device buffers. Wait for device to become idle.

Returns
zero(0) or negative error code.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 169 of file IOStream_Device.cpp.

bool FAT16::File::freeChain ( fat_t  cluster)
protected

Definition at line 626 of file FAT16.cpp.

int FAT16::File::getchar ( )
virtual

Read character from the file.

Returns
character or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 241 of file FAT16.cpp.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

bool FAT16::File::is_open ( void  ) const
inline

Checks the file's open/closed status.

Returns
the value true if a file is open otherwise false;

Definition at line 584 of file FAT16.hh.

static uint8_t FAT16::File::isEOC ( fat_t  cluster)
inlinestaticprotected

Definition at line 703 of file FAT16.hh.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

bool FAT16::File::open ( const char *  fileName,
uint8_t  oflag 
)

Open a file by file name and mode flags. The file must be in the root directory and must have a DOS 8.3 name. Returns true if successful otherwise false for failure. Reasons for failure include the FAT volume has not been initialized, a file is already open, file name, is invalid, the file does not exist, is a directory, or can't be opened in the access mode specified by oflag.

Parameters
[in]fileNamea valid 8.3 DOS name for a file in the root.
[in]oflagmode of file open (create, read, write, etc).
Returns
bool.

Definition at line 143 of file FAT16.cpp.

bool FAT16::File::open ( uint16_t  entry,
uint8_t  oflag 
)
protected

Definition at line 200 of file FAT16.cpp.

int IOStream::Device::peekchar ( )
virtualinherited

Peek at the next character from device.

Returns
character or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 99 of file IOStream_Device.cpp.

int IOStream::Device::peekchar ( char  c)
virtualinherited

Peek for the given character in device buffer. Return number of characters or EOF(-1).

Parameters
[in]ccharacter to peek for.
Returns
available or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 105 of file IOStream_Device.cpp.

int FAT16::File::putchar ( char  c)
virtual

Write character to the file.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 377 of file FAT16.cpp.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

int FAT16::File::read ( void *  buf,
size_t  size 
)
virtual

Read data to given buffer with given size from the file.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 248 of file FAT16.cpp.

bool FAT16::File::remove ( void  )

Remove a file. The directory entry and all data for the file are deleted. 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

Returns
bool, true if successful otherwise false for failure. Reasons for failure include the file is not open for write or an I/O error occurred.

Definition at line 228 of file FAT16.cpp.

void FAT16::File::rewind ( )
inline

Rewind to the start of the file.

Definition at line 637 of file FAT16.hh.

int IOStream::Device::room ( )
virtualinherited

Number of bytes room (write without blocking).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 30 of file IOStream_Device.cpp.

bool FAT16::File::seek ( uint32_t  pos,
uint8_t  whence = SEEK_SET 
)

Sets the file's read/write position relative to mode.

Parameters
[in]posnew position in bytes from given mode.
[in]modeabsolute, relative and from end.
Returns
bool, true if successful otherwise false for failure.

Definition at line 383 of file FAT16.cpp.

uint32_t FAT16::File::size ( )
inline

Return number of bytes in file.

Definition at line 642 of file FAT16.hh.

bool FAT16::File::sync ( void  )

The sync() call causes all modified data and directory fields to be written to the storage device.

Returns
true if successful otherwise false for failure. Reasons for failure include a call to sync() before a file has been opened or an I/O error.

Definition at line 121 of file FAT16.cpp.

uint32_t FAT16::File::tell ( )
inline

Return current position.

Definition at line 632 of file FAT16.hh.

bool FAT16::File::truncate ( uint32_t  size)

Truncate a file to a specified length. The current file position will be maintained if it is less than or equal to length otherwise it will be set to end of file.

Parameters
[in]lengthThe desired length for the file.
Returns
bool, true if successful otherwise false for failure. Reasons for failure include file is read only, file is a directory, length is greater than the current file size or an I/O error occurs.

Definition at line 413 of file FAT16.cpp.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int FAT16::File::write ( const void *  buf,
size_t  size 
)
virtual

Write data from buffer with given size to the file.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 299 of file FAT16.cpp.

int IOStream::Device::write_P ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in CFFS::File, Socket, and CC3000::Driver.

Definition at line 76 of file IOStream_Device.cpp.

Member Data Documentation

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

fat_t FAT16::File::m_curCluster
protected

Definition at line 700 of file FAT16.hh.

uint32_t FAT16::File::m_curPosition
protected

Definition at line 701 of file FAT16.hh.

int16_t FAT16::File::m_dirEntryIndex
protected

Definition at line 697 of file FAT16.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

uint32_t FAT16::File::m_fileSize
protected

Definition at line 699 of file FAT16.hh.

fat_t FAT16::File::m_firstCluster
protected

Definition at line 698 of file FAT16.hh.

uint8_t FAT16::File::m_flags
protected

Definition at line 696 of file FAT16.hh.


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