[Lazarus] Multi-platform console application, how to handle file paths?
Michael Van Canneyt
michael at freepascal.org
Tue Oct 29 13:59:11 CET 2019
On Tue, 29 Oct 2019, Bo Berglund via lazarus wrote:
> On Tue, 29 Oct 2019 12:43:51 +0100 (CET), Michael Van Canneyt via
> lazarus <lazarus at lists.lazarus-ide.org> wrote:
>
>> 1. Don't hardcode '/' or '\', use the PathDelim constant instead.
>> You will not need any ifdefs.
>
> The whole thing is that paths might be read from config or other data
> files and so they will come in either with / or \.
> I cannot use PathDelim in the target spec because that would not find
> the erroneous delimiters.
Hence the setdirseparators call. As soon as you read a path from a file,
correct it with SetDirSeparators. For the rest you use PathDelim and all
will be well.
You're not the only one to have to deal with this, we've all been there :-)
Michael.
More information about the lazarus
mailing list