fatfs/src/ff.c
static void create_xdir (
	BYTE* dirb,			/* Pointer to the direcotry entry block buffer */
	const WCHAR* lfn	/* Pointer to the object name */
)
{
	UINT i;
	BYTE nc1, nlen;
	WCHAR wc;


	/* Create file-directory and stream-extension entry */
	mem_set(dirb, 0, 2 * SZDIRE);
	dirb[0 * SZDIRE + XDIR_Type] = ET_FILEDIR;
	dirb[1 * SZDIRE + XDIR_Type] = ET_STREAM;

	/* Create file-name entries */
	i = SZDIRE * 2;	/* Top of file_name entries */
	nlen = nc1 = 0; wc = 1;
	do {
		dirb[i++] = ET_FILENAME; dirb[i++] = 0;
		do {	/* Fill name field */
			if (wc != 0 && (wc = lfn[nlen]) != 0) nlen++;	/* Get a character if exist */
			st_word(dirb + i, wc); 		/* Store it */
			i += 2;
		} while (i % SZDIRE != 0);
		nc1++;
	} while (lfn[nlen]);	/* Fill next entry if any char follows */

	dirb[XDIR_NumName] = nlen;		/* Set name length */
	dirb[XDIR_NumSec] = 1 + nc1;	/* Set secondary count (C0 + C1s) */
	st_word(dirb + XDIR_NameHash, xname_sum(lfn));	/* Set name hash */
}
/*-------------------------------------------*/
/* exFAT: Create a new directory enrty block */
/*-------------------------------------------*/
Create a new directory enrty block
Create a new directory enrty block
static void create_xdir (
	BYTE* dirb,			
	const WCHAR* lfn	
)
{
	UINT i;
	BYTE nc1, nlen;
	WCHAR wc;
	mem_set(dirb, 0, 2 * SZDIRE);
	dirb[0 * SZDIRE + XDIR_Type] = ET_FILEDIR;
	dirb[1 * SZDIRE + XDIR_Type] = ET_STREAM;
	i = SZDIRE * 2;	
	nlen = nc1 = 0; wc = 1;
	do {
		dirb[i++] = ET_FILENAME; dirb[i++] = 0;
		do {	
			if (wc != 0 && (wc = lfn[nlen]) != 0) nlen++;	
			st_word(dirb + i, wc); 		
			i += 2;
		} while (i % SZDIRE != 0);
		nc1++;
	} while (lfn[nlen]);	
	dirb[XDIR_NumName] = nlen;		
	dirb[XDIR_NumSec] = 1 + nc1;	
	st_word(dirb + XDIR_NameHash, xname_sum(lfn));	
}
static void create_xdir ( BYTE * dirb , const WCHAR * lfn ) { UINT i ; BYTE nc1 , nlen ; WCHAR wc ; mem_set ( dirb , 0 , 2 * SZDIRE ) ; dirb [ 0 * SZDIRE + XDIR_Type ] = ET_FILEDIR ; dirb [ 1 * SZDIRE + XDIR_Type ] = ET_STREAM ; i = SZDIRE * 2 ; nlen = nc1 = 0 ; wc = 1 ; do { dirb [ i ++ ] = ET_FILENAME ; dirb [ i ++ ] = 0 ; do { if ( wc != 0 && ( wc = lfn [ nlen ] ) != 0 ) nlen ++ ; st_word ( dirb + i , wc ) ; i += 2 ; } while ( i % SZDIRE != 0 ) ; nc1 ++ ; } while ( lfn [ nlen ] ) ; dirb [ XDIR_NumName ] = nlen ; dirb [ XDIR_NumSec ] = 1 + nc1 ; st_word ( dirb + XDIR_NameHash , xname_sum ( lfn ) ) ; }
exFAT: Create a new directory enrty block
exFAT : Create a new directory enrty block
/* Pointer to the direcotry entry block buffer */ /* Pointer to the object name */ /* Create file-directory and stream-extension entry */ /* Create file-name entries */ /* Top of file_name entries */ /* Fill name field */ /* Get a character if exist */ /* Store it */ /* Fill next entry if any char follows */ /* Set name length */ /* Set secondary count (C0 + C1s) */ /* Set name hash */