Description

open() a file has to be opened before any operations (read / write / seek / getVersion etc.) can take place.

Syntax

open( filename );

Parameters

char* filename – pointer a zero-terminated char array holding the file name

Returns

SerialFlashFile: file object of class SerialFlashFile.

Example Code

#include "SerialFlash.h"
void setup()
{
  char c;
  while(!Serial);
  SerialFlash.begin();
  if( SerialFlash.create("myFile.txt", 1024) == false )
    Serial.println("Normal file could NOT be created");

  SerialFlashFile file = SerialFlash.open("myFile.txt");
  while((file.read(&c, 1) > 0) && (c != 255))
    Serial.write(c);

  file.seek(file.position() -1); // adjust the r/w pointer
  file.write("new data\n", 9); 
}
void loop () 
{ }

Notes and Warnings

See also

GitHub – PaulStoffregen/SerialFlash – org. code this library is based on
c_str() – function to create a 0-terminated char array from a String
create() – a file
read() / write () – data from/to a file
erase() – delete content of a file only