本文整理汇总了C++中SdBaseFile::isDir方法的典型用法代码示例。如果您正苦于以下问题:C++ SdBaseFile::isDir方法的具体用法?C++ SdBaseFile::isDir怎么用?C++ SdBaseFile::isDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdBaseFile
的用法示例。
在下文中一共展示了SdBaseFile::isDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chdir
/** Change a volume's working directory
*
* Changes the volume working directory to the \a path subdirectory.
* Optionally set the current working directory to the volume's
* working directory.
*
* Example: If the volume's working directory is "/DIR", chdir("SUB")
* will change the volume's working directory from "/DIR" to "/DIR/SUB".
*
* If path is "/", the volume's working directory will be changed to the
* root directory
*
* \param[in] path The name of the subdirectory.
*
* \param[in] set_cwd Set the current working directory to this volume's
* working directory if true.
*
* \return The value one, true, is returned for success and
* the value zero, false, is returned for failure.
*/
bool SdFat::chdir(const char *path, bool set_cwd) {
SdBaseFile dir;
if (path[0] == '/' && path[1] == '\0') return chdir(set_cwd);
if (!dir.open(&m_vwd, path, O_READ)) goto fail;
if (!dir.isDir()) goto fail;
m_vwd = dir;
if (set_cwd) SdBaseFile::setCwd(&m_vwd);
return true;
fail:
return false;
}
示例2: JSONFileInfo
void SDCard::JSONFileInfo(const char* filename) {
SdBaseFile targetFile;
GCodeFileInfo *info,tmpInfo;
if (strlen(filename) == 0) {
targetFile = file;
info = &fileInfo;
} else {
if (!targetFile.open(fat.vwd(), filename, O_READ) || targetFile.isDir()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tFileOpenFailed);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
info = &tmpInfo;
info->init(targetFile);
}
if (!targetFile.isOpen()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tNotSDPrinting);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
// {"err":0,"size":457574,"height":4.00,"layerHeight":0.25,"filament":[6556.3],"generatedBy":"Slic3r 1.1.7 on 2014-11-09 at 17:11:32"}
Com::printF(Com::tJSONFileInfoStart);
Com::print(info->fileSize);
Com::printF(Com::tJSONFileInfoHeight);
Com::print(info->objectHeight);
Com::printF(Com::tJSONFileInfoLayerHeight);
Com::print(info->layerHeight);
Com::printF(Com::tJSONFileInfoFilament);
Com::print(info->filamentNeeded);
Com::printF(Com::tJSONFileInfoGeneratedBy);
Com::print(info->generatedBy);
Com::print('"');
if (strlen(filename) == 0) {
Com::printF(Com::tJSONFileInfoName);
file.printName();
Com::print('"');
}
Com::print('}');
Com::println();
};
示例3: lsJSON
void SDCard::lsJSON(const char *filename)
{
SdBaseFile dir;
fat.chdir();
if (*filename == 0) {
dir.openRoot(fat.vol());
} else {
if (!dir.open(fat.vwd(), filename, O_READ) || !dir.isDir()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tFileOpenFailed);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
}
Com::printF(Com::tJSONDir);
SDCard::printEscapeChars(filename);
Com::printF(Com::tJSONFiles);
dir.lsJSON();
Com::printFLN(Com::tJSONArrayEnd);
}