Listing files in direcotry

Post Reply
wojsza
Posts: 2
Joined: Thu Nov 25, 2010 12:49 pm

Listing files in direcotry

Post by wojsza » Mon Mar 21, 2011 11:08 am

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>

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: Listing files in direcotry

Post by lazyprogramer » Tue Mar 22, 2011 2:37 pm

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests