Windows to Linux Porting
Russel Winder
russel at winder.org.uk
Fri May 4 07:43:39 UTC 2018
On Fri, 2018-05-04 at 03:30 +0000, Vino via Digitalmars-d-learn wrote:
> Hi All,
>
> Request you help on the below code, the below code always state
> the file does not exist even if the file do exist.
>
> Code:
>
> import core.stdc.stdlib: exit;
> import std.stdio;
> import std.file;
> import std.path;
>
> auto osSwitch () {
> string ConfigFile;
> version (Windows) { ConfigFile = absolutePath(`.\nasconfig.txt`);
`./nasconfig.txt`
perhaps: Linux uses / (as does Windows in fact) for directory separator.
> } else version (Linux) { ConfigFile =
> absolutePath(`nasconfig.txt`); }
> return ConfigFile;
> }
> void main () {
> auto ConfigFile = osSwitch;
> if (!ConfigFile.exists) { writeln("The Configuration File ",
> buildNormalizedPath(ConfigFile), " do to exist, Terminating the
> execution.."); exit(-1);}
> else { writeln(ConfigFile); }
> }
>
> From,
> Vino.B
>
--
Russel.
==========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180504/cc630b52/attachment.sig>
More information about the Digitalmars-d-learn
mailing list