@@ -295,7 +295,7 @@ class SdFile : public Print {
295295 }
296296 uint8_t timestamp (uint8_t flag, uint16_t year, uint8_t month, uint8_t day,
297297 uint8_t hour, uint8_t minute, uint8_t second);
298- uint8_t sync (void );
298+ uint8_t sync (uint8_t blocking = 1 );
299299 /* * Type of this SdFile. You should use isFile() or isDir() instead of type()
300300 if possible.
301301
@@ -320,6 +320,7 @@ class SdFile : public Print {
320320 void write_P (PGM_P str);
321321 void writeln_P (PGM_P str);
322322 #endif
323+ int availableForWrite (void );
323324 // ------------------------------------------------------------------------------
324325 #if ALLOW_DEPRECATED_FUNCTIONS
325326 // Deprecated functions - suppress cpplint warnings with NOLINT comment
@@ -407,14 +408,16 @@ class SdFile : public Print {
407408 // should be 0XF
408409 static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC);
409410 // available bits
410- static uint8_t const F_UNUSED = 0X30 ;
411+ static uint8_t const F_FILE_NON_BLOCKING_WRITE = 0X10 ;
412+ // a new cluster was added to the file
413+ static uint8_t const F_FILE_CLUSTER_ADDED = 0X20 ;
411414 // use unbuffered SD read
412415 static uint8_t const F_FILE_UNBUFFERED_READ = 0X40 ;
413416 // sync of directory entry required
414417 static uint8_t const F_FILE_DIR_DIRTY = 0X80 ;
415418
416419 // make sure F_OFLAG is ok
417- #if ((F_UNUSED | F_FILE_UNBUFFERED_READ | F_FILE_DIR_DIRTY) & F_OFLAG)
420+ #if ((F_FILE_NON_BLOCKING_WRITE | F_FILE_CLUSTER_ADDED | F_FILE_UNBUFFERED_READ | F_FILE_DIR_DIRTY) & F_OFLAG)
418421#error flags_ bits conflict
419422 #endif // flags_ bits
420423
@@ -587,7 +590,8 @@ class SdVolume {
587590 uint32_t blockNumber (uint32_t cluster, uint32_t position) const {
588591 return clusterStartBlock (cluster) + blockOfCluster (position);
589592 }
590- static uint8_t cacheFlush (void );
593+ static uint8_t cacheFlush (uint8_t blocking = 1 );
594+ static uint8_t cacheMirrorBlockFlush (uint8_t blocking);
591595 static uint8_t cacheRawBlock (uint32_t blockNumber, uint8_t action);
592596 static void cacheSetDirty (void ) {
593597 cacheDirty_ |= CACHE_FOR_WRITE;
@@ -610,8 +614,14 @@ class SdVolume {
610614 uint16_t count, uint8_t * dst) {
611615 return sdCard_->readData (block, offset, count, dst);
612616 }
613- uint8_t writeBlock (uint32_t block, const uint8_t * dst) {
614- return sdCard_->writeBlock (block, dst);
617+ uint8_t writeBlock (uint32_t block, const uint8_t * dst, uint8_t blocking = 1 ) {
618+ return sdCard_->writeBlock (block, dst, blocking);
619+ }
620+ uint8_t isBusy (void ) {
621+ return sdCard_->isBusy ();
622+ }
623+ uint8_t isCacheMirrorBlockDirty (void ) {
624+ return (cacheMirrorBlock_ != 0 );
615625 }
616626};
617627#endif // SdFat_h
0 commit comments