scaning directories?
scaning directories?
hi im working on a little app for DS & im kinda stuck.
i have the file directories showing. but i kinda need some help scanning trough them like selecting folders & opening/closing them.
sorta like how that one example called all in one where it has a simple menu.
i cant seem to figure it out
my code is similar to the libfat code.
but how to surch trugh directories it shows?
i have the file directories showing. but i kinda need some help scanning trough them like selecting folders & opening/closing them.
sorta like how that one example called all in one where it has a simple menu.
i cant seem to figure it out
my code is similar to the libfat code.
but how to surch trugh directories it shows?
Re: scaning directories?
can you be a little more specific - I am not sure what you are asking. can you show what you are trying to do, how you are trying to do it, and why you think it is not working?
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: scaning directories?
I think he meant he wants the source code for open a directory (folder) and to show the filenames in this directory (folder).can you be a little more specific - I am not sure what you are asking.
Re: scaning directories?
yes exactly that, sorry wasnt so spacific,lazyprogramer wrote:I think he meant he wants the source code for open a directory (folder) and to show the filenames in this directory (folder).can you be a little more specific - I am not sure what you are asking.
like i have the code where the folder directories are showing. but im having problems comming up with something to look trugh the folders.
heres the code
Code: Select all
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
videoSetMode(MODE_0_2D);
videoSetModeSub(MODE_0_2D);
PrintConsole topScreen;
vramSetBankA(VRAM_A_MAIN_BG);
consoleInit(&topScreen, 0,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
PrintConsole bottomScreen;
consoleSelect(&topScreen);
//1-7 after 3 for color
iprintf("\x1b[34;1miLauncher 000\n");
vramSetBankC(VRAM_C_SUB_BG);
consoleInit(&bottomScreen, 0,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
BG_PALETTE_SUB[0] = RGB15( 0, 0, 20 );
consoleSelect(&bottomScreen);
if (fatInitDefault())
{
DIR *pdir;
struct dirent *pent;
struct stat statbuf;
pdir=opendir("/");
if (pdir)
{
while ((pent=readdir(pdir))!=NULL)
{
stat(pent->d_name,&statbuf);
if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0)continue;
if(S_ISDIR(statbuf.st_mode))
iprintf("%s <dir>\n", pent->d_name);
if(!(S_ISDIR(statbuf.st_mode)))
iprintf("%s %ld\n", pent->d_name, statbuf.st_size);
}
closedir(pdir);
}
else
{
iprintf("opendir() failure; terminating\n");
}
}
//if fails
else
{
iprintf("fatInitDefault failure: terminating\n");
}
while(1) {
//swiWaitForVBlank();
}
return 0;
}
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: scaning directories?
Sorry can you please post your hole source and maybe your Makefile, because compiling this short piece of code isn't possible!
-
- Posts: 1
- Joined: Fri Jul 09, 2010 4:16 pm
Re: scaning directories?
Hi. It might be worth your while looking at devkitpro/examples/nds/filesystem/nitrofs and libfat.
The nitrofs example seems to fill your requirement.
The nitrofs example seems to fill your requirement.
Re: scaning directories?
sorry heres the while source , & te makefile is from arm 9 templatelazyprogramer wrote:Sorry can you please post your hole source and maybe your Makefile, because compiling this short piece of code isn't possible!
Code: Select all
/*---------------------------------------------------------------------------------
Basic template code for starting a DS app
---------------------------------------------------------------------------------*/
#include <nds.h>
#include <fat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
videoSetMode(MODE_0_2D);
videoSetModeSub(MODE_0_2D);
PrintConsole topScreen;
vramSetBankA(VRAM_A_MAIN_BG);
consoleInit(&topScreen, 0,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
PrintConsole bottomScreen;
consoleSelect(&topScreen);
//1-7 after 3 for color
iprintf("\x1b[34;1miLauncher 000\n");
vramSetBankC(VRAM_C_SUB_BG);
consoleInit(&bottomScreen, 0,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
BG_PALETTE_SUB[0] = RGB15( 0, 0, 20 );
consoleSelect(&bottomScreen);
if (fatInitDefault())
{
DIR *pdir;
struct dirent *pent;
struct stat statbuf;
pdir=opendir("/");
if (pdir)
{
while ((pent=readdir(pdir))!=NULL)
{
stat(pent->d_name,&statbuf);
if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0)continue;
if(S_ISDIR(statbuf.st_mode))
iprintf("%s <dir>\n", pent->d_name);
if(!(S_ISDIR(statbuf.st_mode)))
iprintf("%s %ld\n", pent->d_name, statbuf.st_size);
}
closedir(pdir);
}
else
{
iprintf("opendir() failure; terminating\n");
}
}
//if fails
else
{
iprintf("fatInitDefault failure: terminating\n");
}
while(1) {
//swiWaitForVBlank();
}
return 0;
}
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: scaning directories?
Well, it seems that you changed the Makefile a bit:
You have to add the libfat in your makefile right?
I will test your app now...
Code: Select all
LIBS := -lfat -lnds9
I will test your app now...
Re: scaning directories?
yes i added thoselazyprogramer wrote:Well, it seems that you changed the Makefile a bit:You have to add the libfat in your makefile right?Code: Select all
LIBS := -lfat -lnds9
I will test your app now...
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests