mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
renamed SD to FileSystem in FileIO library
This commit is contained in:
parent
051772ba50
commit
deaee73f20
@ -159,21 +159,15 @@ const char *File::name() {
|
||||
|
||||
|
||||
|
||||
boolean SDClass::begin() {
|
||||
Process chksd;
|
||||
int res = chksd.runShellCommand(F("cat /sys/bus/scsi/drivers/sd/*/block/sda/size"));
|
||||
if (res == 0) {
|
||||
if (chksd.peek() != '0')
|
||||
boolean FileSystemClass::begin() {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
File SDClass::open(const char *filename, uint8_t mode) {
|
||||
File FileSystemClass::open(const char *filename, uint8_t mode) {
|
||||
return File(filename, mode);
|
||||
}
|
||||
|
||||
boolean SDClass::exists(const char *filepath) {
|
||||
boolean FileSystemClass::exists(const char *filepath) {
|
||||
Process ls;
|
||||
ls.begin("ls");
|
||||
ls.addParameter(filepath);
|
||||
@ -181,7 +175,7 @@ boolean SDClass::exists(const char *filepath) {
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
boolean SDClass::mkdir(const char *filepath) {
|
||||
boolean FileSystemClass::mkdir(const char *filepath) {
|
||||
Process mk;
|
||||
mk.begin("mkdir");
|
||||
mk.addParameter("-p");
|
||||
@ -190,7 +184,7 @@ boolean SDClass::mkdir(const char *filepath) {
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
boolean SDClass::remove(const char *filepath) {
|
||||
boolean FileSystemClass::remove(const char *filepath) {
|
||||
Process rm;
|
||||
rm.begin("rm");
|
||||
rm.addParameter(filepath);
|
||||
@ -198,7 +192,7 @@ boolean SDClass::remove(const char *filepath) {
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
boolean SDClass::rmdir(const char *filepath) {
|
||||
boolean FileSystemClass::rmdir(const char *filepath) {
|
||||
Process rm;
|
||||
rm.begin("rmdir");
|
||||
rm.addParameter(filepath);
|
||||
@ -206,4 +200,4 @@ boolean SDClass::rmdir(const char *filepath) {
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
SDClass SD;
|
||||
FileSystemClass FileSystem;
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
operator bool();
|
||||
const char * name();
|
||||
|
||||
boolean isDirectory(void);
|
||||
boolean iFileSystemirectory(void);
|
||||
File openNextFile(uint8_t mode = FILE_READ);
|
||||
void rewindDirectory(void);
|
||||
|
||||
@ -66,13 +66,11 @@ private:
|
||||
uint8_t handle;
|
||||
};
|
||||
|
||||
class SDClass {
|
||||
class FileSystemClass {
|
||||
public:
|
||||
SDClass() : bridge(Bridge) { }
|
||||
SDClass(BridgeClass &_b) : bridge(_b) { }
|
||||
FileSystemClass() : bridge(Bridge) { }
|
||||
FileSystemClass(BridgeClass &_b) : bridge(_b) { }
|
||||
|
||||
// This needs to be called to set up the connection to the SD card
|
||||
// before other methods are used.
|
||||
boolean begin();
|
||||
|
||||
// Open the specified file/directory with the supplied mode (e.g. read or
|
||||
@ -98,6 +96,6 @@ private:
|
||||
BridgeClass &bridge;
|
||||
};
|
||||
|
||||
extern SDClass SD;
|
||||
extern FileSystemClass FileSystem;
|
||||
|
||||
#endif
|
||||
|
@ -8,8 +8,8 @@
|
||||
* analog sensors on analog ins 0, 1, and 2
|
||||
* SD card attached to SD card slot of the Arduino Yun
|
||||
|
||||
You are allowed to remove the SD card while the Linux and the
|
||||
sketch is running but becareful to don't remove it while
|
||||
You can remove the SD card while the Linux and the
|
||||
sketch are running but becareful to don't remove it while
|
||||
the system is writing on it.
|
||||
|
||||
created 24 Nov 2010
|
||||
@ -29,19 +29,11 @@ void setup() {
|
||||
// Initialize the Bridge and the Console
|
||||
Bridge.begin();
|
||||
Console.begin();
|
||||
FileSystem.begin();
|
||||
|
||||
while(!Console){
|
||||
; // wait for Console port to connect.
|
||||
}
|
||||
|
||||
// see if the card is present and can be initialized:
|
||||
if (!SD.begin()) {
|
||||
Console.println("SD card failed, or not present");
|
||||
// don't do anything more:
|
||||
return;
|
||||
}
|
||||
Console.println("SD card initialized.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -62,8 +54,8 @@ void loop () {
|
||||
|
||||
// open the file. note that only one file can be open at a time,
|
||||
// so you have to close this one before opening another.
|
||||
// The SD card is mounted at the following "/mnt/sda1"
|
||||
File dataFile = SD.open("/mnt/sda1/datalog.txt", FILE_APPEND);
|
||||
// The FileSystem card is mounted at the following "/mnt/FileSystema1"
|
||||
File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND);
|
||||
|
||||
// if the file is available, write to it:
|
||||
if (dataFile) {
|
||||
|
Loading…
Reference in New Issue
Block a user