Page 1 of 1

Listing files in direcotry

Posted: Mon Mar 21, 2011 11:08 am
by wojsza
Greetings I have a question for my first nds project Id like to create a simple file manager reading about it a lot and even started some coding but I have a problem with this:

Code: Select all

	DIR *pdir = NULL;
	pdir = opendir("."); 
	struct dirent *pent = NULL; 
	if (pdir == NULL)
	{
		printf("opendir() failed");
		exit(3);
	}
	while(pent == readdir(pdir))
	{
		if (pent == NULL)
		{
			printf("readdir() failed"); 
			exit(3);
		}
		printf(pent -> d_name); 
	}
	closedir(pdir); 
It allays prints out a message that open dir has failed and Im stuck with it. Includes I am using are :

Code: Select all

#include <nds.h>
#include <fat.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>

Re: Listing files in direcotry

Posted: Tue Mar 22, 2011 2:37 pm
by lazyprogramer
You used the same includes like in the libfatdir example ;) That's okay!
But did you also wrote a

Code: Select all

fatInitDefault();
or something like that (with other filesystems) in your code?
If you wrote fatInitDefault(); make sure you have a FAT filesystem on your card!