Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Michael Van Canneyt via fpc-pascal



On Sun, 19 Nov 2023, Bart via fpc-pascal wrote:


On Sun, Nov 19, 2023 at 3:50 PM Bart  wrote:


Thanks again for testing.


What about ['c:','a','b']
Does it return c:a\b, or c:\a\b (on Windows), or IOW: does it take
into account driveletters?
The first one IMO would be correct.


It returns c:a\b

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Michael Van Canneyt via fpc-pascal



On Sun, 19 Nov 2023, Bart via fpc-pascal wrote:


On Sun, Nov 19, 2023 at 2:31 PM Michael Van Canneyt via fpc-pascal
 wrote:



> 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.


Thanks again for testing.
Where is EInOutArgumentException defined?
Probably it's defined as class(EInOutError)?


No. EArgumentException.


If so, what is the value of the ErrorCode property in this case?


There is no errorcode, since there is no IO. It's purely a string operation.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Bart via fpc-pascal
Put a new implementation in the bugreport.
Did not test the "wah is an illegal chatacter", IMO that should be a
seperate issue.

Currently based upon these rules:

{
  Concatenates the paths.
  If one or more of the paths is absolute, it will use the right most
absolute path as
  base path and then concatenates the remaining paths to that.
  E.g. ['\a','b','\c','d'] will return '\c\d';
  If ValidateParam is True, and any of the paths contains an invalid
path character
  an exception is raised.
  No checks are done wether or not a given paths exists.
  E.g. ['\a','b','\c:'] will hapilly return the non-sensical path '\c:'
}


My tests now give these results:

OK:   ['']: Got: '', Expected: ''
OK:   ['','']: Got: '', Expected: ''
OK:   ['','','']: Got: '', Expected: ''
OK:   ['a','b','c']: Got: 'a\b\c', Expected: 'a\b\c'
OK:   ['a','b','\c']: Got: '\c', Expected: '\c'
OK:   ['a','\b','c']: Got: '\b\c', Expected: '\b\c'
OK:   ['\a','\b','c']: Got: '\b\c', Expected: '\b\c'
OK:   ['\a','\b','\c']: Got: '\c', Expected: '\c'
OK:   ['\a','b','\c:']: Got: '\c:', Expected: '\c:'
OK:   ['a','<>','\b','c','\d'] --> EArgumentException, (as expected)
FAIL: ['c:','a','b']: Got: 'c:\a\b', Expected: '?'  <== don't know
what the expected value should be here

NOT ValidateParams
OK:   ['']: Got: '', Expected: ''
OK:   ['','']: Got: '', Expected: ''
OK:   ['','','']: Got: '', Expected: ''
OK:   ['a','b','c']: Got: 'a\b\c', Expected: 'a\b\c'
OK:   ['a','b','\c']: Got: '\c', Expected: '\c'
OK:   ['a','\b','c']: Got: '\b\c', Expected: '\b\c'
OK:   ['\a','\b','c']: Got: '\b\c', Expected: '\b\c'
OK:   ['\a','\b','\c']: Got: '\c', Expected: '\c'
OK:   ['\a','b','\c:']: Got: '\c:', Expected: '\c:'
OK:   ['a','<>','\b','c','\d']: Got: '\d', Expected: '\d'

--
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Bart via fpc-pascal
On Sun, Nov 19, 2023 at 3:50 PM Bart  wrote:

> Thanks again for testing.

What about ['c:','a','b']
Does it return c:a\b, or c:\a\b (on Windows), or IOW: does it take
into account driveletters?
The first one IMO would be correct.
-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Bart via fpc-pascal
On Sun, Nov 19, 2023 at 2:31 PM Michael Van Canneyt via fpc-pascal
 wrote:


> > 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.

Thanks again for testing.
Where is EInOutArgumentException defined?
Probably it's defined as class(EInOutError)?
If so, what is the value of the ErrorCode property in this case?


-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TPath enhancements (Issue #40513): can somebody test with Delphi 12?y

2023-11-19 Thread Michael Van Canneyt via fpc-pascal



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
 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.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal