[fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y
Michael Van Canneyt
michael at freepascal.org
Sun Nov 19 14:31:45 CET 2023
On Sun, 19 Nov 2023, Bart via fpc-pascal wrote:
> On Sun, Nov 19, 2023 at 12:59 PM Michael Van Canneyt via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
>
>> The output is in linux.txt and windows.txt
>
> Thanks for testing.
>
> It seems that it'll pick the last absolute path it finds, not the
> first one in the argument list.
>
> It seems that DoTest('regular 1','a','\b','c'); will give '\b\c'
> That's confucing given that the Delphi docs suggest that if an
> absolute path is found (being not the firts argument), then this path
> will be the function result.
Given the purpose, I think it's perfectly logical since it starts from the back.
The purpose is to create an absolute path given some partial or complete paths.
So you must start from the back.
I have a file myfile = 'c:\something\myfile.inc' that I must find in a path
so I do
For P in SearchPath do
begin
F:=TPath.Combine(P,MyFile);
if FileExists(F) then
Exit(F)
The above should return myfile since that is an absolute filename.
> If that were to be true, I would expect the result to be '\b' in that case.
>
> This raises the question what the result of
> TPath.Combine(['a','\b',c'','\d','e']) would be (I would then expect
> either \b\c or \d\e)?
\d\e
>
> If ValidateParams is True, will it raise an error on invalid path
> characters in an argument that will not be used for the final result
> e.g. ['a','<|>','c:\foo']?
Yes. All arguments are checked.
Michael.
More information about the fpc-pascal
mailing list