pic32/libraries/SD/utility/SdFile.cpp
//------------------------------------------------------------------------------
/** Remove a directory file.
 *
 * The directory file will be removed only if it is empty and is not the
 * root directory.  rmDir() follows DOS and Windows and ignores the
 * read-only attribute for the directory.
 *
 * \note This function should not be used to delete the 8.3 version of a
 * directory that has a long name. For example if a directory has the
 * long name "New folder" you should not delete the 8.3 name "NEWFOL~1".
 *
 * \return The value one, true, is returned for success and
 * the value zero, false, is returned for failure.
 * Reasons for failure include the file is not a directory, is the root
 * directory, is not empty, or an I/O error occurred.
 */
Remove a directory file.
The directory file will be removed only if it is empty and is not the
root directory.  rmDir() follows DOS and Windows and ignores the
read-only attribute for the directory.

\note This function should not be used to delete the 8.3 version of a
directory that has a long name. For example if a directory has the
long name "New folder" you should not delete the 8.3 name "NEWFOL~1".

\return The value one, true, is returned for success and
the value zero, false, is returned for failure.
Reasons for failure include the file is not a directory, is the root
directory, is not empty, or an I/O error occurred.
Remove a directory file . The directory file will be removed only if it is empty and is not the root directory . rmDir () follows DOS and Windows and ignores the read - only attribute for the directory . \ note This function should not be used to delete the 8 . 3 version of a directory that has a long name . For example if a directory has the long name " New folder " you should not delete the 8 . 3 name " NEWFOL~1 " . \ return The value one true is returned for success and the value zero false is returned for failure . Reasons for failure include the file is not a directory is the root directory is not empty or an I / O error occurred .
uint8_t SdFile::rmDir(void) {
  if (!isSubDir()) return false;
  rewind();
  while (curPosition_ < fileSize_) {
    dir_t* p = readDirCache();
    if (p == NULL) return false;
    if (p->name[0] == DIR_NAME_FREE) break;
    if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue;
    if (DIR_IS_FILE_OR_SUBDIR(p)) return false;
  }
  type_ = FAT_FILE_TYPE_NORMAL;
  flags_ |= O_WRITE;
  return remove();
}
uint8_t SdFile :: rmDir ( void ) { if ( ! isSubDir ( ) ) return false ; rewind ( ) ; while ( curPosition_ < fileSize_ ) { dir_t * p = readDirCache ( ) ; if ( p == NULL ) return false ; if ( p -> name [ 0 ] == DIR_NAME_FREE ) break ; if ( p -> name [ 0 ] == DIR_NAME_DELETED || p -> name [ 0 ] == ' ' ) continue ; if ( DIR_IS_FILE_OR_SUBDIR ( p ) ) return false ; } type_ = FAT_FILE_TYPE_NORMAL ; flags_ |= O_WRITE ; return remove ( ) ; }
Remove a directory file.
Remove a directory file .
// must be open subdirectory // make sure directory is empty // done if past last used entry // skip empty slot or '.' or '..' // error not empty // convert empty directory to normal file for remove