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