From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f890526de6a8a218 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!proxad.net!easynet-quince!easynet.net!news-peer-lilac.gradwell.net!not-for-mail From: Rob Norris Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? Date: Thu, 13 Oct 2005 13:06:16 +0100 Message-ID: <22jsk1pnk6664cr4so2nig7ssi2u0d6bv7@4ax.com> References: X-Newsreader: Forte Free Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Date: 13 Oct 2005 11:56:39 GMT NNTP-Posting-Host: 20.133.0.1 X-Trace: 1129204599 news.gradwell.net 38039 dnews/20.133.0.1 X-Complaints-To: news-abuse@gradwell.net Xref: g2news1.google.com comp.lang.ada:5593 Date: 2005-10-13T11:56:39+00:00 List-Id: On Thu, 13 Oct 2005 02:35:13 GMT, "Roger Blum" wrote: >Is there a way within Ada (GNAT 3.15p) to tell whether the application is >running on Linux or Windows (and the version of the OS)? > >Regards, >Roger > One lazy dirty method is to inspect the path or directory separators. Not very exact, but may be useful eg: type os_type is (Unix, Windows, Unknown); function What_OS return os_type is if gnat.os_lib.directory_separator = '/' then return Unix; elsif gnat.os_lib.directory_separator = '\' then return Windows; else return Unknown; end if; end What_OS;