Remove silly tex/ directory.
[thesis.git] / src / package / ifplatform.sty
1 %%
2 %% This is file `ifplatform.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
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}
14 \newif\ifshellescape
15 \newif\ifwindows
16 \newif\ifmacosx
17 \newif\iflinux
18 \newif\ifcygwin
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}
26 \newif\if@ip@nix@
27 \ifnum\pdf@shellescape=1\relax
28   \shellescapetrue
29 \else
30   \PackageWarningNoLine{ifplatform}{^^J \space\space\space
31     shell escape is disabled,
32     so I can only detect \@backslashchar ifwindows%
33   }
34 \fi
35 \def\ip@cantdecide{%
36   \PackageWarningNoLine{ifplatform}{^^J \space\space\space
37     I can't tell if this is Windows or *nix;
38     you appear to be both%
39   }%
40 }
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"}
44 \def\ip@backupplan{%
45   \IfFileExists{\ip@file}{%
46     \PackageWarningNoLine{ifplatform}{^^J \space\space\space
47       Please delete the file "\ip@file" and try again%
48     }%
49     \ip@cantdecide
50   }{%
51     \immediate\write18{\ip@windows@echo@test}%
52     \IfFileExists{\ip@file}{%
53       \immediate\write18{del "\ip@file"}%
54       \windowstrue
55     }{%
56       \@ip@nix@true
57     }%
58   }%
59 }
60 \ifwindows
61   \if@ip@nix@
62     \PackageWarningNoLine{ifplatform}{^^J \space\space\space
63       I can't tell if this is Windows or *nix;
64       you appear to be neither%
65     }
66   \fi
67 \else
68   \if@ip@nix@\else
69     \ifshellescape
70       \ip@backupplan
71     \else
72       \ip@cantdecide
73     \fi
74   \fi
75 \fi
76 \def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
77 \if@ip@nix@
78 \ifshellescape
79   \ifwindows\else
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}
84     \def\@tempb{Linux}
85     \ifx\@tempa\@tempb
86       \linuxtrue
87     \else
88       \def\@tempb{Darwin}
89       \ifx\@tempa\@tempb
90         \macosxtrue
91       \else
92         \def\@tempb{CYGWIN}
93         \edef\@tempc{\expandafter\ip@only@six\@tempa------\@nil}
94         \ifx\@tempb\@tempc
95           \cygwintrue
96         \else
97           \edef\unknownplatform{\@tempa}
98         \fi
99       \fi
100     \fi
101   \fi
102 \fi\fi
103 \edef\platformname{%
104   \ifwindows
105     \noexpand\windowsname
106   \else
107     \ifshellescape
108       \iflinux
109         \noexpand\linuxname
110       \else
111         \ifmacosx
112           \noexpand\macosxname
113         \else
114           \ifcygwin
115             \noexpand\cygwinname
116           \else
117             \noexpand\unknownplatform
118           \fi
119         \fi
120       \fi
121     \else
122       \noexpand\notwindowsname
123     \fi
124   \fi
125 }
126 %% Copyright (C) 2007, 2009 by Will Robertson & Johannes Große
127 %% 
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
131 %% 
132 %% This work is "author-maintained" by Will Robertson.
133 %% 
134 %% This work consists of the file  ifplatform.dtx
135 %%           and the derived files ifplatform.pdf,
136 %%                                 ifplatform.sty, and
137 %%                                 ifplatform.ins.
138 %%
139 %% End of file `ifplatform.sty'.