Example #1
0
int dirnextl (DIR_ITER *dirState, char *filename, char *longFilename, struct stat *filestat)
{
	DIR_STATE_STRUCT* state = (DIR_STATE_STRUCT*) (dirState->dirStruct);

	
	// Make sure we are still using this entry

	if (!state->inUse) {

		errno = EBADF;
		return -1;

	}


	// Make sure there is another file to report on
	
	if (! state->validEntry) {
		errno = ENOENT;

		return -1;

	}


	// Get the filename
	
	strncpy (filename, state->currentEntry.d_name, MAX_FILENAME_LENGTH);

	// Get long filename
	_FAT_unicode_unicode_to_local( state->currentEntry.unicodeFilename, (u8 *)longFilename );


	// Get the stats, if requested

	if (filestat != NULL) {

		_FAT_directory_entryStat (state->partition, &(state->currentEntry), filestat);

	}

	
	// Look for the next entry for use next time

	state->validEntry = 
_FAT_directory_getNextEntry (state->partition, &(state->currentEntry));


	return 0;
}
Example #2
0
void fat_seekdir(DIR_STATE_STRUCT *dirp, long int loc)
{
	if (!dirp->inUse) {
		__REENT._errno = EBADF;
		return;
	}

	if(0 == loc)
	{
		dirp->posEntry = 0;
	}
	else if(loc > 0)
	{
		while(dirp->posEntry < loc)
		{
			dirp->validEntry = _FAT_directory_getNextEntry (dirp->partition, &(dirp->currentEntry));
			dirp->posEntry += 1;

			if(!dirp->validEntry) break;
		}
	}

	return;
}