pic32/libraries/SD/utility/SdFile.cpp
//------------------------------------------------------------------------------
/**
 * Open a volume's root directory.
 *
 * \param[in] vol The FAT volume containing the root directory to be opened.
 *
 * \return The value one, true, is returned for success and
 * the value zero, false, is returned for failure.
 * Reasons for failure include the FAT volume has not been initialized
 * or it a FAT12 volume.
 */
Open a volume's root directory.
\param[in] vol The FAT volume containing the root directory to be opened.

\return The value one, true, is returned for success and
the value zero, false, is returned for failure.
Reasons for failure include the FAT volume has not been initialized
or it a FAT12 volume.
Open a volume ' s root directory . \ param [ in ] vol The FAT volume containing the root directory to be opened . \ return The value one true is returned for success and the value zero false is returned for failure . Reasons for failure include the FAT volume has not been initialized or it a FAT12 volume .
uint8_t SdFile::openRoot(SdVolume* vol) {
  if (isOpen()) return false;
  if (vol->fatType() == 16) {
    type_ = FAT_FILE_TYPE_ROOT16;
    firstCluster_ = 0;
    fileSize_ = 32 * vol->rootDirEntryCount();
  } else if (vol->fatType() == 32) {
    type_ = FAT_FILE_TYPE_ROOT32;
    firstCluster_ = vol->rootDirStart();
    if (!vol->chainSize(firstCluster_, &fileSize_)) return false;
  } else {
    return false;
  }
  vol_ = vol;
  flags_ = O_READ;
  curCluster_ = 0;
  curPosition_ = 0;
  dirBlock_ = 0;
  dirIndex_ = 0;
  return true;
}
uint8_t SdFile :: openRoot ( SdVolume * vol ) { if ( isOpen ( ) ) return false ; if ( vol -> fatType ( ) == 16 ) { type_ = FAT_FILE_TYPE_ROOT16 ; firstCluster_ = 0 ; fileSize_ = 32 * vol -> rootDirEntryCount ( ) ; } else if ( vol -> fatType ( ) == 32 ) { type_ = FAT_FILE_TYPE_ROOT32 ; firstCluster_ = vol -> rootDirStart ( ) ; if ( ! vol -> chainSize ( firstCluster_ , & fileSize_ ) ) return false ; } else { return false ; } vol_ = vol ; flags_ = O_READ ; curCluster_ = 0 ; curPosition_ = 0 ; dirBlock_ = 0 ; dirIndex_ = 0 ; return true ; }
Open a volume's root directory.
Open a volume ' s root directory .
// error if file is already open // volume is not initialized or FAT12 // read only // set to start of file // root has no directory entry