khenriks/mp3fs

`file_type` is case-sensitive

Closed this issue · 2 comments

https://github.com/khenriks/mp3fs/blob/master/src/coders.cc#L73 calls file_type to determine if a file is a 'flac', however what it really is doing is checking the file extension.

In my case, I have many millions of flac files which have the extension .FLAC, which while they are valid flac files, mp3fs fails to transcode them as flac != FLAC.

root@colossus03:~# file flac/4058765179864_1_3.FLAC
flac/4058765179864_1_3.FLAC: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 15876646 samples

This is on Ubuntu 16.04.2 with a recent git clone of the mp3fs repo.

Naive fix is there: master...bak1an:case-insensitive-naive

However, it won't work for all the possible cases like .fLaC, .OGG, etc; and the behaviour for cases when there is identically named files in the same directory with only difference in extension being uppercase will be rather random.

I would suggest adding another options flag that will change the way we're transforming filenames: instead of replacing file extension with target extension (.mp3) it would append it to original filename (and shadow origin file from being returned from readdir), so something.FLAC becomes something.FLAC.mp3 and something.fLaC becomes something.fLaC.mp3.

Decoder::CreateDecoder(...) will also downcase extension before comparing.

Does this sound sane?

I think adding the options flag just like you described would make sense.