Skip to content

Commit

Permalink
Update SD card file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nischay2312 committed Jun 25, 2024
1 parent bc981bc commit b2bd8d6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/SDCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,21 @@ namespace SDCard
}
}

// create a new base file
// Check if directory exists
if (!SD.exists(LOG_DIR)) {
// Create directory if it does not exist
if (SD.mkdir(LOG_DIR)) {
Serial.println("Directory created");
} else {
Serial.println("Failed to create directory");
SDStatus = SDCARD_ERROR;
return SDCARD_ERROR;
}
}

// Create a new base file
File file = SD.open((String(LOG_DIR) + "/" + String(LOG_FILE_BASE) + String(LOG_FILE_EXT)), FILE_WRITE);
if(!file){
if (!file) {
Serial.println("Failed to create new file");
SDStatus = SDCARD_ERROR;
return SDCARD_ERROR;
Expand Down

0 comments on commit b2bd8d6

Please sign in to comment.