arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.11k stars 7k forks source link

Arduino SD class / File class: feature request: readln() missing (... and more...) #11635

Open dsyleixa opened 3 years ago

dsyleixa commented 3 years ago

a method .readStringUntil(EOL) or perhaps a new .readln()
is missing: to read an entire textline all at once until end of line, discarding any EoL/LF/CR (e.g., text files on an SD may have \n or \r\n at EoL, so readStringUntil('\n') or readStringUntil('\r') may fail or mess it up)

edit, perhaps sth like my workaround

File SD_File;
String buf;
buf = SD_File.readStringUntil('\n');
int blen=buf.length();
if( blen>=1 && buf[blen-1]=='\r' ) buf.remove(blen-1, 1);
dsyleixa commented 2 years ago

PS; similar to

include

File myFile; SD.remove("example.txt");

now additionally rename and copy functions would be appreciated:

int SD.rename("example.txt", "newname.txt"); and int SD.copy("example.txt", "newname.txt");

Return value If the file is successfully renamed or copied, a zero value is returned. On failure, a nonzero value has to be returned. Perhaps, an errno variable is also set to a system-specific error code on failure.

dsyleixa commented 2 years ago

additionally, in some functions seem to be undocumented (https://www.arduino.cc/en/reference/SD), e.g.:

File myfile; myFile.readStringUntil(terminator)