On Tue, February 7, 2012 17:43, michael.vancann...@wisa.be wrote:
> On Tue, 7 Feb 2012, Jürgen Hestermann wrote:
>> Reinier Olislagers schrieb:
>>> And while ~ is a relative path,
>>
>> But ~ is not the only placeholder that will be expanded. Relative paths
>> would
>> become absolute paths and environment variables will be replaced by
>> their
>> values too. And I think it's not restricted to Linus/Unix, it happens on
>> Windows too. So if at all I would list all these possible expansions:
>>
>> "ExpandFileName expands the filename to an absolute filename. Replaced
>> would
>> be
>> -) placeholders (like ~)
>> -) environment variables (like HOME)
>> -) relative path would completed to absolute paths
>> etc.
>
> I will look into improving the documentation. The implementation has been
> improved over the years.

Until Michael updates the documentation, some comments from me:

1) "~" is the only placeholder which is expanded by ExpandFileName and
this only on Unix platforms (in particular, those containing {$DEFINE
FPC_FEXPAND_TILDE} in the respective parts of implementations of units
sysutils (and dos for FExpand).

2) No environment variables are expanded by ExpandFileName; the "~"
placeholder is directly replaced by content of environment variable HOME
as appropriate, but if you include $HOME (or %HOME% under Dos / OS/2 /
Windows), it will stay in the expanded value literally. Changing this
would result in an incompatibility to Delphi and TP/BP. Should an
environment variable expansion feature be required, I'd do it by adding a
new function or an overloaded variant to the RTL (we could still share the
same implementation code, but probably add a different compiler define).

3) The ExpandFileName / FExpand implementation is shared across all
supported targets, but the set of features used for a particular target is
determined by conditional defines within the particular RTL version - see
comments at the end of rtl/inc/fexpand.inc for details. This means that
the exact behaviour tries to accomodate standard filesystem API
conventions and features relevant for the different targets.

Tomas


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to