本文整理汇总了C++中SdFat::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFat::remove方法的具体用法?C++ SdFat::remove怎么用?C++ SdFat::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdFat
的用法示例。
在下文中一共展示了SdFat::remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delete_handler
boolean delete_handler(AtMegaWebServer& web_server){
const char *path = web_server.get_path();
#if DEBUG
Serial << "delete_handler: " << path << '\n';
#endif
int len = strlen(path);
char *c = (char *)(path + len - 1);
if(*c == '/') *c = 0;// remove tailing '/'
if(sdfat.remove(path) || sdfat.rmdir(path)){
#if DEBUG
Serial << "delete: " << path << '\n';
#endif
web_server.sendHttpResult(200);
web_server << path;
}else{
web_server.sendHttpResult(404);
#if DEBUG
Serial << F("not exists or failed deleting: ") << path << '\n';
#endif
}
return true;
}
示例2: fileRemove
void TicketflySDBeacon::fileRemove (String fileName, SdFat& SD) {
File myFile;
const char* conversion = fileName.c_str();
myFile = SD.open(conversion);
SD.remove(conversion);
}
示例3: removefile
void SDcard::removefile(){
if (SD.exists("data.txt")) {
SD.remove("data.txt");
}
}
示例4: setup
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
// Wait for USB Serial
while (!Serial) {
SysCall::yield();
}
delay(1000);
cout << F("Type any character to start\n");
// Wait for input line and discard.
cin.readline();
cout << endl;
// Initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
// breadboards. use SPI_FULL_SPEED for better performance.
if (!sd.begin(SD_CHIP_SELECT, SPI_HALF_SPEED)) {
sd.initErrorHalt();
}
if (sd.exists("Folder1")
|| sd.exists("Folder1/file1.txt")
|| sd.exists("Folder1/File2.txt")) {
error("Please remove existing Folder1, file1.txt, and File2.txt");
}
int rootFileCount = 0;
sd.vwd()->rewind();
while (file.openNext(sd.vwd(), O_READ)) {
if (!file.isHidden()) {
rootFileCount++;
}
file.close();
if (rootFileCount > 10) {
error("Too many files in root. Please use an empty SD.");
}
}
if (rootFileCount) {
cout << F("\nPlease use an empty SD for best results.\n\n");
delay(1000);
}
// Create a new folder.
if (!sd.mkdir("Folder1")) {
error("Create Folder1 failed");
}
cout << F("Created Folder1\n");
// Create a file in Folder1 using a path.
if (!file.open("Folder1/file1.txt", O_CREAT | O_WRITE)) {
error("create Folder1/file1.txt failed");
}
file.close();
cout << F("Created Folder1/file1.txt\n");
// Change volume working directory to Folder1.
if (!sd.chdir("Folder1")) {
error("chdir failed for Folder1.\n");
}
cout << F("chdir to Folder1\n");
// Create File2.txt in current directory.
if (!file.open("File2.txt", O_CREAT | O_WRITE)) {
error("create File2.txt failed");
}
file.close();
cout << F("Created File2.txt in current directory\n");
cout << F("\nList of files on the SD.\n");
sd.ls("/", LS_R);
// Remove files from current directory.
if (!sd.remove("file1.txt") || !sd.remove("File2.txt")) {
error("remove failed");
}
cout << F("\nfile1.txt and File2.txt removed.\n");
// Change current directory to root.
if (!sd.chdir()) {
error("chdir to root failed.\n");
}
cout << F("\nList of files on the SD.\n");
sd.ls(LS_R);
// Remove Folder1.
if (!sd.rmdir("Folder1")) {
error("rmdir for Folder1 failed\n");
}
cout << F("\nFolder1 removed.\n");
cout << F("\nList of files on the SD.\n");
sd.ls(LS_R);
cout << F("Done!\n");
}