Browse Source

Add openCwd(), fix library.properties for Particle

Bill Greiman 6 years ago
parent
commit
635d3fd50f

+ 1 - 1
examples/AnalogBinLogger/AnalogBinLogger.ino

@@ -747,7 +747,7 @@ void logData() {
       error("Can't truncate file");
     }
   }
-  if (!binFile.rename(sd.vwd(), binName)) {
+  if (!binFile.rename(binName)) {
     error("Can't rename file");
   }
   Serial.print(F("File renamed: "));

+ 7 - 2
examples/DirectoryFunctions/DirectoryFunctions.ino

@@ -11,6 +11,9 @@ const uint8_t chipSelect = SS;
 // File system object.
 SdFat sd;
 
+// Directory file.
+SdFile root;
+
 // Use for file creation in folders.
 SdFile file;
 
@@ -52,8 +55,10 @@ void setup() {
   }
 
   int rootFileCount = 0;
-  sd.vwd()->rewind(); 
-  while (file.openNext(sd.vwd(), O_RDONLY)) {
+  if (!root.open("/")){
+    error("open root failed");
+  }    
+  while (file.openNext(&root, O_RDONLY)) {
     if (!file.isHidden()) {
       rootFileCount++;
     }

+ 27 - 27
examples/LowLatencyLogger/LowLatencyLogger.ino

@@ -192,7 +192,7 @@ void binaryToCsv() {
   Serial.println();
   Serial.print(F("FreeStack: "));
   Serial.println(FreeStack());
-  
+
   // Create a new csvFile.
   strcpy(csvName, binName);
   strcpy(&csvName[BASE_NAME_SIZE + 3], "csv");
@@ -245,7 +245,7 @@ void createBinFile() {
   // max number of blocks to erase per erase call
   const uint32_t ERASE_SIZE = 262144L;
   uint32_t bgnBlock, endBlock;
-  
+
   // Delete old tmp file.
   if (sd.exists(TMP_FILE_NAME)) {
     Serial.println(F("Deleting tmp file " TMP_FILE_NAME));
@@ -349,19 +349,19 @@ void recordBinFile() {
   const uint8_t QUEUE_DIM = BUFFER_BLOCK_COUNT + 1;
   // Index of last queue location.
   const uint8_t QUEUE_LAST = QUEUE_DIM - 1;
-  
+
   // Allocate extra buffer space.
   block_t block[BUFFER_BLOCK_COUNT - 1];
-  
+
   block_t* curBlock = 0;
-  
+
   block_t* emptyStack[BUFFER_BLOCK_COUNT];
   uint8_t emptyTop;
   uint8_t minTop;
 
   block_t* fullQueue[QUEUE_DIM];
   uint8_t fullHead = 0;
-  uint8_t fullTail = 0;  
+  uint8_t fullTail = 0;
 
   // Use SdFat's internal buffer.
   emptyStack[0] = (block_t*)sd.vol()->cacheClear();
@@ -374,7 +374,7 @@ void recordBinFile() {
   }
   emptyTop = BUFFER_BLOCK_COUNT;
   minTop = BUFFER_BLOCK_COUNT;
-  
+
   // Start a multiple block write.
   if (!sd.card()->writeStart(binFile.firstBlock())) {
     error("writeStart failed");
@@ -383,7 +383,7 @@ void recordBinFile() {
   Serial.println(FreeStack());
   Serial.println(F("Logging - type any character to stop"));
   bool closeFile = false;
-  uint32_t bn = 0;  
+  uint32_t bn = 0;
   uint32_t maxLatency = 0;
   uint32_t overrun = 0;
   uint32_t overrunTotal = 0;
@@ -393,7 +393,7 @@ void recordBinFile() {
     logTime += LOG_INTERVAL_USEC;
     if (Serial.available()) {
       closeFile = true;
-    }  
+    }
     if (closeFile) {
       if (curBlock != 0) {
         // Put buffer in full queue.
@@ -412,7 +412,7 @@ void recordBinFile() {
         overrun = 0;
       }
       if ((int32_t)(logTime - micros()) < 0) {
-        error("Rate too fast");             
+        error("Rate too fast");
       }
       int32_t delta;
       do {
@@ -423,24 +423,24 @@ void recordBinFile() {
         overrunTotal++;
         if (ERROR_LED_PIN >= 0) {
           digitalWrite(ERROR_LED_PIN, HIGH);
-        }        
+        }
 #if ABORT_ON_OVERRUN
         Serial.println(F("Overrun abort"));
         break;
- #endif  // ABORT_ON_OVERRUN       
+ #endif  // ABORT_ON_OVERRUN
       } else {
 #if USE_SHARED_SPI
         sd.card()->spiStop();
-#endif  // USE_SHARED_SPI   
+#endif  // USE_SHARED_SPI
         acquireData(&curBlock->data[curBlock->count++]);
 #if USE_SHARED_SPI
         sd.card()->spiStart();
-#endif  // USE_SHARED_SPI      
+#endif  // USE_SHARED_SPI
         if (curBlock->count == DATA_DIM) {
           fullQueue[fullHead] = curBlock;
           fullHead = fullHead < QUEUE_LAST ? fullHead + 1 : 0;
           curBlock = 0;
-        } 
+        }
       }
     }
     if (fullHead == fullTail) {
@@ -506,7 +506,7 @@ void recoverTmpFile() {
     if (binFile.read(&count, 2) != 2) error("read");
     if (count == 0 || count > DATA_DIM) {
       endBlock = midBlock - 1;
-    } else {          
+    } else {
       bgnBlock = midBlock;
     }
   }
@@ -529,7 +529,7 @@ void renameBinFile() {
       binName[BASE_NAME_SIZE]++;
     }
   }
-  if (!binFile.rename(sd.vwd(), binName)) {
+  if (!binFile.rename(binName)) {
     error("Can't rename file");
     }
   Serial.print(F("File renamed: "));
@@ -563,8 +563,8 @@ void setup(void) {
     pinMode(ERROR_LED_PIN, OUTPUT);
   }
   Serial.begin(9600);
-  
-  // Wait for USB Serial 
+
+  // Wait for USB Serial
   while (!Serial) {
     SysCall::yield();
   }
@@ -578,10 +578,10 @@ void setup(void) {
   // Allow userSetup access to SPI bus.
   pinMode(SD_CS_PIN, OUTPUT);
   digitalWrite(SD_CS_PIN, HIGH);
-  
+
   // Setup sensors.
   userSetup();
-  
+
   // Initialize at the highest speed supported by the board that is
   // not over 50 MHz. Try a lower speed if SPI errors occur.
   if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
@@ -609,11 +609,11 @@ void loop(void) {
   } while (Serial.available() && Serial.read() >= 0);
   Serial.println();
   Serial.println(F("type:"));
-  Serial.println(F("b - open existing bin file"));  
+  Serial.println(F("b - open existing bin file"));
   Serial.println(F("c - convert file to csv"));
   Serial.println(F("d - dump data to Serial"));
   Serial.println(F("e - overrun error details"));
-  Serial.println(F("l - list files"));  
+  Serial.println(F("l - list files"));
   Serial.println(F("r - record data"));
   Serial.println(F("t - test without logging"));
   while(!Serial.available()) {
@@ -623,7 +623,7 @@ void loop(void) {
   Serial.println(F("LowLatencyLogger can not run with watchdog timer"));
   SysCall::halt();
 #endif
-  
+
   char c = tolower(Serial.read());
 
   // Discard extra Serial data.
@@ -643,12 +643,12 @@ void loop(void) {
   } else if (c == 'e') {
     checkOverrun();
   } else if (c == 'l') {
-    Serial.println(F("\nls:"));  
-    sd.ls(&Serial, LS_SIZE);  
+    Serial.println(F("\nls:"));
+    sd.ls(&Serial, LS_SIZE);
   } else if (c == 'r') {
     logData();
   } else if (c == 't') {
-    testSensor();    
+    testSensor();
   } else {
     Serial.println(F("Invalid entry"));
   }

+ 27 - 27
examples/LowLatencyLoggerADXL345/LowLatencyLogger.ino

@@ -192,7 +192,7 @@ void binaryToCsv() {
   Serial.println();
   Serial.print(F("FreeStack: "));
   Serial.println(FreeStack());
-  
+
   // Create a new csvFile.
   strcpy(csvName, binName);
   strcpy(&csvName[BASE_NAME_SIZE + 3], "csv");
@@ -245,7 +245,7 @@ void createBinFile() {
   // max number of blocks to erase per erase call
   const uint32_t ERASE_SIZE = 262144L;
   uint32_t bgnBlock, endBlock;
-  
+
   // Delete old tmp file.
   if (sd.exists(TMP_FILE_NAME)) {
     Serial.println(F("Deleting tmp file " TMP_FILE_NAME));
@@ -349,19 +349,19 @@ void recordBinFile() {
   const uint8_t QUEUE_DIM = BUFFER_BLOCK_COUNT + 1;
   // Index of last queue location.
   const uint8_t QUEUE_LAST = QUEUE_DIM - 1;
-  
+
   // Allocate extra buffer space.
   block_t block[BUFFER_BLOCK_COUNT - 1];
-  
+
   block_t* curBlock = 0;
-  
+
   block_t* emptyStack[BUFFER_BLOCK_COUNT];
   uint8_t emptyTop;
   uint8_t minTop;
 
   block_t* fullQueue[QUEUE_DIM];
   uint8_t fullHead = 0;
-  uint8_t fullTail = 0;  
+  uint8_t fullTail = 0;
 
   // Use SdFat's internal buffer.
   emptyStack[0] = (block_t*)sd.vol()->cacheClear();
@@ -374,7 +374,7 @@ void recordBinFile() {
   }
   emptyTop = BUFFER_BLOCK_COUNT;
   minTop = BUFFER_BLOCK_COUNT;
-  
+
   // Start a multiple block write.
   if (!sd.card()->writeStart(binFile.firstBlock())) {
     error("writeStart failed");
@@ -383,7 +383,7 @@ void recordBinFile() {
   Serial.println(FreeStack());
   Serial.println(F("Logging - type any character to stop"));
   bool closeFile = false;
-  uint32_t bn = 0;  
+  uint32_t bn = 0;
   uint32_t maxLatency = 0;
   uint32_t overrun = 0;
   uint32_t overrunTotal = 0;
@@ -393,7 +393,7 @@ void recordBinFile() {
     logTime += LOG_INTERVAL_USEC;
     if (Serial.available()) {
       closeFile = true;
-    }  
+    }
     if (closeFile) {
       if (curBlock != 0) {
         // Put buffer in full queue.
@@ -412,7 +412,7 @@ void recordBinFile() {
         overrun = 0;
       }
       if ((int32_t)(logTime - micros()) < 0) {
-        error("Rate too fast");             
+        error("Rate too fast");
       }
       int32_t delta;
       do {
@@ -423,24 +423,24 @@ void recordBinFile() {
         overrunTotal++;
         if (ERROR_LED_PIN >= 0) {
           digitalWrite(ERROR_LED_PIN, HIGH);
-        }        
+        }
 #if ABORT_ON_OVERRUN
         Serial.println(F("Overrun abort"));
         break;
- #endif  // ABORT_ON_OVERRUN       
+ #endif  // ABORT_ON_OVERRUN
       } else {
 #if USE_SHARED_SPI
         sd.card()->spiStop();
-#endif  // USE_SHARED_SPI   
+#endif  // USE_SHARED_SPI
         acquireData(&curBlock->data[curBlock->count++]);
 #if USE_SHARED_SPI
         sd.card()->spiStart();
-#endif  // USE_SHARED_SPI      
+#endif  // USE_SHARED_SPI
         if (curBlock->count == DATA_DIM) {
           fullQueue[fullHead] = curBlock;
           fullHead = fullHead < QUEUE_LAST ? fullHead + 1 : 0;
           curBlock = 0;
-        } 
+        }
       }
     }
     if (fullHead == fullTail) {
@@ -506,7 +506,7 @@ void recoverTmpFile() {
     if (binFile.read(&count, 2) != 2) error("read");
     if (count == 0 || count > DATA_DIM) {
       endBlock = midBlock - 1;
-    } else {          
+    } else {
       bgnBlock = midBlock;
     }
   }
@@ -529,7 +529,7 @@ void renameBinFile() {
       binName[BASE_NAME_SIZE]++;
     }
   }
-  if (!binFile.rename(sd.vwd(), binName)) {
+  if (!binFile.rename(binName)) {
     error("Can't rename file");
     }
   Serial.print(F("File renamed: "));
@@ -563,8 +563,8 @@ void setup(void) {
     pinMode(ERROR_LED_PIN, OUTPUT);
   }
   Serial.begin(9600);
-  
-  // Wait for USB Serial 
+
+  // Wait for USB Serial
   while (!Serial) {
     SysCall::yield();
   }
@@ -578,10 +578,10 @@ void setup(void) {
   // Allow userSetup access to SPI bus.
   pinMode(SD_CS_PIN, OUTPUT);
   digitalWrite(SD_CS_PIN, HIGH);
-  
+
   // Setup sensors.
   userSetup();
-  
+
   // Initialize at the highest speed supported by the board that is
   // not over 50 MHz. Try a lower speed if SPI errors occur.
   if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
@@ -609,11 +609,11 @@ void loop(void) {
   } while (Serial.available() && Serial.read() >= 0);
   Serial.println();
   Serial.println(F("type:"));
-  Serial.println(F("b - open existing bin file"));  
+  Serial.println(F("b - open existing bin file"));
   Serial.println(F("c - convert file to csv"));
   Serial.println(F("d - dump data to Serial"));
   Serial.println(F("e - overrun error details"));
-  Serial.println(F("l - list files"));  
+  Serial.println(F("l - list files"));
   Serial.println(F("r - record data"));
   Serial.println(F("t - test without logging"));
   while(!Serial.available()) {
@@ -623,7 +623,7 @@ void loop(void) {
   Serial.println(F("LowLatencyLogger can not run with watchdog timer"));
   SysCall::halt();
 #endif
-  
+
   char c = tolower(Serial.read());
 
   // Discard extra Serial data.
@@ -643,12 +643,12 @@ void loop(void) {
   } else if (c == 'e') {
     checkOverrun();
   } else if (c == 'l') {
-    Serial.println(F("\nls:"));  
-    sd.ls(&Serial, LS_SIZE);  
+    Serial.println(F("\nls:"));
+    sd.ls(&Serial, LS_SIZE);
   } else if (c == 'r') {
     logData();
   } else if (c == 't') {
-    testSensor();    
+    testSensor();
   } else {
     Serial.println(F("Invalid entry"));
   }

+ 27 - 27
examples/LowLatencyLoggerMPU6050/LowLatencyLogger.ino

@@ -192,7 +192,7 @@ void binaryToCsv() {
   Serial.println();
   Serial.print(F("FreeStack: "));
   Serial.println(FreeStack());
-  
+
   // Create a new csvFile.
   strcpy(csvName, binName);
   strcpy(&csvName[BASE_NAME_SIZE + 3], "csv");
@@ -245,7 +245,7 @@ void createBinFile() {
   // max number of blocks to erase per erase call
   const uint32_t ERASE_SIZE = 262144L;
   uint32_t bgnBlock, endBlock;
-  
+
   // Delete old tmp file.
   if (sd.exists(TMP_FILE_NAME)) {
     Serial.println(F("Deleting tmp file " TMP_FILE_NAME));
@@ -349,19 +349,19 @@ void recordBinFile() {
   const uint8_t QUEUE_DIM = BUFFER_BLOCK_COUNT + 1;
   // Index of last queue location.
   const uint8_t QUEUE_LAST = QUEUE_DIM - 1;
-  
+
   // Allocate extra buffer space.
   block_t block[BUFFER_BLOCK_COUNT - 1];
-  
+
   block_t* curBlock = 0;
-  
+
   block_t* emptyStack[BUFFER_BLOCK_COUNT];
   uint8_t emptyTop;
   uint8_t minTop;
 
   block_t* fullQueue[QUEUE_DIM];
   uint8_t fullHead = 0;
-  uint8_t fullTail = 0;  
+  uint8_t fullTail = 0;
 
   // Use SdFat's internal buffer.
   emptyStack[0] = (block_t*)sd.vol()->cacheClear();
@@ -374,7 +374,7 @@ void recordBinFile() {
   }
   emptyTop = BUFFER_BLOCK_COUNT;
   minTop = BUFFER_BLOCK_COUNT;
-  
+
   // Start a multiple block write.
   if (!sd.card()->writeStart(binFile.firstBlock())) {
     error("writeStart failed");
@@ -383,7 +383,7 @@ void recordBinFile() {
   Serial.println(FreeStack());
   Serial.println(F("Logging - type any character to stop"));
   bool closeFile = false;
-  uint32_t bn = 0;  
+  uint32_t bn = 0;
   uint32_t maxLatency = 0;
   uint32_t overrun = 0;
   uint32_t overrunTotal = 0;
@@ -393,7 +393,7 @@ void recordBinFile() {
     logTime += LOG_INTERVAL_USEC;
     if (Serial.available()) {
       closeFile = true;
-    }  
+    }
     if (closeFile) {
       if (curBlock != 0) {
         // Put buffer in full queue.
@@ -412,7 +412,7 @@ void recordBinFile() {
         overrun = 0;
       }
       if ((int32_t)(logTime - micros()) < 0) {
-        error("Rate too fast");             
+        error("Rate too fast");
       }
       int32_t delta;
       do {
@@ -423,24 +423,24 @@ void recordBinFile() {
         overrunTotal++;
         if (ERROR_LED_PIN >= 0) {
           digitalWrite(ERROR_LED_PIN, HIGH);
-        }        
+        }
 #if ABORT_ON_OVERRUN
         Serial.println(F("Overrun abort"));
         break;
- #endif  // ABORT_ON_OVERRUN       
+ #endif  // ABORT_ON_OVERRUN
       } else {
 #if USE_SHARED_SPI
         sd.card()->spiStop();
-#endif  // USE_SHARED_SPI   
+#endif  // USE_SHARED_SPI
         acquireData(&curBlock->data[curBlock->count++]);
 #if USE_SHARED_SPI
         sd.card()->spiStart();
-#endif  // USE_SHARED_SPI      
+#endif  // USE_SHARED_SPI
         if (curBlock->count == DATA_DIM) {
           fullQueue[fullHead] = curBlock;
           fullHead = fullHead < QUEUE_LAST ? fullHead + 1 : 0;
           curBlock = 0;
-        } 
+        }
       }
     }
     if (fullHead == fullTail) {
@@ -506,7 +506,7 @@ void recoverTmpFile() {
     if (binFile.read(&count, 2) != 2) error("read");
     if (count == 0 || count > DATA_DIM) {
       endBlock = midBlock - 1;
-    } else {          
+    } else {
       bgnBlock = midBlock;
     }
   }
@@ -529,7 +529,7 @@ void renameBinFile() {
       binName[BASE_NAME_SIZE]++;
     }
   }
-  if (!binFile.rename(sd.vwd(), binName)) {
+  if (!binFile.rename(binName)) {
     error("Can't rename file");
     }
   Serial.print(F("File renamed: "));
@@ -563,8 +563,8 @@ void setup(void) {
     pinMode(ERROR_LED_PIN, OUTPUT);
   }
   Serial.begin(9600);
-  
-  // Wait for USB Serial 
+
+  // Wait for USB Serial
   while (!Serial) {
     SysCall::yield();
   }
@@ -578,10 +578,10 @@ void setup(void) {
   // Allow userSetup access to SPI bus.
   pinMode(SD_CS_PIN, OUTPUT);
   digitalWrite(SD_CS_PIN, HIGH);
-  
+
   // Setup sensors.
   userSetup();
-  
+
   // Initialize at the highest speed supported by the board that is
   // not over 50 MHz. Try a lower speed if SPI errors occur.
   if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
@@ -609,11 +609,11 @@ void loop(void) {
   } while (Serial.available() && Serial.read() >= 0);
   Serial.println();
   Serial.println(F("type:"));
-  Serial.println(F("b - open existing bin file"));  
+  Serial.println(F("b - open existing bin file"));
   Serial.println(F("c - convert file to csv"));
   Serial.println(F("d - dump data to Serial"));
   Serial.println(F("e - overrun error details"));
-  Serial.println(F("l - list files"));  
+  Serial.println(F("l - list files"));
   Serial.println(F("r - record data"));
   Serial.println(F("t - test without logging"));
   while(!Serial.available()) {
@@ -623,7 +623,7 @@ void loop(void) {
   Serial.println(F("LowLatencyLogger can not run with watchdog timer"));
   SysCall::halt();
 #endif
-  
+
   char c = tolower(Serial.read());
 
   // Discard extra Serial data.
@@ -643,12 +643,12 @@ void loop(void) {
   } else if (c == 'e') {
     checkOverrun();
   } else if (c == 'l') {
-    Serial.println(F("\nls:"));  
-    sd.ls(&Serial, LS_SIZE);  
+    Serial.println(F("\nls:"));
+    sd.ls(&Serial, LS_SIZE);
   } else if (c == 'r') {
     logData();
   } else if (c == 't') {
-    testSensor();    
+    testSensor();
   } else {
     Serial.println(F("Invalid entry"));
   }

+ 4 - 10
examples/QuickStart/QuickStart.ino

@@ -9,7 +9,7 @@
 // to 10 to disable the Ethernet controller.
 const int8_t DISABLE_CHIP_SELECT = -1;
 //
-// Test with reduced SPI speed for breadboards.  SD_SCK_MHZ(4) will select 
+// Test with reduced SPI speed for breadboards.  SD_SCK_MHZ(4) will select
 // the highest speed supported by the board that is not over 4 MHz.
 // Change SPI_SPEED to SD_SCK_MHZ(50) for best performance.
 #define SPI_SPEED SD_SCK_MHZ(4)
@@ -40,8 +40,8 @@ void reformatMsg() {
 
 void setup() {
   Serial.begin(9600);
-  
-  // Wait for USB Serial 
+
+  // Wait for USB Serial
   while (!Serial) {
     SysCall::yield();
   }
@@ -114,18 +114,12 @@ void loop() {
       cout << dec << noshowbase << endl;
       return;
     }
-    cout << F("\nCard successfully initialized.\n");
     if (sd.vol()->fatType() == 0) {
       cout << F("Can't find a valid FAT16/FAT32 partition.\n");
       reformatMsg();
       return;
     }
-    if (!sd.vwd()->isOpen()) {
-      cout << F("Can't open root directory.\n");
-      reformatMsg();
-      return;
-    }
-    cout << F("Can't determine error type\n");
+    cout << F("begin failed, can't determine error type\n");
     return;
   }
   cout << F("\nCard successfully initialized.\n");

+ 5 - 5
examples/rename/rename.ino

@@ -20,8 +20,8 @@ ArduinoOutStream cout(Serial);
 //------------------------------------------------------------------------------
 void setup() {
   Serial.begin(9600);
-  
-  // Wait for USB Serial 
+
+  // Wait for USB Serial
   while (!Serial) {
     SysCall::yield();
   }
@@ -53,8 +53,8 @@ void setup() {
   file.println("A test line for Name1.txt");
 
   // rename the file name2.txt and add a line.
-  // sd.vwd() is the volume working directory, root.
-  if (!file.rename(sd.vwd(), "name2.txt")) {
+  // Use current working directory, root.
+  if (!file.rename("name2.txt")) {
     error("name2.txt");
   }
   file.println("A test line for name2.txt");
@@ -69,7 +69,7 @@ void setup() {
   }
 
   // move file into Dir1, rename it NAME3.txt and add a line
-  if (!file.rename(sd.vwd(), "Dir1/NAME3.txt")) {
+  if (!file.rename("Dir1/NAME3.txt")) {
     error("NAME3.txt");
   }
   file.println("A line for Dir1/NAME3.txt");

+ 3 - 1
library.properties

@@ -1,9 +1,11 @@
 name=SdFat
-version=1.0.15
+version=1.0.16
+license=MIT
 author=Bill Greiman <fat16lib@sbcglobal.net>
 maintainer=Bill Greiman <fat16lib@sbcglobal.net>
 sentence=FAT16/FAT32 file system for SD cards.
 paragraph=FAT16/FAT32 file system for SD cards.
 category=Data Storage
 url=https://github.com/greiman/SdFat
+repository=https://github.com/greiman/SdFat.git
 architectures=*

+ 10 - 0
src/FatLib/FatFile.cpp

@@ -565,6 +565,16 @@ fail:
   return false;
 }
 //------------------------------------------------------------------------------
+bool FatFile::openCwd() {
+  if (!cwd()) {
+    DBG_FAIL_MACRO;
+    return false;
+  }
+  *this = *cwd();
+  rewind();
+  return true;
+}
+//------------------------------------------------------------------------------
 bool FatFile::openNext(FatFile* dirFile, oflag_t oflag) {
   uint8_t chksum = 0;
   ldir_t* ldir;

+ 17 - 0
src/FatLib/FatFile.h

@@ -570,6 +570,11 @@ class FatFile {
   bool open(const char* path, oflag_t oflag = O_RDONLY) {
     return open(m_cwd, path, oflag);
   }
+  /** Open current working directory.
+   *
+   * \return true for success or false for failure.
+   */
+  bool openCwd();
   /** Open the next file or subdirectory in a directory.
    *
    * \param[in] dirFile An open FatFile instance for the directory
@@ -746,6 +751,18 @@ class FatFile {
   void rewind() {
     seekSet(0);
   }
+  /** Rename a file or subdirectory.
+   *
+   * \note the file will be moved to the current working directory.
+   *
+   * \param[in] newPath New path name for the file/directory.
+   *
+   * \return The value true is returned for success and
+   * the value false is returned for failure.
+   */
+  bool rename(const char* newPath) {
+    return rename(cwd(), newPath);
+  }
   /** Rename a file or subdirectory.
    *
    * \param[in] dirFile Directory for the new path.

+ 1 - 1
src/FatLib/FatStructs.h

@@ -813,7 +813,7 @@ static inline uint8_t FAT_MINUTE(uint16_t fatTime) {
   return (fatTime >> 5) & 0X3F;
 }
 /** second part of FAT directory time field
- * Note second/2 is stored in packed time.
+ * \note second/2 is stored in packed time.
  *
  * \param[in] fatTime Time in packed dir format.
  *