Re: Case un-sensitive filetypes

On Sat, 5 Jan 2008 19:10:20 -0800 (PST)
Caballero Rojo <pampeano@xxxxxxxxxxxxxx> wrote:

> Hi all, just a little patch in case anyone moves files from windows to
> linux like me, I usually end up with some files with upper case.
> I modified e2_filetype_get_default_action function in e2_filetype.c,
> adding ext = g_utf8_strdown(ext,-1); before calling
> g_hash_table_lookup. That converts file extention to lower case and
> then goes to compare. I hope someone can tell me if I should allocate a
> new gchar to get the result of that function, since regarding to the
> manual, it allocates new space to return, that would make the first
> reference of ext to get lost.
> Hope this helps.
> Keep up with emelfm2, it's the best norton commander style fm that I
> found on Linux.
> 
> Best regards,
>     Guillermo Bonvehí

Thanks Guillermo. These sorts of contributions are always welcome.

The problem you're addressing has been discussed before. In summary, there's no 
good solution (well, unless we go to mime-type management or something) that 
meets everyone's needs, except to determine at runtime which file-systems are 
case-insensitive, and only in such cases would you ignore case of the filetype.

IIRC there's not many fs's that are insensitive - maybe only FAT* and one old 
one from Apple? Does any of you have, or can any of you discover, a 
comprehensive list of case-insensitive fs's?

If the situation could be confirmed, then I think it would be easy enough to 
check the fs type and then apply the sort of masking that you propose. But 
otherwise, I'm quite reluctant to make such change, at risk of breaking the 
reasonable expectations of users of a case-sensitive fs.

As to the questions you pose about the code:
It's no big deal to re-assign the function-argument variable, but you should 
g_free() the newly created string when finished with it. And this change 
by-itself would not be bullet-proof, as a user may have nominated 
file-extensions which are not, or not completely, lower-case. You'd need a 
custom hash-finding function, involving e2_utf8_caseless_match().

Regards
Tom


--
Users can unsubscribe from the list by sending email to 
emelfm2-request@xxxxxxxxxxxxx with 'unsubscribe' in the subject field or by 
logging into the web interface.

Other related posts: