scan files with FatFs from Chan

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

On the FatFs-page there is an example for scanfiles-procedure. it receives a "char* path" But what do i have to overgive to this function?
My files are on a SD-Card. no subdirectories.
Don't have any clue :(

Please help!
Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"/" would be the root directory. Probably an empty string will work just as well.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

Are you sure, that it is a frontslash?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I am.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually, I think you will use "" as the path to the root directory.

From the accompanying test program, you can specify "", "/", "\" to access the root directory after the initial mount.

char *path = "";      // current directory (starts with root)
char *path = "/";     // root directory or :
char *path = "\\";    // In C a backslash must be escaped

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't be 100% sure, but I think the version I used had no concept of "current directory". This was a couple years ago and I used the most stripped down version, too. Things could have changed since then.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how about directory mp3 ?
is it "/MP3" or "MP3" ?

it's pointing to the file but can not read the file inside the sub directory...

if (fno.fattrib & AM_DIR) {                    /* It is a directory */
	sprintf(&path[i], "/s", fn);
	res = scan_files(path);
		if (res != FR_OK) break;
			path[i] = 0;
			} else {                                 /* It is a file. */
			printf("s/s\n", path, fn);
				
			usart_pstr(" ");
sprintf_P( &temp_buffer, PSTR(" 9lu bytes "), fno.fsize );
		usart_pstr( &temp_buffer );
	byte_counter = fno.fsize / 512;
sprintf_P( &temp_buffer, PSTR(",byte counter => 9lu "), byte_counter );
	usart_pstr( &temp_buffer );usart_pstr("\n");
	PlayMP3(fn);
	

}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

how about directory mp3 ?
is it "/MP3" or "MP3" ?

Geesh if only Chan had written a user manual eh? ....

Oh, wait a minute...

http://elm-chan.org/fsw/ff/en/fi...

(there's a direct link to that page in the description of f_chdir() - please try and learn to search - what's that famous expression about spoon feeding that some genius once wrote? ;-))