Closed james-d-mitchell closed 8 years ago
This is inherited from the underlying C functions -- fopen and friends don't extend filenames.
There is a function in GAP to extend home directories (USER_HOME_EXPAND
), if we wanted to support this (and I personally think we should), we could consistently use that function everywhere.
So, we would add USER_HOME_EXPAND
to the GAP-level functions IO_Whatever
? This would be super useful.
It must still be possible to access files that actually start with a ~. In shell you can use quotes. With IO_File not.
./~...
would work, or we could document globally in GAP a method of turning off ~
expansion.
./~... makes sense. Must be documented.
More global switches in a multi-threaded application is not good.
I am very reluctant to change this, or to accept PR #38. To me, io is a low-level wrapper library around POSIX APIs. No frills added. Its simplicity is a defining feature -- while at times this is slightly inconvenient, it also ensures there are no nasty surprises.
If you want tilde expansion, how about changing
file := IO_File("~/tmp.txt", "w");
to file := IO_File(UserHomeExpand("~/tmp.txt"), "w");
?
The reason for introducing this was to make IO a bit more user friendly, but I'll close it now, and use UserHomeExpand
in the code that I have using IO_File
etc.
Currently on a Mac using
~
(for user directory) in the name of a file forIO_File
and chums, results infail
being returned. It would be wonderful if this worked.