f_opendir:
1 /*-----------------------------------------------------------------------*/ 2 /* Create a Directroy Object */ 3 /*-----------------------------------------------------------------------*/ 4 5 FRESULT f_opendir ( 6 DIR *dj, /* Pointer to directory object to create */ 7 const TCHAR *path /* Pointer to the directory path */ 8 ) 9 { 10 FRESULT res; 11 DEF_NAMEBUF; 12 13 14 res = chk_mounted(&path, &dj->fs, 0); 15 if (res == FR_OK) { 16 INIT_BUF(*dj); 17 res = follow_path(dj, path); /* Follow the path to the directory */ 18 FREE_BUF(); 19 if (res == FR_OK) { /* Follow completed */ 20 if (dj->dir) { /* It is not the root dir */ 21 if (dj->dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ 22 dj->sclust = LD_CLUST(dj->dir); 23 } else { /* The object is not a directory */ 24 res = FR_NO_PATH; 25 } 26 } 27 if (res == FR_OK) { 28 dj->id = dj->fs->id; 29 res = dir_sdi(dj, 0); /* Rewind dir */ 30 } 31 } 32 if (res == FR_NO_FILE) res = FR_NO_PATH; 33 } 34 35 LEAVE_FF(dj->fs, res); 36 }