MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / mkdir

Method mkdir

Marlin/src/sd/SdBaseFile.cpp:440–474  ·  view source on GitHub ↗

* Make a new directory. * * \param[in] parent An open SdFat instance for the directory that will contain * the new directory. * * \param[in] path A path with a valid 8.3 DOS name for the new directory. * * \param[in] pFlag Create missing parent directories if true. * * \return true for success, false for failure. * Reasons for failure include this file is already open, \a parent is not a

Source from the content-addressed store, hash-verified

438 * directory, \a path is invalid or already exists in \a parent.
439 */
440bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, const bool pFlag/*=true*/) {
441 if (ENABLED(SDCARD_READONLY)) return false;
442
443 SdBaseFile dir1, dir2, *sub = &dir1;
444 SdBaseFile * const start = parent;
445
446 #if ENABLED(LONG_FILENAME_WRITE_SUPPORT)
447 uint8_t dlname[LONG_FILENAME_LENGTH];
448 #endif
449
450 if (!parent || isOpen()) return false;
451
452 if (*path == '/') {
453 while (*path == '/') path++;
454 if (!parent->isRoot()) {
455 if (!dir2.openRoot(parent->vol_)) return false;
456 parent = &dir2;
457 }
458 }
459
460 uint8_t dname[11];
461 for (;;) {
462 if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false;
463 while (*path == '/') path++;
464 if (!*path) break;
465 if (!sub->open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_READ)) {
466 if (!pFlag || !sub->mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)))
467 return false;
468 }
469 if (parent != start) parent->close();
470 parent = sub;
471 sub = parent != &dir1 ? &dir1 : &dir2;
472 }
473 return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname));
474}
475
476bool SdBaseFile::mkdir(SdBaseFile * const parent, const uint8_t dname[11]
477 OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH])

Callers 7

renameMethod · 0.80
_splitEntryDataMethod · 0.80
languageExport.pyFile · 0.80
languageImport.pyFile · 0.80
download_mks_assetsFunction · 0.80
copy_mks_assetsFunction · 0.80

Calls 10

syncFunction · 0.85
isRootMethod · 0.80
openRootMethod · 0.80
clusterStartBlockMethod · 0.80
cacheRawBlockMethod · 0.80
cacheMethod · 0.80
cacheFlushMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
isDirMethod · 0.45

Tested by

no test coverage detected