[Resolved] Error opening file in C based on file extension

Given the two following files, which are identical apart from the file extension:

didier@MacBook-Pro-de-Didier ~ % ls -l ~/Documents/Code/Playdate/test/Source/Sounds 
total 16
-rw-rw-r--@ 1 didier  staff  3716 18 avr 20:13 test.aif
-rw-rw-r--@ 1 didier  staff  3716 18 avr 20:13 test.raw

and the given C code trying to open them:

  //const char* filepath = "Sounds/test.raw";
  const char* filepath = "Sounds/test.aif";
  pb_log("Loading file at '%s'.", filepath);

  SDFile* file = pd->file->open(filepath, kFileRead);
  if (file == NULL) {
    pb_log("Error loading file at '%s' (%s).", filepath, pd->file->geterr());
    return 0;
  }

It seems like opening test.raw works fine while opening test.aif fails with the following output:

Loading file at 'Sounds/test.aif'.
Error loading file at 'Sounds/test.aif' (No such file).
main.lua:21: assertion failed!
stack traceback:
	[C]: in function 'assert'
	main.lua:21: in function 'setup'
	main.lua:33: in function <main.lua:31>

Am I missing something obvious (probably :grimacing:)?

I suspect that when you build the project with pdc, the aiff file is actually converted into a playdate audio file (.pda).
Can you check in the pdx file that is generated?

Right now it's not possible to tell pdc to not convert certain file types unfortunately. You can change or remove the extension and pdc will simply copy the file like it does for the raw file.

(Et bienvenu sur le forum, ca fait plaisir de voir des vedettes françaises débarquer :slight_smile: )

Bingo! That's exactly what happened. Thank you!

Not sure how I feel about this auto renaming behaviour. As soon as you have to trick something into doing the right thing, that's never a good sign IMO :face_with_monocle:

Comme tu y va... tu veut dire plutôt des dinosaurs :joy: