MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_devfs_mkdir

Function dfs_devfs_mkdir

components/dfs/dfs_v2/filesystems/devfs/devfs.c:462–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462static void dfs_devfs_mkdir(const char *fullpath, mode_t mode)
463{
464 int len = rt_strlen(fullpath);
465 char *path = (char *)rt_malloc(len + 1);
466
467 if (path)
468 {
469 int index = len - 1;
470
471 rt_strcpy(path, fullpath);
472
473 if (path[index] == '/')
474 {
475 path[index] = '\0';
476 index --;
477 }
478
479 while (path[index] != '/' && index >= 0)
480 {
481 index --;
482 }
483
484 path[index] = '\0';
485
486 if (index > 0 && access(path, 0) != 0)
487 {
488 int i = 0;
489
490 if (path[i] == '/')
491 {
492 i ++;
493 }
494
495 while (index > i)
496 {
497 if (path[i] == '/')
498 {
499 path[i] = '\0';
500 mkdir(path, mode);
501 path[i] = '/';
502 }
503
504 i ++;
505 }
506
507 mkdir(path, mode);
508 }
509 }
510}
511
512void dfs_devfs_device_add(rt_device_t device)
513{

Callers 1

dfs_devfs_device_addFunction · 0.85

Calls 5

rt_strlenFunction · 0.85
rt_mallocFunction · 0.85
rt_strcpyFunction · 0.85
accessFunction · 0.50
mkdirFunction · 0.50

Tested by

no test coverage detected