WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

read

Reads one or more bytes from the file into memory.
Returns the actual number of bytes read - which could be less than asked for if the end of file has been reached.
You can optionally change to a different position in the file by specifying a position - otherwise the read will continue on from the current position.
On completion the current position is updated for the next call.
Syntax
File. read(pos,len,dest)
File. read(len,dest)
 
Parameters
TypeNameDescription
'pos'
The position in the file.
'len'
The number of bytes to be transferred.
'dest'
The starting memory address to store the information read from the file.
Returns
size_t
Example
Example: to open an existing file and dump its contents out using rprintf
File file;
char buffer[80];
if(disk_sdCard.open(file,"/TEST.TXT",'r')==0){
    size_t bytes;
    while( bytes=file.read(sizeof(buffer)-1,buffer)) > 0 ){
        // Terminate the string
        buffer[bytes]=0;
        cout << buffer;
    }
    file.close();
}

 

 

Valid XHTML 1.0 Transitional