Re: [AD] ~

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


George Foot <george.foot@xxxxxxxxxx> writes:
> The filing functions don't include any support for `~' expansion
> -- at the start of a path, `~' refers to the user's home
> directory, and `~foo' refers to foo's home directory.  I'd say
> that we don't need to support this for the general operations
> (since things like `fopen' don't -- it's really a shell
> feature), but possibly the canonicalisation function (I've
> forgotten its name) should support it, or the GUI file selector
> should expand it for the user.

I agree. It makes sense for pack_fopen() to be consistent with fopen() in 
not supporting this, but certainly fix_filename_path() ought to. That is 
totally consistent with the existing behaviour of making relative paths be 
absolute, and adding any missing drive letters to DOS/Windows filenames, and 
I can't think of any reason why a ~ should be interpreted as anything 
_other_ than the home directory!

> Regarding the implementation, it's not sufficient for the GUI file 
> selector to just interpret it correctly for its browsing; it can't return 
> paths starting with ~, because the user might feed them into `fopen' for 
> example.  So adding the support to the file selector is totally separate 
> from adding the support to a user-callable function.

The file selector could just call fix_filename_path() before returning the 
typed string to the user, though. It already does that if you type a 
directory name and then hit enter (for example if it is showing 
"c:\mydir\subdir" and you type "\..", when you hit enter it will change to 
display "c:\mydir"), but if you type a direct filename that will be returned 
unchanged (for example if it was in "c:\mydir\subdir" and you entered 
"\..\filename", the return string would be "c:\mydir\subdir\..\filename"). 
I can't think of any good reason not to canonicalise this path before 
returning it, though, since that is already the behaviour when you select 
things with the mouse or by typing one directory at a time...

> Any comments?  Is this just another Unix-specific feature that doesn't 
> belong here?

I don't think it hurts to include it, and it would certainly be nice for the 
file selector, grabber, etc, to handle ~ paths correctly.


--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/