digitalmars.D.learn - Windows to Linux Porting
- Vino (24/24) May 03 2018 Hi All,
- Russel Winder (11/41) May 04 2018 `./nasconfig.txt`
- Vino (6/13) May 04 2018 Hi Russel,
- Russel Winder (12/15) May 04 2018 It would have helped if I had read the code first rather than jumped to ...
- Vino (5/15) May 04 2018 Hi Russel,
- Jonathan M Davis (8/16) May 04 2018 It happens to us all from time to time, and the casing of the version
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 03 2018
On Fri, 2018-05-04 at 03:30 +0000, Vino via Digitalmars-d-learn wrote:Hi All, =20 Request you help on the below code, the below code always state=20 the file does not exist even if the file do exist. =20 Code: =20 import core.stdc.stdlib: exit; import std.stdio; import std.file; import std.path; =20 auto osSwitch () { string ConfigFile; version (Windows) { ConfigFile =3D absolutePath(`.\nasconfig.txt`);=20`./nasconfig.txt` perhaps: Linux uses / (as does Windows in fact) for directory separator.= =20} else version (Linux) { ConfigFile =3D=20 absolutePath(`nasconfig.txt`); } return ConfigFile; } void main () { auto ConfigFile =3D osSwitch; if (!ConfigFile.exists) { writeln("The Configuration File ",=20 buildNormalizedPath(ConfigFile), " do to exist, Terminating the=20 execution.."); exit(-1);} else { writeln(ConfigFile); } } =20 From, Vino.B =20--=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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
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: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[...]`./nasconfig.txt` perhaps: Linux uses / (as does Windows in fact) for directory separator.[...]
May 04 2018
On Fri, 2018-05-04 at 08:47 +0000, Vino via Digitalmars-d-learn wrote:=20[=E2=80=A6]Was able to resolve the issue, the issue was the letter "L" in=20 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. :-) --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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
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:Hi Russel, No issue, and thank you for your help. From, Vino.B[…]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. :-)
May 04 2018
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: […]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 DavisWas 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. :-)
May 04 2018