fatfs/src/ff.c
static FRESULT dir_remove (	/* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
	DIR* dp					/* Directory object pointing the entry to be removed */
)
{
	FRESULT res;
	FATFS *fs = dp->obj.fs;
#if FF_USE_LFN		/* LFN configuration */
	DWORD last = dp->dptr;

	res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs);	/* Goto top of the entry block if LFN is exist */
	if (res == FR_OK) {
		do {
			res = move_window(fs, dp->sect);
			if (res != FR_OK) break;
			if (FF_FS_EXFAT && fs->fs_type == FS_EXFAT) {	/* On the exFAT volume */
				dp->dir[XDIR_Type] &= 0x7F;	/* Clear the entry InUse flag. */
			} else {									/* On the FAT/FAT32 volume */
				dp->dir[DIR_Name] = DDEM;	/* Mark the entry 'deleted'. */
			}
			fs->wflag = 1;
			if (dp->dptr >= last) break;	/* If reached last entry then all entries of the object has been deleted. */
			res = dir_next(dp, 0);	/* Next entry */
		} while (res == FR_OK);
		if (res == FR_NO_FILE) res = FR_INT_ERR;
	}
#else			/* Non LFN configuration */

	res = move_window(fs, dp->sect);
	if (res == FR_OK) {
		dp->dir[DIR_Name] = DDEM;	/* Mark the entry 'deleted'.*/
		fs->wflag = 1;
	}
#endif

	return res;
}
/*-----------------------------------------------------------------------*/
/* Remove an object from the directory                                   */
/*-----------------------------------------------------------------------*/
Remove an object from the directory
Remove an object from the directory
static FRESULT dir_remove (	
	DIR* dp					
)
{
	FRESULT res;
	FATFS *fs = dp->obj.fs;
#if FF_USE_LFN		
	DWORD last = dp->dptr;
	res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs);	
	if (res == FR_OK) {
		do {
			res = move_window(fs, dp->sect);
			if (res != FR_OK) break;
			if (FF_FS_EXFAT && fs->fs_type == FS_EXFAT) {	
				dp->dir[XDIR_Type] &= 0x7F;	
			} else {									
				dp->dir[DIR_Name] = DDEM;	
			}
			fs->wflag = 1;
			if (dp->dptr >= last) break;	
			res = dir_next(dp, 0);	
		} while (res == FR_OK);
		if (res == FR_NO_FILE) res = FR_INT_ERR;
	}
#else			
	res = move_window(fs, dp->sect);
	if (res == FR_OK) {
		dp->dir[DIR_Name] = DDEM;	
		fs->wflag = 1;
	}
#endif
	return res;
}
static FRESULT dir_remove ( DIR * dp ) { FRESULT res ; FATFS * fs = dp -> obj . fs ; #if FF_USE_LFN DWORD last = dp -> dptr ; res = ( dp -> blk_ofs == 0xFFFFFFFF ) ? FR_OK : dir_sdi ( dp , dp -> blk_ofs ) ; if ( res == FR_OK ) { do { res = move_window ( fs , dp -> sect ) ; if ( res != FR_OK ) break ; if ( FF_FS_EXFAT && fs -> fs_type == FS_EXFAT ) { dp -> dir [ XDIR_Type ] &= 0x7F ; } else { dp -> dir [ DIR_Name ] = DDEM ; } fs -> wflag = 1 ; if ( dp -> dptr >= last ) break ; res = dir_next ( dp , 0 ) ; } while ( res == FR_OK ) ; if ( res == FR_NO_FILE ) res = FR_INT_ERR ; } #else res = move_window ( fs , dp -> sect ) ; if ( res == FR_OK ) { dp -> dir [ DIR_Name ] = DDEM ; fs -> wflag = 1 ; } #endif return res ; }
Remove an object from the directory
Remove an object from the directory
/* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ /* Directory object pointing the entry to be removed */ /* LFN configuration */ /* Goto top of the entry block if LFN is exist */ /* On the exFAT volume */ /* Clear the entry InUse flag. */ /* On the FAT/FAT32 volume */ /* Mark the entry 'deleted'. */ /* If reached last entry then all entries of the object has been deleted. */ /* Next entry */ /* Non LFN configuration */ /* Mark the entry 'deleted'.*/