Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes

SdBase Class Reference

Base class for SD streams. More...

#include <SdStream.h>

Inheritance diagram for SdBase:
Inheritance graph
[legend]
Collaboration diagram for SdBase:
Collaboration graph
[legend]

List of all members.

Public Types

typedef unsigned int fmtflags
typedef unsigned char iostate
typedef int32_t off_type
typedef uint8_t openmode
typedef uint32_t pos_type
enum  seekdir { beg, cur, end }
typedef uint32_t streamsize

Public Member Functions

bool bad () const
void clear (iostate state=goodbit)
bool eof () const
bool fail () const
char fill ()
char fill (char c)
fmtflags flags () const
fmtflags flags (fmtflags fl)
uint8_t flagsToBase ()
bool good () const
 operator const void * () const
bool operator! () const
int precision (unsigned int n)
int precision () const
iostate rdstate () const
fmtflags setf (fmtflags fl)
fmtflags setf (fmtflags fl, fmtflags mask)
void setstate (iostate state)
void unsetf (fmtflags fl)
int width ()
int width (unsigned int n)

Static Public Attributes

static const fmtflags adjustfield = left | right | internal
static const openmode app = 0x04
static const openmode ate = 0x08
static const iostate badbit = 0X01
static const fmtflags basefield = dec | hex | oct
static const openmode binary = 0x10
static const fmtflags boolalpha = 0x0100
static const fmtflags dec = 0x0008
static const iostate eofbit = 0x02
static const iostate failbit = 0X04
static const iostate goodbit = 0x00
static const fmtflags hex = 0x0010
static const openmode in = 0x20
static const fmtflags internal = 0x0004
static const fmtflags left = 0x0001
static const fmtflags oct = 0x0020
static const openmode out = 0x40
static const fmtflags right = 0x0002
static const fmtflags showbase = 0x0200
static const fmtflags showpoint = 0x0400
static const fmtflags showpos = 0x0800
static const fmtflags skipws = 0x1000
static const openmode trunc = 0x80
static const fmtflags uppercase = 0x4000

Protected Member Functions

bool close ()
bool contiguousRange (uint32_t *bgnBlock, uint32_t *endBlock)
bool createContiguous (SdFile *dirFile, const char *path, uint32_t size)
uint32_t curCluster () const
uint32_t curPosition () const
bool dirEntry (dir_t *dir)
bool exists (const char *name)
uint32_t fileSize () const
uint32_t firstCluster () const
bool getFilename (char *name)
void getpos (fpos_t *pos)
bool isDir () const
bool isFile () const
bool isOpen () const
bool isRoot () const
bool isSubDir () const
void ls (uint8_t flags=0, uint8_t indent=0)
bool mkdir (SdFile *dir, const char *path, bool pFlag=true)
bool open (SdFile *dirFile, uint16_t index, uint16_t oflag)
bool open (SdFile *dirFile, const char *path, uint16_t oflag)
bool open (const char *path, uint16_t oflag)
bool openRoot (SdVolume *vol)
void print (const String &)
void print (const char[])
void print (char, int=BYTE)
void print (unsigned char, int=BYTE)
void print (int, int=DEC)
void print (unsigned int, int=DEC)
void print (long, int=DEC)
void print (unsigned long, int=DEC)
void print (double, int=2)
void println (long, int=DEC)
void println (void)
void println (double, int=2)
void println (unsigned long, int=DEC)
void println (int, int=DEC)
void println (unsigned char, int=BYTE)
void println (const String &s)
void println (const char[])
void println (char, int=BYTE)
void println (unsigned int, int=DEC)
bool printName ()
int16_t read ()
int16_t read (void *buf, uint16_t nbyte)
int8_t readDir (dir_t *dir)
bool remove ()
void rewind ()
bool rmdir ()
bool rmRfStar ()
bool seekCur (int32_t offset)
bool seekEnd (int32_t offset=0)
bool seekSet (uint32_t pos)
void setpos (fpos_t *pos)
bool sync ()
bool timestamp (uint8_t flag, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
bool truncate (uint32_t size)
uint8_t type () const
SdVolumevolume () const
virtual void write (const uint8_t *buffer, size_t size)
int16_t write (const void *buf, uint16_t nbyte)
void write (uint8_t b)
void write (const char *str)
void write_P (PGM_P str)
void writeln_P (PGM_P str)

Static Protected Member Functions

static void dateTimeCallback (void(*dateTime)(uint16_t *date, uint16_t *time))
static void dateTimeCallbackCancel ()
static void dirName (const dir_t &dir, char *name)
static void printDirName (const dir_t &dir, uint8_t width, bool printSlash=true)
static void printFatDate (uint16_t fatDate)
static void printFatTime (uint16_t fatTime)
static void printTwoDigits (uint8_t v)
static bool remove (SdFile *dirFile, const char *path)

Protected Attributes

bool writeError

Detailed Description

Base class for SD streams.


Member Typedef Documentation

typedef unsigned int ios_base::fmtflags [inherited]

type for format flags

typedef unsigned char ios_base::iostate [inherited]

typedef for iostate bitmask

typedef int32_t ios_base::off_type [inherited]

type for relative seek offset

typedef uint8_t ios_base::openmode [inherited]

typedef for iostream open mode

typedef uint32_t ios_base::pos_type [inherited]

type for absolute seek position

typedef uint32_t ios_base::streamsize [inherited]

unsigned size that can represent maximum file size. (violates spec - should be signed)


Member Enumeration Documentation

enum ios_base::seekdir [inherited]

enumerated type for the direction of relative seeks

Enumerator:
beg 

seek relative to the beginning of the stream

cur 

seek relative to the current stream position

end 

seek relative to the end of the stream


Member Function Documentation

bool ios::bad (  ) const [inline, inherited]
Returns:
true if bad bit is set else false.
void ios::clear ( iostate  state = goodbit ) [inline, inherited]

Clear iostate bits.

Parameters:
[in]stateThe flags you want to set after clearing all flags.

Reimplemented in fstream, and ofstream.

bool SdFile::close (  ) [inherited]

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

Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include no file is open or an I/O error.

Reimplemented in fstream, ifstream, and ofstream.

bool SdFile::contiguousRange ( uint32_t *  bgnBlock,
uint32_t *  endBlock 
) [inherited]

Check for contiguous file and return its raw block range.

Parameters:
[out]bgnBlockthe first block address for the file.
[out]endBlockthe last block address for the file.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include file is not contiguous, file has zero length or an I/O error occurred.
bool SdFile::createContiguous ( SdFile dirFile,
const char *  path,
uint32_t  size 
) [inherited]

Create and open a new contiguous file of a specified size.

Note:
This function only supports short DOS 8.3 names. See open() for more information.
Parameters:
[in]dirFileThe directory where the file will be created.
[in]pathA path with a valid DOS 8.3 file name.
[in]sizeThe desired file size.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include path contains an invalid DOS 8.3 file name, the FAT volume has not been initialized, a file is already open, the file already exists, the root directory is full or an I/O error.
uint32_t SdFile::curCluster (  ) const [inline, inherited]
Returns:
The current cluster number for a file or directory.
uint32_t SdFile::curPosition (  ) const [inline, inherited]
Returns:
The current position for a file or directory.
static void SdFile::dateTimeCallback ( void(*)(uint16_t *date, uint16_t *time)  dateTime ) [inline, static, inherited]

Set the date/time callback function

Parameters:
[in]dateTimeThe user's call back function. The callback function is of the form:
 void dateTime(uint16_t* date, uint16_t* time) {
   uint16_t year;
   uint8_t month, day, hour, minute, second;

   // User gets date and time from GPS or real-time clock here

   // return date using FAT_DATE macro to format fields
   *date = FAT_DATE(year, month, day);

   // return time using FAT_TIME macro to format fields
   *time = FAT_TIME(hour, minute, second);
 }

Sets the function that is called when a file is created or when a file's directory entry is modified by sync(). All timestamps, access, creation, and modify, are set when a file is created. sync() maintains the last access date and last modify date/time.

See the timestamp() function.

static void SdFile::dateTimeCallbackCancel (  ) [inline, static, inherited]

Cancel the date/time callback function.

bool SdFile::dirEntry ( dir_t dir ) [inherited]

Return a file's directory entry

Parameters:
[out]dirLocation for return of the file's directory entry.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
void SdFile::dirName ( const dir_t dir,
char *  name 
) [static, inherited]

Format the name field of dir into the 13 byte array name in standard 8.3 short name format.

Parameters:
[in]dirThe directory structure containing the name.
[out]nameA 13 byte char array for the formatted name.
bool ios::eof (  ) const [inline, inherited]
Returns:
true if end of file has been reached else false.

Warning: An empty file returns false before the first read.

Moral: eof() is only useful in combination with fail(), to find out whether EOF was the cause for failure

bool SdFile::exists ( const char *  name ) [inherited]

Test for the existence of a file in a directory

Parameters:
[in]nameName of the file to be tested for.
Returns:
true if the file exists else false.
bool ios::fail (  ) const [inline, inherited]
Returns:
true if any iostate bit other than eof are set else false.
uint32_t SdFile::fileSize (  ) const [inline, inherited]
Returns:
The total number of bytes in a file or directory.
char ios_base::fill (  ) [inline, inherited]
Returns:
fill character
char ios_base::fill ( char  c ) [inline, inherited]

Set fill character

Parameters:
[in]cnew fill character
Returns:
old fill character
uint32_t SdFile::firstCluster (  ) const [inline, inherited]
Returns:
The first cluster number for a file or directory.
fmtflags ios_base::flags (  ) const [inline, inherited]
Returns:
format flags
fmtflags ios_base::flags ( fmtflags  fl ) [inline, inherited]

set format flags

Parameters:
[in]flnew flag
Returns:
old flags
uint8_t ios_base::flagsToBase (  ) [inline, inherited]
Returns:
current number base
bool SdFile::getFilename ( char *  name ) [inherited]

Get a file's name

Parameters:
[out]nameAn array of 13 characters for the file's name.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
void SdFile::getpos ( fpos_t pos ) [inherited]

get position for streams

Parameters:
[out]posstruct to receive position
bool ios::good (  ) const [inline, inherited]
Returns:
True if no iostate flags are set else false.
bool SdFile::isDir (  ) const [inline, inherited]
Returns:
True if this is a SdFile for a directory else false.
bool SdFile::isFile (  ) const [inline, inherited]
Returns:
True if this is a SdFile for a file else false.
bool SdFile::isOpen (  ) const [inline, inherited]
Returns:
True if this is a SdFile for an open file/directory else false.
bool SdFile::isRoot (  ) const [inline, inherited]
Returns:
True if this is a SdFile for the root directory.
bool SdFile::isSubDir (  ) const [inline, inherited]
Returns:
True if this is a SdFile for a subdirectory else false.
void SdFile::ls ( uint8_t  flags = 0,
uint8_t  indent = 0 
) [inherited]

List directory contents to Serial.

Parameters:
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Parameters:
[in]indentAmount of space before file name. Used for recursive list to indicate subdirectory level.
bool SdFile::mkdir ( SdFile parent,
const char *  path,
bool  pFlag = true 
) [inherited]

Make a new directory.

Parameters:
[in]parentAn open SdFat instance for the directory that will contain the new directory.
[in]pathA path with a valid 8.3 DOS name for the new directory.
[in]pFlagCreate missing parent directorys if true.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include this SdFile is already open, parent is not a directory, path is invalid or already exists in parent.
bool SdFile::open ( SdFile dirFile,
uint16_t  index,
uint16_t  oflag 
) [inherited]

Open a file by index.

Parameters:
[in]dirFileAn open SdFat instance for the directory.
[in]indexThe index of the directory entry for the file to be opened. The value for index is (directory file position)/32.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC.

See open() by path for definition of flags.

Returns:
true for success or false for failure.
bool SdFile::open ( SdFile dirFile,
const char *  path,
uint16_t  oflag 
) [inherited]

Open a file or directory by name.

Parameters:
[in]dirFileAn open SdFat instance for the directory containing the file to be opened.
[in]pathA path with a valid 8.3 DOS name for a file to be opened.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of flags from the following list

O_READ - Open for reading.

O_RDONLY - Same as O_READ.

O_WRITE - Open for writing.

O_WRONLY - Same as O_WRITE.

O_RDWR - Open for reading and writing.

O_APPEND - If set, the file offset shall be set to the end of the file prior to each write.

O_CREAT - If the file exists, this flag has no effect except as noted under O_EXCL below. Otherwise, the file shall be created

O_EXCL - If O_CREAT and O_EXCL are set, open() shall fail if the file exists.

O_SYNC - Call sync() after each write. This flag should not be used with write(uint8_t), write_P(PGM_P), writeln_P(PGM_P), or the Arduino Print class. These functions do character at a time writes so sync() will be called after each byte.

O_TRUNC - If the file exists and is a regular file, and the file is successfully opened and is not read only, its length shall be truncated to 0.

WARNING: A given file must not be opened by more than one SdFile object of file coruption may occur.

Note:
Directory files must be opened read only. Write and truncation is not allowed for directory files.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include this SdFile is already open, dirFile is not a directory, path is invalid, the file does not exist or can't be opened in the access mode specified by oflag.
bool SdFile::open ( const char *  path,
uint16_t  oflag 
) [inherited]

Open a file in the current working directory.

Parameters:
[in]pathA path with a valid 8.3 DOS name for a file to be opened.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of open flags. see SdFile::open(SdFile*, const char*, uint8_t).
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
bool SdFile::openRoot ( SdVolume vol ) [inherited]

Open a volume's root directory.

Parameters:
[in]volThe FAT volume containing the root directory to be opened.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the SdFile is already open, the FAT volume has not been initialized or it a FAT12 volume.
ios::operator const void * (  ) const [inline, inherited]
Returns:
null pointer if fail() is true.
bool ios::operator! (  ) const [inline, inherited]
Returns:
true if fail() else false.
int ios_base::precision ( unsigned int  n ) [inline, inherited]

set precision

Parameters:
[in]nnew precision
Returns:
old precision
int ios_base::precision (  ) const [inline, inherited]
Returns:
precision
void Print::print ( unsigned int  n,
int  base = DEC 
) [inherited]

Write an unsigned number to the associated device in ASCII.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::print ( const String &  s ) [inherited]

Write a string to the associated device.

Parameters:
[in]sthe string to be printed
void Print::print ( const char  str[] ) [inherited]

Write a string to the associated device.

Parameters:
[in]strthe string to be printed
void Print::print ( char  c,
int  base = BYTE 
) [inherited]

Write an signed byte to the associated device in ASCII.

Parameters:
[in]cthe byte to be printed
[in]baseformat to be used
void Print::print ( unsigned char  b,
int  base = BYTE 
) [inherited]

Write an unsigned byte to the associated device in ASCII.

Parameters:
[in]bthe byte to be printed
[in]baseformat to be used
void Print::print ( int  n,
int  base = DEC 
) [inherited]

Write an signed number to the associated device in ASCII.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::print ( long  n,
int  base = DEC 
) [inherited]

Write an signed number to the associated device in ASCII.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::print ( unsigned long  n,
int  base = DEC 
) [inherited]

Write an unsigned number to the associated device in ASCII.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::print ( double  n,
int  digits = 2 
) [inherited]

Write the decimal representation of an float or double to the associated device in ASCII.

Parameters:
[in]nthe number to be printed
[in]digitsthe digits in ftraction to be printed
void SdFile::printDirName ( const dir_t dir,
uint8_t  width,
bool  printSlash = true 
) [static, inherited]

Print the name field of a directory entry in 8.3 format to Serial.

Parameters:
[in]dirThe directory structure containing the name.
[in]widthBlank fill name if length is less than width.
[in]printSlashPrint '/' after directory names if true.
void SdFile::printFatDate ( uint16_t  fatDate ) [static, inherited]

Print a directory date field to Serial.

Format is yyyy-mm-dd.

Parameters:
[in]fatDateThe date field from a directory entry.
void SdFile::printFatTime ( uint16_t  fatTime ) [static, inherited]

Print a directory time field to Serial.

Format is hh:mm:ss.

Parameters:
[in]fatTimeThe time field from a directory entry.
void Print::println ( double  n,
int  digits = 2 
) [inherited]

Write the decimal representation of an float or double to the associated device in ASCII followed by CR LF.

Parameters:
[in]nthe number to be printed
[in]digitsthe digits in ftraction to be printed
void Print::println ( const char  c[] ) [inherited]

Write a string to the associated device followed by CR LF.

Parameters:
[in]cthe string to be printed
void Print::println ( char  c,
int  base = BYTE 
) [inherited]

Write an signed byte to the associated device in ASCII followed by CR LF.

Parameters:
[in]cthe byte to be printed
[in]baseformat to be used
void Print::println ( unsigned char  b,
int  base = BYTE 
) [inherited]

Write an unsigned byte to the associated device in ASCII followed by CR LF.

Parameters:
[in]bthe byte to be printed
[in]baseformat to be used
void Print::println ( unsigned int  n,
int  base = DEC 
) [inherited]

Write an unsigned number to the associated device in ASCII followed by CR LF.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::println ( long  n,
int  base = DEC 
) [inherited]

Write an signed number to the associated device in ASCII followed by CR LF.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::println ( unsigned long  n,
int  base = DEC 
) [inherited]

Write an unsigned number to the associated device in ASCII followed by CR LF.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::println ( int  n,
int  base = DEC 
) [inherited]

Write an signed number to the associated device in ASCII followed by CR LF.

Parameters:
[in]nthe number to be printed
[in]baseformat to be used
void Print::println ( void   ) [inherited]

Print CR LF

void Print::println ( const String &  s ) [inherited]

Write a string to the associated device followed by CR LF.

Parameters:
[in]sthe string to be printed
bool SdFile::printName (  ) [inherited]

Print a file's name to Serial

Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
void SdFile::printTwoDigits ( uint8_t  v ) [static, inherited]

Print a value as two digits to Serial.

Parameters:
[in]vValue to be printed, 0 <= v <= 99
iostate ios::rdstate (  ) const [inline, inherited]
Returns:
The iostate flags for this SdFile.
int16_t SdFile::read (  ) [inherited]

Read the next byte from a file.

Returns:
For success read returns the next byte in the file as an int. If an error occurs or end of file is reached -1 is returned.
int16_t SdFile::read ( void *  buf,
uint16_t  nbyte 
) [inherited]

Read data from a file starting at the current position.

Parameters:
[out]bufPointer to the location that will receive the data.
[in]nbyteMaximum number of bytes to read.
Returns:
For success read() returns the number of bytes read. A value less than nbyte, including zero, will be returned if end of file is reached. If an error occurs, read() returns -1. Possible errors include read() called before a file has been opened, corrupt file system or an I/O error occurred.
int8_t SdFile::readDir ( dir_t dir ) [inherited]

Read the next directory entry from a directory file.

Parameters:
[out]dirThe dir_t struct that will receive the data.
Returns:
For success readDir() returns the number of bytes read. A value of zero will be returned if end of file is reached. If an error occurs, readDir() returns -1. Possible errors include readDir() called before a directory has been opened, this is not a directory file or an I/O error occurred.
bool SdFile::remove ( SdFile dirFile,
const char *  path 
) [static, inherited]

Remove a file.

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

Parameters:
[in]dirFileThe directory that contains the file.
[in]pathPath for 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 a directory, is read only, dirFile is not a directory, path is not found or an I/O error occurred.
bool SdFile::remove (  ) [inherited]

Remove a file.

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

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 read-only, is a directory, or an I/O error occurred.
void SdFile::rewind (  ) [inline, inherited]

Set the file's current position to zero.

bool SdFile::rmdir (  ) [inherited]

Remove a directory file.

The directory file will be removed only if it is empty and is not the root directory. rmdir() follows DOS and Windows and ignores the read-only attribute for the directory.

Note:
This function should not be used to delete the 8.3 version of a directory that has a long name. For example if a directory has the long name "New folder" you should not delete the 8.3 name "NEWFOL~1".
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 not a directory, is the root directory, is not empty, or an I/O error occurred.
bool SdFile::rmRfStar (  ) [inherited]

Recursively delete a directory and all contained files.

This is like the Unix/Linux 'rm -rf *' if called with the root directory hence the name.

Warning - This will remove all contents of the directory including subdirectories. The directory will then be removed if it is not root. The read-only attribute for files will be ignored.

Note:
This function should not be used to delete the 8.3 version of a directory that has a long name. See remove() and rmdir().
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
bool SdFile::seekCur ( int32_t  offset ) [inline, inherited]

Set the files position to current position + pos. See seekSet().

Parameters:
[in]offsetThe new position in bytes from the current position.
Returns:
true for success or false for failure.
bool SdFile::seekEnd ( int32_t  offset = 0 ) [inline, inherited]

Set the files position to end-of-file + offset. See seekSet().

Parameters:
[in]offsetThe new position in bytes from end-of-file.
Returns:
true for success or false for failure.
bool SdFile::seekSet ( uint32_t  pos ) [inherited]

Sets a file's position.

Parameters:
[in]posThe new position in bytes from the beginning of the file.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
fmtflags ios_base::setf ( fmtflags  fl ) [inline, inherited]

set format flags

Parameters:
[in]flnew flags to be or'ed in
Returns:
old flags
fmtflags ios_base::setf ( fmtflags  fl,
fmtflags  mask 
) [inline, inherited]

modify format flags

Parameters:
[in]maskflags to be removed
[in]flflags to be set after mask bits have been cleared
Returns:
old flags
void SdFile::setpos ( fpos_t pos ) [inherited]

set position for streams

Parameters:
[out]posstruct with value for new position
void ios::setstate ( iostate  state ) [inline, inherited]

Set iostate bits.

Parameters:
[in]stateBitts to set.
bool SdFile::sync (  ) [inherited]

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

Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include a call to sync() before a file has been opened or an I/O error.
bool SdFile::timestamp ( uint8_t  flags,
uint16_t  year,
uint8_t  month,
uint8_t  day,
uint8_t  hour,
uint8_t  minute,
uint8_t  second 
) [inherited]

Set a file's timestamps in its directory entry.

Parameters:
[in]flagsValues for flags are constructed by a bitwise-inclusive OR of flags from the following list

T_ACCESS - Set the file's last access date.

T_CREATE - Set the file's creation date and time.

T_WRITE - Set the file's last write/modification date and time.

Parameters:
[in]yearValid range 1980 - 2107 inclusive.
[in]monthValid range 1 - 12 inclusive.
[in]dayValid range 1 - 31 inclusive.
[in]hourValid range 0 - 23 inclusive.
[in]minuteValid range 0 - 59 inclusive.
[in]secondValid range 0 - 59 inclusive
Note:
It is possible to set an invalid date since there is no check for the number of days in a month.
Modify and access timestamps may be overwritten if a date time callback function has been set by dateTimeCallback().
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
bool SdFile::truncate ( uint32_t  length ) [inherited]

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:
The value one, true, is returned for success and the value zero, false, is returned 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.
uint8_t SdFile::type (  ) const [inline, inherited]

Type of this SdFile. You should use isFile() or isDir() instead of type() if possible.

Returns:
The file or directory type.
void ios_base::unsetf ( fmtflags  fl ) [inline, inherited]

clear format flags

Parameters:
[in]flflags to be cleared
Returns:
old flags
SdVolume* SdFile::volume (  ) const [inline, inherited]
Returns:
SdVolume that contains this file.
int ios_base::width (  ) [inline, inherited]
Returns:
width
int ios_base::width ( unsigned int  n ) [inline, inherited]

set width

Parameters:
[in]nnew width
Returns:
old width
int16_t SdFile::write ( const void *  buf,
uint16_t  nbyte 
) [inherited]

Write data to an open file.

Note:
Data is moved to the cache but may not be written to the storage device until sync() is called.
Parameters:
[in]bufPointer to the location of the data to be written.
[in]nbyteNumber of bytes to write.
Returns:
For success write() returns the number of bytes written, always nbyte. If an error occurs, write() returns -1. Possible errors include write() is called before a file has been opened, write is called for a read-only file, device is full, a corrupt file system or an I/O error.
void SdFile::write ( const char *  str ) [virtual, inherited]

Write a string to a file. Used by the Arduino Print class.

Parameters:
[in]strPointer to the string. Use SdFile::writeError to check for errors.

Reimplemented from Print.

void Print::write ( const uint8_t *  buffer,
size_t  size 
) [virtual, inherited]

default implementation: may be overridden

Parameters:
[in]bufferpointer to data
[in]sizecount of bytes to be written
void SdFile::write ( uint8_t  b ) [virtual, inherited]

Write a byte to a file. Required by the Arduino Print class.

Parameters:
[in]bthe byte to be written. Use SdFile::writeError to check for errors.

Implements Print.

void SdFile::write_P ( PGM_P  str ) [inherited]

Write a PROGMEM string to a file.

Parameters:
[in]strPointer to the PROGMEM string. Use SdFile::writeError to check for errors.
void SdFile::writeln_P ( PGM_P  str ) [inherited]

Write a PROGMEM string followed by CR/LF to a file.

Parameters:
[in]strPointer to the PROGMEM string. Use SdFile::writeError to check for errors.

Member Data Documentation

const fmtflags ios_base::adjustfield = left | right | internal [static, inherited]

mask for adjustfield

const openmode ios_base::app = 0x04 [static, inherited]

seek to end before each write

const openmode ios_base::ate = 0x08 [static, inherited]

open and seek to end immediately after opening

const iostate ios_base::badbit = 0X01 [static, inherited]

iostate bad bit for a non-recoverable error.

const fmtflags ios_base::basefield = dec | hex | oct [static, inherited]

mask for basefield

const openmode ios_base::binary = 0x10 [static, inherited]

perform input and output in binary mode (as opposed to text mode)

const fmtflags ios_base::boolalpha = 0x0100 [static, inherited]

use strings true/false for bool

const fmtflags ios_base::dec = 0x0008 [static, inherited]

base 10 flag

const iostate ios_base::eofbit = 0x02 [static, inherited]

iostate bit for end of file reached

const iostate ios_base::failbit = 0X04 [static, inherited]

iostate fail bit for non-fatal error

const iostate ios_base::goodbit = 0x00 [static, inherited]

iostate for no flags

const fmtflags ios_base::hex = 0x0010 [static, inherited]

base 16 flag

const openmode ios_base::in = 0x20 [static, inherited]

open for input

const fmtflags ios_base::internal = 0x0004 [static, inherited]

fill between sign/base prefix and number

const fmtflags ios_base::left = 0x0001 [static, inherited]

left adjust fields

const fmtflags ios_base::oct = 0x0020 [static, inherited]

base 8 flag

const openmode ios_base::out = 0x40 [static, inherited]

open for output

const fmtflags ios_base::right = 0x0002 [static, inherited]

right adjust fields

const fmtflags ios_base::showbase = 0x0200 [static, inherited]

use prefix 0X for hex and 0 for oct

const fmtflags ios_base::showpoint = 0x0400 [static, inherited]

always show '.' for floating numbes

const fmtflags ios_base::showpos = 0x0800 [static, inherited]

show + sign for non-negative numbers

const fmtflags ios_base::skipws = 0x1000 [static, inherited]

skip initial white space

const openmode ios_base::trunc = 0x80 [static, inherited]

truncate an existing stream when opening

const fmtflags ios_base::uppercase = 0x4000 [static, inherited]

use uppercase letters in number representations

bool SdFile::writeError [inherited]

writeError is set to true if an error occurs during a write(). Set writeError to false before calling print() and/or write() and check for true after calls to print() and/or write().


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