<div dir="ltr"><div><br></div><div>In Windows XP , it is possible to use "/" instead of "\" . Therefore , it is NOT necessary to make two different file path representations . I am not using any Windows now , therefore I can not say anything about last Windows versions . <br></div><div><br></div><div>It is very easy to check whether "/" is usable on your Windows : Use a file path with "/" . My opinion is that it will find the related file assuming that your file path is correct other than "/" .</div><div><br></div><div><br></div><div><br></div><div>Mehmet Erol Sanliturk</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 29, 2019 at 2:25 PM Bo Berglund via lazarus <<a href="mailto:lazarus@lists.lazarus-ide.org">lazarus@lists.lazarus-ide.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am writing a console application intended to be portable between<br>
Windows and Linux and it uses files on the file system for<br>
configuration and also for processing data.<br>
<br>
Since the path delimiter is different on Unix and Windows I believe I<br>
have to handle this in my code, but how?<br>
<br>
I could create all paths inside the application using Windows<br>
delimiters and then upon usage send them to a "platform filter" like<br>
FixPlatformPath() below, which returns the string with the proper<br>
delimiters for the platform.<br>
Or else I have to check wherever the paths are dealt with and put<br>
conditionals inside the code in many places.<br>
Either way it feels a bit convoluted.<br>
<br>
Is there a better way?<br>
<br>
function FixPlatformPath(PathIn: string): string;<br>
begin<br>
{$ifdef UNIX}<br>
Result:= StringReplace(PathIn, '\', PathDelim, [rfReplaceAll]);<br>
{$else}<br>
Result:= StringReplace(PathIn, '/', PathDelim, [rfReplaceAll]);<br>
{$endif}<br>
end;<br>
<br>
This would apply to all functions where files are handled such as<br>
reading config data, creating data files or reading data files etc...<br>
<br>
<br>
-- <br>
Bo Berglund<br>
Developer in Sweden<br>
<br>
-- <br>
_______________________________________________<br>
lazarus mailing list<br>
<a href="mailto:lazarus@lists.lazarus-ide.org" target="_blank">lazarus@lists.lazarus-ide.org</a><br>
<a href="https://lists.lazarus-ide.org/listinfo/lazarus" rel="noreferrer" target="_blank">https://lists.lazarus-ide.org/listinfo/lazarus</a><br>
</blockquote></div>