Lines Matching refs:dp

949 	DIR* dp,		/* Directory object pointing the file to be checked */  in chk_share()  argument
959 if (Files[i].fs == dp->obj.fs && /* Check if the object matches with an open object */ in chk_share()
960 Files[i].clu == dp->obj.sclust && in chk_share()
961 Files[i].ofs == dp->dptr) break; in chk_share()
985 DIR* dp, /* Directory object pointing the file to register or increment */ in inc_share() argument
993 if (Files[i].fs == dp->obj.fs in inc_share()
994 && Files[i].clu == dp->obj.sclust in inc_share()
995 && Files[i].ofs == dp->dptr) break; in inc_share()
1001 Files[i].fs = dp->obj.fs; in inc_share()
1002 Files[i].clu = dp->obj.sclust; in inc_share()
1003 Files[i].ofs = dp->dptr; in inc_share()
1716 DIR* dp, /* Pointer to directory object */ in dir_sdi() argument
1721 FATFS *fs = dp->obj.fs; in dir_sdi()
1727 dp->dptr = ofs; /* Set current offset */ in dir_sdi()
1728 clst = dp->obj.sclust; /* Table start cluster (0:root) */ in dir_sdi()
1731 if (FF_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ in dir_sdi()
1736 dp->sect = fs->dirbase; in dir_sdi()
1741 clst = get_fat(&dp->obj, clst); /* Get next cluster */ in dir_sdi()
1746 dp->sect = clst2sect(fs, clst); in dir_sdi()
1748 dp->clust = clst; /* Current cluster# */ in dir_sdi()
1749 if (dp->sect == 0) return FR_INT_ERR; in dir_sdi()
1750 dp->sect += ofs / SS(fs); /* Sector# of the directory entry */ in dir_sdi()
1751 dp->dir = fs->win + (ofs % SS(fs)); /* Pointer to the entry in the win[] */ in dir_sdi()
1764 DIR* dp, /* Pointer to the directory object */ in dir_next() argument
1769 FATFS *fs = dp->obj.fs; in dir_next()
1772 ofs = dp->dptr + SZDIRE; /* Next entry */ in dir_next()
1773 …if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) dp->sect = 0;… in dir_next()
1774 if (dp->sect == 0) return FR_NO_FILE; /* Report EOT if it has been disabled */ in dir_next()
1777 dp->sect++; /* Next sector */ in dir_next()
1779 if (dp->clust == 0) { /* Static table */ in dir_next()
1781 dp->sect = 0; return FR_NO_FILE; in dir_next()
1786 clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ in dir_next()
1792 dp->sect = 0; return FR_NO_FILE; in dir_next()
1794 clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ in dir_next()
1799 if (FF_FS_EXFAT) dp->obj.stat |= 4; /* exFAT: The directory has been stretched */ in dir_next()
1801 if (!stretch) dp->sect = 0; /* (this line is to suppress compiler warning) */ in dir_next()
1802 dp->sect = 0; return FR_NO_FILE; /* Report EOT */ in dir_next()
1805 dp->clust = clst; /* Initialize data for new cluster */ in dir_next()
1806 dp->sect = clst2sect(fs, clst); in dir_next()
1810 dp->dptr = ofs; /* Current entry */ in dir_next()
1811 dp->dir = fs->win + ofs % SS(fs); /* Pointer to the entry in the win[] */ in dir_next()
1825 DIR* dp, /* Pointer to the directory object */ argument
1831 FATFS *fs = dp->obj.fs;
1834 res = dir_sdi(dp, 0);
1838 res = move_window(fs, dp->sect);
1841 …if ((fs->fs_type == FS_EXFAT) ? (int)((dp->dir[XDIR_Type] & 0x80) == 0) : (int)(dp->dir[DIR_Name] …
1843 if (dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0) { /* Is the entry free? */
1849 res = dir_next(dp, 1); /* Next entry with table stretch enabled */
2149 DIR* dp /* Reading directory object pointing top of the entry block to load */ argument
2154 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */
2158 res = move_window(dp->obj.fs, dp->sect);
2160 if (dp->dir[XDIR_Type] != ET_FILEDIR) return FR_INT_ERR; /* Invalid order? */
2161 memcpy(dirb + 0 * SZDIRE, dp->dir, SZDIRE);
2166 res = dir_next(dp, 0);
2169 res = move_window(dp->obj.fs, dp->sect);
2171 if (dp->dir[XDIR_Type] != ET_STREAM) return FR_INT_ERR; /* Invalid order? */
2172 memcpy(dirb + 1 * SZDIRE, dp->dir, SZDIRE);
2178 res = dir_next(dp, 0);
2181 res = move_window(dp->obj.fs, dp->sect);
2183 if (dp->dir[XDIR_Type] != ET_FILENAME) return FR_INT_ERR; /* Invalid order? */
2184 …if (i < MAXDIRB(FF_MAX_LFN)) memcpy(dirb + i, dp->dir, SZDIRE); /* Load name entries only if the o…
2219 DIR* dp, /* Blank directory object to be used to access containing directory */ argument
2226 dp->obj.fs = obj->fs;
2227 dp->obj.sclust = obj->c_scl;
2228 dp->obj.stat = (BYTE)obj->c_size;
2229 dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2230 dp->obj.n_frag = 0;
2231 dp->blk_ofs = obj->c_ofs;
2233 res = dir_sdi(dp, dp->blk_ofs); /* Goto object's entry block */
2235 res = load_xdir(dp); /* Load the object's entry block */
2248 DIR* dp /* Pointer to the directory object */ argument
2253 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the entry set 85+C0+C1s */
2260 res = dir_sdi(dp, dp->blk_ofs); /* Top of the entry set */
2263 res = move_window(dp->obj.fs, dp->sect);
2265 memcpy(dp->dir, dirb, SZDIRE);
2266 dp->obj.fs->wflag = 1;
2270 res = dir_next(dp, 0); /* Next entry */
2324 #define DIR_READ_FILE(dp) dir_read(dp, 0) argument
2325 #define DIR_READ_LABEL(dp) dir_read(dp, 1) argument
2328 DIR* dp, /* Pointer to the directory object */ argument
2333 FATFS *fs = dp->obj.fs;
2339 while (dp->sect) {
2340 res = move_window(fs, dp->sect);
2342 b = dp->dir[DIR_Name]; /* Test for the entry type */
2352 dp->blk_ofs = dp->dptr; /* Get location of the block */
2353 res = load_xdir(dp); /* Load the entry block */
2355 dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */
2363 dp->obj.attr = attr = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
2370 sum = dp->dir[LDIR_Chksum];
2372 dp->blk_ofs = dp->dptr;
2375 … ord = (b == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
2377 if (ord != 0 || sum != sum_sfn(dp->dir)) { /* Is there a valid LFN? */
2378 dp->blk_ofs = 0xFFFFFFFF; /* It has no LFN. */
2389 res = dir_next(dp, 0); /* Next entry */
2393 if (res != FR_OK) dp->sect = 0; /* Terminate the read operation on error or EOT */
2406 DIR* dp /* Pointer to the directory object with the file name */ argument
2410 FATFS *fs = dp->obj.fs;
2416 res = dir_sdi(dp, 0); /* Rewind directory object */
2424 while ((res = DIR_READ_FILE(dp)) == FR_OK) { /* Read an item */
2440 ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
2443 res = move_window(fs, dp->sect);
2445 c = dp->dir[DIR_Name];
2448 dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK;
2450 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
2453 if (!(dp->fn[NSFLAG] & NS_NOLFN)) {
2457 dp->blk_ofs = dp->dptr; /* Start offset of LFN */
2458 sum = dp->dir[LDIR_Chksum]; /* Sum of the SFN */
2461 … ord = (c == ord && sum == dp->dir[LDIR_Chksum] && cmp_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
2464 if (ord == 0 && sum == sum_sfn(dp->dir)) break; /* LFN matched? */
2465 if (!(dp->fn[NSFLAG] & NS_LOSS) && !memcmp(dp->dir, dp->fn, 11)) break; /* SFN matched? */
2466 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Not matched, reset LFN sequence */
2470 dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK;
2471 …if (!(dp->dir[DIR_Attr] & AM_VOL) && !memcmp(dp->dir, dp->fn, 11)) break; /* Is it a valid entry? …
2473 res = dir_next(dp, 0); /* Next entry */
2488 DIR* dp /* Target directory with object name to be created */ argument
2492 FATFS *fs = dp->obj.fs;
2498 if (dp->fn[NSFLAG] & (NS_DOT | NS_NONAME)) return FR_INVALID_NAME; /* Check name validity */
2504 res = dir_alloc(dp, n_ent); /* Allocate directory entries */
2506 dp->blk_ofs = dp->dptr - SZDIRE * (n_ent - 1); /* Set the allocated entry block offset */
2508 if (dp->obj.stat & 4) { /* Has the directory been stretched by new allocation? */
2509 dp->obj.stat &= ~4;
2510 res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
2512 …res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if nee…
2514 if (dp->obj.sclust != 0) { /* Is it a sub-directory? */
2517 res = load_obj_xdir(&dj, &dp->obj); /* Load the object status */
2519 dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2520 st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize);
2521 st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2522 fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; /* Update the allocation status */
2533 memcpy(sn, dp->fn, 12);
2535 dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */
2537 gen_numname(dp->fn, sn, fs->lfnbuf, n); /* Generate a numbered name */
2538 res = dir_find(dp); /* Check if the name collides with existing SFN */
2543 dp->fn[NSFLAG] = sn[NSFLAG];
2548 res = dir_alloc(dp, n_ent); /* Allocate entries */
2550 res = dir_sdi(dp, dp->dptr - n_ent * SZDIRE);
2552 sum = sum_sfn(dp->fn); /* Checksum value of the SFN tied to the LFN */
2554 res = move_window(fs, dp->sect);
2556 put_lfn(fs->lfnbuf, dp->dir, (BYTE)n_ent, sum);
2558 res = dir_next(dp, 0); /* Next entry */
2564 res = dir_alloc(dp, 1); /* Allocate an entry for SFN */
2570 res = move_window(fs, dp->sect);
2572 memset(dp->dir, 0, SZDIRE); /* Clean the entry */
2573 memcpy(dp->dir + DIR_Name, dp->fn, 11); /* Put SFN */
2575 dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */
2594 DIR* dp /* Directory object pointing the entry to be removed */ argument
2598 FATFS *fs = dp->obj.fs;
2600 DWORD last = dp->dptr;
2602 …res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs); /* Goto top of the entry blo…
2605 res = move_window(fs, dp->sect);
2608 dp->dir[XDIR_Type] &= 0x7F; /* Clear the entry InUse flag. */
2610 dp->dir[DIR_Name] = DDEM; /* Mark the entry 'deleted'. */
2613 …if (dp->dptr >= last) break; /* If reached last entry then all entries of the object has been dele…
2614 res = dir_next(dp, 0); /* Next entry */
2620 res = move_window(fs, dp->sect);
2622 dp->dir[DIR_Name] = DDEM; /* Mark the entry 'deleted'.*/
2640 DIR* dp, /* Pointer to the directory object */ argument
2648 FATFS *fs = dp->obj.fs;
2656 if (dp->sect == 0) return; /* Exit if read pointer has reached end of directory */
2694 if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */
2716 wc = dp->dir[si++]; /* Get a char */
2721 if (dbc_1st((BYTE)wc) && si != 8 && si != 11 && dbc_2nd(dp->dir[si])) { /* Make a DBC if needed */
2722 wc = wc << 8 | dp->dir[si++];
2746 if (IsUpper(wc) && (dp->dir[DIR_NTres] & lcf)) wc += 0x20;
2751 …if (!dp->dir[DIR_NTres]) fno->altname[0] = 0; /* Altname is not needed if neither LFN nor case inf…
2757 c = (TCHAR)dp->dir[si++];
2766 fno->fattrib = dp->dir[DIR_Attr] & AM_MASK; /* Attribute */
2767 fno->fsize = ld_dword(dp->dir + DIR_FileSize); /* Size */
2768 fno->ftime = ld_word(dp->dir + DIR_ModTime + 0); /* Time */
2769 fno->fdate = ld_word(dp->dir + DIR_ModTime + 2); /* Date */
2870 DIR* dp, /* Pointer to the directory object */ argument
2884 p = *path; lfn = dp->obj.fs->lfnbuf; di = 0;
2909 dp->fn[i] = (i < di) ? '.' : ' ';
2911 dp->fn[i] = cf | NS_DOT; /* This is a dot entry */
2928 memset(dp->fn, ' ', 11);
2971 dp->fn[i++] = (BYTE)(wc >> 8); /* Put 1st byte */
2984 dp->fn[i++] = (BYTE)wc;
2987 …if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with DDEM, replace it…
2996 dp->fn[NSFLAG] = cf; /* SFN is created into dp->fn[] */
3008 p = *path; sfn = dp->fn;
3074 DIR* dp, /* Directory object to return last directory and found object */ argument
3080 FATFS *fs = dp->obj.fs;
3085 dp->obj.sclust = fs->cdir; /* Start at the current directory */
3090 dp->obj.sclust = 0; /* Start from the root directory */
3093 dp->obj.n_frag = 0; /* Invalidate last fragment counter of the object */
3095 if (fs->fs_type == FS_EXFAT && dp->obj.sclust) { /* exFAT: Retrieve the sub-directory's status */
3098 dp->obj.c_scl = fs->cdc_scl;
3099 dp->obj.c_size = fs->cdc_size;
3100 dp->obj.c_ofs = fs->cdc_ofs;
3101 res = load_obj_xdir(&dj, &dp->obj);
3103 dp->obj.objsize = ld_dword(fs->dirbuf + XDIR_FileSize);
3104 dp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2;
3110 dp->fn[NSFLAG] = NS_NONAME;
3111 res = dir_sdi(dp, 0);
3115 res = create_name(dp, &path); /* Get a segment name of the path */
3117 res = dir_find(dp); /* Find an object with the segment name */
3118 ns = dp->fn[NSFLAG];
3123 dp->fn[NSFLAG] = NS_NONAME;
3133 if (!(dp->obj.attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */
3138 dp->obj.c_scl = dp->obj.sclust;
3139 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
3140 dp->obj.c_ofs = dp->blk_ofs;
3141 init_alloc_info(fs, &dp->obj); /* Open next directory */
3145 dp->obj.sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */
4613 DIR* dp, /* Pointer to directory object to create */ argument
4622 if (!dp) return FR_INVALID_OBJECT;
4627 dp->obj.fs = fs;
4629 res = follow_path(dp, path); /* Follow the path to the directory */
4631 if (!(dp->fn[NSFLAG] & NS_NONAME)) { /* It is not the origin directory itself */
4632 if (dp->obj.attr & AM_DIR) { /* This object is a sub-directory */
4635 dp->obj.c_scl = dp->obj.sclust; /* Get containing directory information */
4636 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
4637 dp->obj.c_ofs = dp->blk_ofs;
4638 init_alloc_info(fs, &dp->obj); /* Get object allocation info */
4642 dp->obj.sclust = ld_clust(fs, dp->dir); /* Get object allocation info */
4649 dp->obj.id = fs->id;
4650 res = dir_sdi(dp, 0); /* Rewind directory */
4653 if (dp->obj.sclust != 0) {
4654 dp->obj.lockid = inc_share(dp, 0); /* Lock the sub directory */
4655 if (!dp->obj.lockid) res = FR_TOO_MANY_OPEN_FILES;
4657 dp->obj.lockid = 0; /* Root directory need not to be locked */
4666 if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function failed */
4679 DIR *dp /* Pointer to the directory object to be closed */ argument
4686 res = validate(&dp->obj, &fs); /* Check validity of the file object */
4689 if (dp->obj.lockid) res = dec_share(dp->obj.lockid); /* Decrement sub-directory open counter */
4690 if (res == FR_OK) dp->obj.fs = 0; /* Invalidate directory object */
4692 dp->obj.fs = 0; /* Invalidate directory object */
4709 DIR* dp, /* Pointer to the open directory object */ argument
4718 res = validate(&dp->obj, &fs); /* Check validity of the directory object */
4721 res = dir_sdi(dp, 0); /* Rewind the directory object */
4724 res = DIR_READ_FILE(dp); /* Read an item */
4727 get_fileinfo(dp, fno); /* Get the object information */
4728 res = dir_next(dp, 0); /* Increment index for next */
4745 DIR* dp, /* Pointer to the open directory object */ argument
4753 res = f_readdir(dp, fno); /* Get a directory item */
4755 if (pattern_match(dp->pat, fno->fname, 0, FIND_RECURS)) break; /* Test for the file name */
4757 …if (pattern_match(dp->pat, fno->altname, 0, FIND_RECURS)) break; /* Test for alternative name if e…
4770 DIR* dp, /* Pointer to the blank directory object */ argument
4779 dp->pat = pattern; /* Save pointer to pattern string */
4780 res = f_opendir(dp, path); /* Open the target directory */
4782 res = f_findnext(dp, fno); /* Find the first item */