Welcome! Log In Create A New Profile

Advanced

[Resolved] Retrieve filelist

Posted by RiderFx3 
[Resolved] Retrieve filelist
March 30, 2011 12:35PM
Hello !

I have an Error with filelist retrieve.

When I lauch my homebrew, I have got this error: [-] File List Error (ret = -1)
	/* Retrieve filelist */
	ret = filelist_retrieve();
	if (ret < 0) 
	{
		printf("\n[-] File List Error (ret = %d)\n", ret);
		goto err;
	}

Here is the function:
s32 filelist_retrieve(void)
{
	char dirpath[MAX_FILEPATH_LEN];
	char *ptr = filelist;
	
	struct stat filestat;
	DIR_ITER *dir;
	
	/* Generate dirpath */
	sprintf(dirpath, "fat%d:/" FILE_DIRECTORY, device);
	
	/* Open directory */
	dir = diropen("Rider");
	if (!dir)
		return -1;
	
	/* Reset file counter */
	nb_files = 0;
	
	/* Erase file list */
	memset(filelist, 0, sizeof(filelist));
	
	/* Get directory entries */
	while (!dirnext(dir, ptr, &filestat))
		if (!(filestat.st_mode & S_IFDIR)) 
		{
			ptr += strlen(ptr) + 1;
			nb_files++;
		}
	
	/* Close directory */
	dirclose(dir);
	
	return 0;
}

But I don't understand what's wrong... My libogc is updated.

The homebrew could open the FILE_DIRECTORY.

Thanks for the help



Edited 2 time(s). Last edit at 03/30/2011 09:57PM by RiderFx3.
Re: Retrieve filelist
March 30, 2011 02:46PM
Is your homebrew on USB or SD?

Try sprintf(dirpath, "/" FILE_DIRECTORY);

It defaults to the 'default' device if you don't give in any device.
Re: Retrieve filelist
March 30, 2011 02:56PM
Thanks for the help !

it's on the SD

i will try tonight!
Re: Retrieve filelist
March 30, 2011 04:20PM
Wait a sec, you don't even use the dirpath... also change dir = diropen("Rider"); to dir = diropen(dirpath); then.
Re: Retrieve filelist
March 30, 2011 09:41PM
Thanks for helping me.

I have the same problem with:

	/* Generate dirpath */
	sprintf(dirpath, "fat%d:/" FILE_DIRECTORY, device);
	
	/* Open directory */
	dir = diropen(dirpath);
	if (!dir)
		return -1;

Same error with this:
	/* Generate dirpath */
	sprintf(dirpath, "/" FILE_DIRECTORY);
	
	/* Open directory */
	dir = diropen("rider");
	if (!dir)
		return -1;


And it works fine with this:
	/* Generate dirpath */
	sprintf(dirpath, "/" FILE_DIRECTORY);
	
	/* Open directory */
	dir = diropen(dirpath);
	if (!dir)
		return -1;


Thank you very much for the help man !!!
Sorry, only registered users may post in this forum.

Click here to login