Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
May 04, 2018 Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
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`); } 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 |
May 04, 2018 Re: Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino Attachments:
| 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 |
May 04, 2018 Re: Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Friday, 4 May 2018 at 07:43:39 UTC, Russel Winder wrote:
> On Fri, 2018-05-04 at 03:30 +0000, Vino via Digitalmars-d-learn wrote:
>> [...]
>
> `./nasconfig.txt`
>
> perhaps: Linux uses / (as does Windows in fact) for directory separator.
>
>> [...]
Hi Russel,
Was able to resolve the issue, the issue was the letter "L" in version (Linux) where is should be version (linux).
From,
Vino.B
|
May 04, 2018 Re: Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino Attachments:
| On Fri, 2018-05-04 at 08:47 +0000, Vino via Digitalmars-d-learn wrote: > […] > Was able to resolve the issue, the issue was the letter "L" in > version (Linux) where is should be version (linux). It would have helped if I had read the code first rather than jumped to a conclusion. :-) -- 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 |
May 04, 2018 Re: Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Friday, 4 May 2018 at 09:25:28 UTC, Russel Winder wrote:
> On Fri, 2018-05-04 at 08:47 +0000, Vino via Digitalmars-d-learn wrote:
>>
> […]
>> Was able to resolve the issue, the issue was the letter "L" in
>> version (Linux) where is should be version (linux).
>
> It would have helped if I had read the code first rather than jumped to a conclusion.
>
> :-)
Hi Russel,
No issue, and thank you for your help.
From,
Vino.B
|
May 04, 2018 Re: Windows to Linux Porting | ||||
---|---|---|---|---|
| ||||
On Friday, May 04, 2018 10:25:28 Russel Winder via Digitalmars-d-learn wrote: > On Fri, 2018-05-04 at 08:47 +0000, Vino via Digitalmars-d-learn wrote: > > […] > > > Was able to resolve the issue, the issue was the letter "L" in > > > > version (Linux) where is should be version (linux). > > It would have helped if I had read the code first rather than jumped to a conclusion. > > :-) It happens to us all from time to time, and the casing of the version identifiers can be easy to screw up and easy to miss the mistakes - especially since many of them are based on the names that get used with #ifdef in C/C++ rather than having consistent casing across the various version identifiers. - Jonathan M Davis |
Copyright © 1999-2021 by the D Language Foundation