2 %% This is file `ifplatform.sty',
3 %% generated with the docstrip utility.
5 %% The original source files were:
7 %% ifplatform.dtx (with options: `package')
8 %% _________________________________________________________
9 %% Copyright (C) 2007, 2009 Will Robertson & Johannes Große
10 %% License information appended.
11 \ProvidesPackage{ifplatform}
12 [2009/09/10 v0.3a Testing for the operating system]
13 \RequirePackage{pdftexcmds,catchfile}
19 \newcommand\windowsname{Windows}
20 \newcommand\notwindowsname{*NIX}
21 \newcommand\linuxname{Linux}
22 \newcommand\macosxname{Mac\,OS\,X}
23 \newcommand\cygwinname{Cygwin}
24 \newcommand\unknownplatform{[Unknown]}
25 \edef\ip@file{\jobname.w18}
27 \ifnum\pdf@shellescape=1\relax
30 \PackageWarningNoLine{ifplatform}{^^J \space\space\space
31 shell escape is disabled,
32 so I can only detect \@backslashchar ifwindows%
36 \PackageWarningNoLine{ifplatform}{^^J \space\space\space
37 I can't tell if this is Windows or *nix;
38 you appear to be both%
41 \IfFileExists{nul:}{\@ip@nix@false}{\@ip@nix@true}
42 \IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
43 \edef\ip@windows@echo@test{echo \string# > "\ip@file"}
45 \IfFileExists{\ip@file}{%
46 \PackageWarningNoLine{ifplatform}{^^J \space\space\space
47 Please delete the file "\ip@file" and try again%
51 \immediate\write18{\ip@windows@echo@test}%
52 \IfFileExists{\ip@file}{%
53 \immediate\write18{del "\ip@file"}%
62 \PackageWarningNoLine{ifplatform}{^^J \space\space\space
63 I can't tell if this is Windows or *nix;
64 you appear to be neither%
76 \def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
80 \immediate\write18{uname -s > "\ip@file"}
81 \CatchFileDef\@tempa{\ip@file}{}
82 \immediate\write18{rm -- "\ip@file"}
83 \edef\@tempa{\expandafter\zap@space\@tempa\@empty}
93 \edef\@tempc{\expandafter\ip@only@six\@tempa------\@nil}
97 \edef\unknownplatform{\@tempa}
105 \noexpand\windowsname
117 \noexpand\unknownplatform
122 \noexpand\notwindowsname
126 %% Copyright (C) 2007, 2009 by Will Robertson & Johannes Große
128 %% Distributable under the LaTeX Project Public License,
129 %% version 1.3c or higher (your choice). The latest version of
130 %% this license is at: http://www.latex-project.org/lppl.txt
132 %% This work is "author-maintained" by Will Robertson.
134 %% This work consists of the file ifplatform.dtx
135 %% and the derived files ifplatform.pdf,
136 %% ifplatform.sty, and
139 %% End of file `ifplatform.sty'.