Lines Matching refs:dp
918 DIR* dp, /* Directory object pointing the file to be checked */ in chk_lock() argument
928 if (Files[i].fs == dp->obj.fs && /* Check if the object matches with an open object */ in chk_lock()
929 Files[i].clu == dp->obj.sclust && in chk_lock()
930 Files[i].ofs == dp->dptr) break; in chk_lock()
954 DIR* dp, /* Directory object pointing the file to register or increment */ in inc_lock() argument
962 if (Files[i].fs == dp->obj.fs in inc_lock()
963 && Files[i].clu == dp->obj.sclust in inc_lock()
964 && Files[i].ofs == dp->dptr) break; in inc_lock()
970 Files[i].fs = dp->obj.fs; in inc_lock()
971 Files[i].clu = dp->obj.sclust; in inc_lock()
972 Files[i].ofs = dp->dptr; in inc_lock()
1667 DIR* dp, /* Pointer to directory object */ in dir_sdi() argument
1672 FATFS *fs = dp->obj.fs; in dir_sdi()
1678 dp->dptr = ofs; /* Set current offset */ in dir_sdi()
1679 clst = dp->obj.sclust; /* Table start cluster (0:root) */ in dir_sdi()
1682 if (FF_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ in dir_sdi()
1687 dp->sect = fs->dirbase; in dir_sdi()
1692 clst = get_fat(&dp->obj, clst); /* Get next cluster */ in dir_sdi()
1697 dp->sect = clst2sect(fs, clst); in dir_sdi()
1699 dp->clust = clst; /* Current cluster# */ in dir_sdi()
1700 if (dp->sect == 0) return FR_INT_ERR; in dir_sdi()
1701 dp->sect += ofs / SS(fs); /* Sector# of the directory entry */ in dir_sdi()
1702 dp->dir = fs->win + (ofs % SS(fs)); /* Pointer to the entry in the win[] */ in dir_sdi()
1715 DIR* dp, /* Pointer to the directory object */ in dir_next() argument
1720 FATFS *fs = dp->obj.fs; in dir_next()
1723 ofs = dp->dptr + SZDIRE; /* Next entry */ in dir_next()
1724 …if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) dp->sect = 0;… in dir_next()
1725 if (dp->sect == 0) return FR_NO_FILE; /* Report EOT if it has been disabled */ in dir_next()
1728 dp->sect++; /* Next sector */ in dir_next()
1730 if (dp->clust == 0) { /* Static table */ in dir_next()
1732 dp->sect = 0; return FR_NO_FILE; in dir_next()
1737 clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ in dir_next()
1743 dp->sect = 0; return FR_NO_FILE; in dir_next()
1745 clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ in dir_next()
1750 if (FF_FS_EXFAT) dp->obj.stat |= 4; /* exFAT: The directory has been stretched */ in dir_next()
1752 if (!stretch) dp->sect = 0; /* (this line is to suppress compiler warning) */ in dir_next()
1753 dp->sect = 0; return FR_NO_FILE; /* Report EOT */ in dir_next()
1756 dp->clust = clst; /* Initialize data for new cluster */ in dir_next()
1757 dp->sect = clst2sect(fs, clst); in dir_next()
1761 dp->dptr = ofs; /* Current entry */ in dir_next()
1762 dp->dir = fs->win + ofs % SS(fs); /* Pointer to the entry in the win[] */ in dir_next()
1776 DIR* dp, /* Pointer to the directory object */ argument
1782 FATFS *fs = dp->obj.fs;
1785 res = dir_sdi(dp, 0);
1789 res = move_window(fs, dp->sect);
1792 …if ((fs->fs_type == FS_EXFAT) ? (int)((dp->dir[XDIR_Type] & 0x80) == 0) : (int)(dp->dir[DIR_Name] …
1794 if (dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0) { /* Is the entry free? */
1800 res = dir_next(dp, 1); /* Next entry with table stretch enabled */
2100 DIR* dp /* Reading direcotry object pointing top of the entry block to load */ argument
2105 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */
2109 res = move_window(dp->obj.fs, dp->sect);
2111 if (dp->dir[XDIR_Type] != ET_FILEDIR) return FR_INT_ERR; /* Invalid order */
2112 memcpy(dirb + 0 * SZDIRE, dp->dir, SZDIRE);
2117 res = dir_next(dp, 0);
2120 res = move_window(dp->obj.fs, dp->sect);
2122 if (dp->dir[XDIR_Type] != ET_STREAM) return FR_INT_ERR; /* Invalid order */
2123 memcpy(dirb + 1 * SZDIRE, dp->dir, SZDIRE);
2129 res = dir_next(dp, 0);
2132 res = move_window(dp->obj.fs, dp->sect);
2134 if (dp->dir[XDIR_Type] != ET_FILENAME) return FR_INT_ERR; /* Invalid order */
2135 if (i < MAXDIRB(FF_MAX_LFN)) memcpy(dirb + i, dp->dir, SZDIRE);
2169 DIR* dp, /* Blank directory object to be used to access containing direcotry */ argument
2176 dp->obj.fs = obj->fs;
2177 dp->obj.sclust = obj->c_scl;
2178 dp->obj.stat = (BYTE)obj->c_size;
2179 dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2180 dp->obj.n_frag = 0;
2181 dp->blk_ofs = obj->c_ofs;
2183 res = dir_sdi(dp, dp->blk_ofs); /* Goto object's entry block */
2185 res = load_xdir(dp); /* Load the object's entry block */
2198 DIR* dp /* Pointer to the direcotry object */ argument
2203 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the direcotry entry block 85+C0+C1s */
2210 res = dir_sdi(dp, dp->blk_ofs);
2212 res = move_window(dp->obj.fs, dp->sect);
2214 memcpy(dp->dir, dirb, SZDIRE);
2215 dp->obj.fs->wflag = 1;
2218 res = dir_next(dp, 0);
2272 #define DIR_READ_FILE(dp) dir_read(dp, 0) argument
2273 #define DIR_READ_LABEL(dp) dir_read(dp, 1) argument
2276 DIR* dp, /* Pointer to the directory object */ argument
2281 FATFS *fs = dp->obj.fs;
2287 while (dp->sect) {
2288 res = move_window(fs, dp->sect);
2290 b = dp->dir[DIR_Name]; /* Test for the entry type */
2300 dp->blk_ofs = dp->dptr; /* Get location of the block */
2301 res = load_xdir(dp); /* Load the entry block */
2303 dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */
2311 dp->obj.attr = attr = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
2318 sum = dp->dir[LDIR_Chksum];
2320 dp->blk_ofs = dp->dptr;
2323 … ord = (b == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
2325 if (ord != 0 || sum != sum_sfn(dp->dir)) { /* Is there a valid LFN? */
2326 dp->blk_ofs = 0xFFFFFFFF; /* It has no LFN. */
2337 res = dir_next(dp, 0); /* Next entry */
2341 if (res != FR_OK) dp->sect = 0; /* Terminate the read operation on error or EOT */
2354 DIR* dp /* Pointer to the directory object with the file name */ argument
2358 FATFS *fs = dp->obj.fs;
2364 res = dir_sdi(dp, 0); /* Rewind directory object */
2372 while ((res = DIR_READ_FILE(dp)) == FR_OK) { /* Read an item */
2388 ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
2391 res = move_window(fs, dp->sect);
2393 c = dp->dir[DIR_Name];
2396 dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK;
2398 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
2401 if (!(dp->fn[NSFLAG] & NS_NOLFN)) {
2403 sum = dp->dir[LDIR_Chksum];
2405 dp->blk_ofs = dp->dptr; /* Start offset of LFN */
2408 … ord = (c == ord && sum == dp->dir[LDIR_Chksum] && cmp_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
2411 if (ord == 0 && sum == sum_sfn(dp->dir)) break; /* LFN matched? */
2412 if (!(dp->fn[NSFLAG] & NS_LOSS) && !memcmp(dp->dir, dp->fn, 11)) break; /* SFN matched? */
2413 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
2417 dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK;
2418 …if (!(dp->dir[DIR_Attr] & AM_VOL) && !memcmp(dp->dir, dp->fn, 11)) break; /* Is it a valid entry? …
2420 res = dir_next(dp, 0); /* Next entry */
2435 DIR* dp /* Target directory with object name to be created */ argument
2439 FATFS *fs = dp->obj.fs;
2445 if (dp->fn[NSFLAG] & (NS_DOT | NS_NONAME)) return FR_INVALID_NAME; /* Check name validity */
2451 res = dir_alloc(dp, n_ent); /* Allocate directory entries */
2453 dp->blk_ofs = dp->dptr - SZDIRE * (n_ent - 1); /* Set the allocated entry block offset */
2455 if (dp->obj.stat & 4) { /* Has the directory been stretched by new allocation? */
2456 dp->obj.stat &= ~4;
2457 res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
2459 …res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if nee…
2461 if (dp->obj.sclust != 0) { /* Is it a sub-directory? */
2464 res = load_obj_xdir(&dj, &dp->obj); /* Load the object status */
2466 dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2467 st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize);
2468 st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2469 fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; /* Update the allocation status */
2480 memcpy(sn, dp->fn, 12);
2482 dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */
2484 gen_numname(dp->fn, sn, fs->lfnbuf, n); /* Generate a numbered name */
2485 res = dir_find(dp); /* Check if the name collides with existing SFN */
2490 dp->fn[NSFLAG] = sn[NSFLAG];
2495 res = dir_alloc(dp, n_ent); /* Allocate entries */
2497 res = dir_sdi(dp, dp->dptr - n_ent * SZDIRE);
2499 sum = sum_sfn(dp->fn); /* Checksum value of the SFN tied to the LFN */
2501 res = move_window(fs, dp->sect);
2503 put_lfn(fs->lfnbuf, dp->dir, (BYTE)n_ent, sum);
2505 res = dir_next(dp, 0); /* Next entry */
2511 res = dir_alloc(dp, 1); /* Allocate an entry for SFN */
2517 res = move_window(fs, dp->sect);
2519 memset(dp->dir, 0, SZDIRE); /* Clean the entry */
2520 memcpy(dp->dir + DIR_Name, dp->fn, 11); /* Put SFN */
2522 dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */
2541 DIR* dp /* Directory object pointing the entry to be removed */ argument
2545 FATFS *fs = dp->obj.fs;
2547 DWORD last = dp->dptr;
2549 …res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs); /* Goto top of the entry blo…
2552 res = move_window(fs, dp->sect);
2555 dp->dir[XDIR_Type] &= 0x7F; /* Clear the entry InUse flag. */
2557 dp->dir[DIR_Name] = DDEM; /* Mark the entry 'deleted'. */
2560 …if (dp->dptr >= last) break; /* If reached last entry then all entries of the object has been dele…
2561 res = dir_next(dp, 0); /* Next entry */
2567 res = move_window(fs, dp->sect);
2569 dp->dir[DIR_Name] = DDEM; /* Mark the entry 'deleted'.*/
2587 DIR* dp, /* Pointer to the directory object */ argument
2595 FATFS *fs = dp->obj.fs;
2603 if (dp->sect == 0) return; /* Exit if read pointer has reached end of directory */
2637 if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */
2657 wc = dp->dir[si++]; /* Get a char */
2662 if (dbc_1st((BYTE)wc) && si != 8 && si != 11 && dbc_2nd(dp->dir[si])) { /* Make a DBC if needed */
2663 wc = wc << 8 | dp->dir[si++];
2683 if (IsUpper(wc) && (dp->dir[DIR_NTres] & lcf)) wc += 0x20;
2688 …if (!dp->dir[DIR_NTres]) fno->altname[0] = 0; /* Altname is not needed if neither LFN nor case inf…
2694 c = (TCHAR)dp->dir[si++];
2703 fno->fattrib = dp->dir[DIR_Attr] & AM_MASK; /* Attribute */
2704 fno->fsize = ld_dword(dp->dir + DIR_FileSize); /* Size */
2705 fno->ftime = ld_word(dp->dir + DIR_ModTime + 0); /* Time */
2706 fno->fdate = ld_word(dp->dir + DIR_ModTime + 2); /* Date */
2802 DIR* dp, /* Pointer to the directory object */ argument
2815 p = *path; lfn = dp->obj.fs->lfnbuf; di = 0;
2840 dp->fn[i] = (i < di) ? '.' : ' ';
2842 dp->fn[i] = cf | NS_DOT; /* This is a dot entry */
2859 memset(dp->fn, ' ', 11);
2902 dp->fn[i++] = (BYTE)(wc >> 8); /* Put 1st byte */
2915 dp->fn[i++] = (BYTE)wc;
2918 …if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with DDEM, replace it…
2927 dp->fn[NSFLAG] = cf; /* SFN is created into dp->fn[] */
2938 p = *path; sfn = dp->fn;
3004 DIR* dp, /* Directory object to return last directory and found object */ argument
3010 FATFS *fs = dp->obj.fs;
3015 dp->obj.sclust = fs->cdir; /* Start at the current directory */
3020 dp->obj.sclust = 0; /* Start from the root directory */
3023 dp->obj.n_frag = 0; /* Invalidate last fragment counter of the object */
3025 if (fs->fs_type == FS_EXFAT && dp->obj.sclust) { /* exFAT: Retrieve the sub-directory's status */
3028 dp->obj.c_scl = fs->cdc_scl;
3029 dp->obj.c_size = fs->cdc_size;
3030 dp->obj.c_ofs = fs->cdc_ofs;
3031 res = load_obj_xdir(&dj, &dp->obj);
3033 dp->obj.objsize = ld_dword(fs->dirbuf + XDIR_FileSize);
3034 dp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2;
3040 dp->fn[NSFLAG] = NS_NONAME;
3041 res = dir_sdi(dp, 0);
3045 res = create_name(dp, &path); /* Get a segment name of the path */
3047 res = dir_find(dp); /* Find an object with the segment name */
3048 ns = dp->fn[NSFLAG];
3053 dp->fn[NSFLAG] = NS_NONAME;
3063 if (!(dp->obj.attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */
3068 dp->obj.c_scl = dp->obj.sclust;
3069 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
3070 dp->obj.c_ofs = dp->blk_ofs;
3071 init_alloc_info(fs, &dp->obj); /* Open next directory */
3075 dp->obj.sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */
4532 DIR* dp, /* Pointer to directory object to create */ argument
4541 if (!dp) return FR_INVALID_OBJECT;
4546 dp->obj.fs = fs;
4548 res = follow_path(dp, path); /* Follow the path to the directory */
4550 if (!(dp->fn[NSFLAG] & NS_NONAME)) { /* It is not the origin directory itself */
4551 if (dp->obj.attr & AM_DIR) { /* This object is a sub-directory */
4554 dp->obj.c_scl = dp->obj.sclust; /* Get containing directory inforamation */
4555 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
4556 dp->obj.c_ofs = dp->blk_ofs;
4557 init_alloc_info(fs, &dp->obj); /* Get object allocation info */
4561 dp->obj.sclust = ld_clust(fs, dp->dir); /* Get object allocation info */
4568 dp->obj.id = fs->id;
4569 res = dir_sdi(dp, 0); /* Rewind directory */
4572 if (dp->obj.sclust != 0) {
4573 dp->obj.lockid = inc_lock(dp, 0); /* Lock the sub directory */
4574 if (!dp->obj.lockid) res = FR_TOO_MANY_OPEN_FILES;
4576 dp->obj.lockid = 0; /* Root directory need not to be locked */
4585 if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function faild */
4598 DIR *dp /* Pointer to the directory object to be closed */ argument
4605 res = validate(&dp->obj, &fs); /* Check validity of the file object */
4608 if (dp->obj.lockid) res = dec_lock(dp->obj.lockid); /* Decrement sub-directory open counter */
4609 if (res == FR_OK) dp->obj.fs = 0; /* Invalidate directory object */
4611 dp->obj.fs = 0; /* Invalidate directory object */
4628 DIR* dp, /* Pointer to the open directory object */ argument
4637 res = validate(&dp->obj, &fs); /* Check validity of the directory object */
4640 res = dir_sdi(dp, 0); /* Rewind the directory object */
4643 res = DIR_READ_FILE(dp); /* Read an item */
4646 get_fileinfo(dp, fno); /* Get the object information */
4647 res = dir_next(dp, 0); /* Increment index for next */
4664 DIR* dp, /* Pointer to the open directory object */ argument
4672 res = f_readdir(dp, fno); /* Get a directory item */
4674 if (pattern_match(dp->pat, fno->fname, 0, FIND_RECURS)) break; /* Test for the file name */
4676 …if (pattern_match(dp->pat, fno->altname, 0, FIND_RECURS)) break; /* Test for alternative name if e…
4689 DIR* dp, /* Pointer to the blank directory object */ argument
4698 dp->pat = pattern; /* Save pointer to pattern string */
4699 res = f_opendir(dp, path); /* Open the target directory */
4701 res = f_findnext(dp, fno); /* Find the first item */