fatfs/src/ff.c
static int pick_lfn (	/* 1:succeeded, 0:buffer overflow or invalid LFN entry */
	WCHAR* lfnbuf,		/* Pointer to the LFN working buffer */
	BYTE* dir			/* Pointer to the LFN entry */
)
{
	UINT i, s;
	WCHAR wc, uc;


	if (ld_word(dir + LDIR_FstClusLO) != 0) return 0;	/* Check LDIR_FstClusLO is 0 */

	i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13;	/* Offset in the LFN buffer */

	for (wc = 1, s = 0; s < 13; s++) {		/* Process all characters in the entry */
		uc = ld_word(dir + LfnOfs[s]);		/* Pick an LFN character */
		if (wc != 0) {
			if (i >= FF_MAX_LFN) return 0;	/* Buffer overflow? */
			lfnbuf[i++] = wc = uc;			/* Store it */
		} else {
			if (uc != 0xFFFF) return 0;		/* Check filler */
		}
	}

	if (dir[LDIR_Ord] & LLEF) {				/* Put terminator if it is the last LFN part */
		if (i >= FF_MAX_LFN) return 0;		/* Buffer overflow? */
		lfnbuf[i] = 0;
	}

	return 1;		/* The part of LFN is valid */
}
/*-----------------------------------------------------*/
/* FAT-LFN: Pick a part of file name from an LFN entry */
/*-----------------------------------------------------*/
FAT-LFN: Pick a part of file name from an LFN entry
FAT - LFN : Pick a part of file name from an LFN entry
static int pick_lfn (	
	WCHAR* lfnbuf,		
	BYTE* dir			
)
{
	UINT i, s;
	WCHAR wc, uc;
	if (ld_word(dir + LDIR_FstClusLO) != 0) return 0;	
	i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13;	
	for (wc = 1, s = 0; s < 13; s++) {		
		uc = ld_word(dir + LfnOfs[s]);		
		if (wc != 0) {
			if (i >= FF_MAX_LFN) return 0;	
			lfnbuf[i++] = wc = uc;			
		} else {
			if (uc != 0xFFFF) return 0;		
		}
	}
	if (dir[LDIR_Ord] & LLEF) {				
		if (i >= FF_MAX_LFN) return 0;		
		lfnbuf[i] = 0;
	}
	return 1;		
}
static int pick_lfn ( WCHAR * lfnbuf , BYTE * dir ) { UINT i , s ; WCHAR wc , uc ; if ( ld_word ( dir + LDIR_FstClusLO ) != 0 ) return 0 ; i = ( ( dir [ LDIR_Ord ] & ~ LLEF ) - 1 ) * 13 ; for ( wc = 1 , s = 0 ; s < 13 ; s ++ ) { uc = ld_word ( dir + LfnOfs [ s ] ) ; if ( wc != 0 ) { if ( i >= FF_MAX_LFN ) return 0 ; lfnbuf [ i ++ ] = wc = uc ; } else { if ( uc != 0xFFFF ) return 0 ; } } if ( dir [ LDIR_Ord ] & LLEF ) { if ( i >= FF_MAX_LFN ) return 0 ; lfnbuf [ i ] = 0 ; } return 1 ; }
FAT-LFN: Pick a part of file name from an LFN entry
FAT - LFN : Pick a part of file name from an LFN entry
/* 1:succeeded, 0:buffer overflow or invalid LFN entry */ /* Pointer to the LFN working buffer */ /* Pointer to the LFN entry */ /* Check LDIR_FstClusLO is 0 */ /* Offset in the LFN buffer */ /* Process all characters in the entry */ /* Pick an LFN character */ /* Buffer overflow? */ /* Store it */ /* Check filler */ /* Put terminator if it is the last LFN part */ /* Buffer overflow? */ /* The part of LFN is valid */