You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
3.8 KiB
150 lines
3.8 KiB
%%
|
|
%% This is file `ifplatform.sty',
|
|
%% generated with the docstrip utility.
|
|
%%
|
|
%% The original source files were:
|
|
%%
|
|
%% ifplatform.dtx (with options: `package')
|
|
%% ________________________________________________________
|
|
%% Copyright (C) 2007-2017 Will Robertson & Johannes Gro^^c3^^9fe
|
|
%% License information appended.
|
|
\ProvidesPackage{ifplatform}
|
|
[2017/10/13 v0.4a Testing for the operating system]
|
|
\RequirePackage{shellesc,pdftexcmds,catchfile,ifluatex}
|
|
\newif\ifshellescape
|
|
\newif\ifwindows
|
|
\newif\ifmacosx
|
|
\newif\iflinux
|
|
\newif\ifcygwin
|
|
\newcommand\windowsname{Windows}
|
|
\newcommand\notwindowsname{*NIX}
|
|
\newcommand\linuxname{Linux}
|
|
\newcommand\macosxname{Mac\,OS\,X}
|
|
\newcommand\cygwinname{Cygwin}
|
|
\newcommand\unknownplatform{[Unknown]}
|
|
\edef\ip@file{\jobname.w18}
|
|
\newif\if@ip@nix@
|
|
\ifnum\pdf@shellescape=1\relax
|
|
\shellescapetrue
|
|
\else
|
|
\ifluatex\else
|
|
\PackageWarningNoLine{ifplatform}{^^J \space\space\space
|
|
shell escape is disabled,
|
|
so I can only detect \@backslashchar ifwindows%
|
|
}
|
|
\fi
|
|
\fi
|
|
\def\ip@cantdecide{%
|
|
\PackageWarningNoLine{ifplatform}{^^J \space\space\space
|
|
I can't tell if this is Windows or *nix;
|
|
you appear to be both%
|
|
}%
|
|
}
|
|
\ifluatex
|
|
\csname\directlua{
|
|
if os.type == "unix" then
|
|
tex.sprint("@ip@nix@true")
|
|
elseif os.type == "windows" then
|
|
tex.sprint("windowstrue")
|
|
end
|
|
}\endcsname
|
|
\else
|
|
\IfFileExists{nul:}{\@ip@nix@false}{\@ip@nix@true}
|
|
\IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
|
|
\edef\ip@windows@echo@test{echo \string# > "\ip@file"}
|
|
\def\ip@backupplan{%
|
|
\IfFileExists{\ip@file}{%
|
|
\PackageWarningNoLine{ifplatform}{^^J \space\space\space
|
|
Please delete the file "\ip@file" and try again%
|
|
}%
|
|
\ip@cantdecide
|
|
}{%
|
|
\ShellEscape{\ip@windows@echo@test}%
|
|
\IfFileExists{\ip@file}{%
|
|
\ShellEscape{del "\ip@file"}%
|
|
\windowstrue
|
|
}{%
|
|
\@ip@nix@true
|
|
}%
|
|
}%
|
|
}
|
|
\ifwindows
|
|
\if@ip@nix@
|
|
\PackageWarningNoLine{ifplatform}{^^J \space\space\space
|
|
I can't tell if this is Windows or *nix;
|
|
you appear to be neither%
|
|
}
|
|
\fi
|
|
\else
|
|
\if@ip@nix@\else
|
|
\ifshellescape
|
|
\ip@backupplan
|
|
\else
|
|
\ip@cantdecide
|
|
\fi
|
|
\fi
|
|
\fi
|
|
\fi
|
|
\def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
|
|
\if@ip@nix@\ifshellescape
|
|
\ifwindows\else
|
|
\ShellEscape{uname -s > "\ip@file"}
|
|
\CatchFileDef\@tempa{\ip@file}{}
|
|
\ShellEscape{rm -- "\ip@file"}
|
|
\edef\@tempa{\expandafter\zap@space\@tempa\@empty}
|
|
\def\@tempb{Linux}
|
|
\ifx\@tempa\@tempb
|
|
\linuxtrue
|
|
\else
|
|
\def\@tempb{Darwin}
|
|
\ifx\@tempa\@tempb
|
|
\macosxtrue
|
|
\else
|
|
\def\@tempb{CYGWIN}
|
|
\edef\@tempc{\expandafter\ip@only@six\@tempa------\@nil}
|
|
\ifx\@tempb\@tempc
|
|
\cygwintrue
|
|
\else
|
|
\edef\unknownplatform{\@tempa}
|
|
\fi
|
|
\fi
|
|
\fi
|
|
\fi
|
|
\fi\fi
|
|
\edef\platformname{%
|
|
\ifwindows
|
|
\noexpand\windowsname
|
|
\else
|
|
\ifshellescape
|
|
\iflinux
|
|
\noexpand\linuxname
|
|
\else
|
|
\ifmacosx
|
|
\noexpand\macosxname
|
|
\else
|
|
\ifcygwin
|
|
\noexpand\cygwinname
|
|
\else
|
|
\noexpand\unknownplatform
|
|
\fi
|
|
\fi
|
|
\fi
|
|
\else
|
|
\noexpand\notwindowsname
|
|
\fi
|
|
\fi
|
|
}
|
|
%% Copyright (C) 2007-2017 by Will Robertson & Johannes Gro^^c3^^9fe
|
|
%%
|
|
%% Distributable under the LaTeX Project Public License,
|
|
%% version 1.3c or higher (your choice). The latest version of
|
|
%% this license is at: http://www.latex-project.org/lppl.txt
|
|
%%
|
|
%% This work is "author-maintained" by Will Robertson.
|
|
%%
|
|
%% This work consists of the file ifplatform.dtx
|
|
%% and the derived files ifplatform.pdf,
|
|
%% ifplatform.sty, and
|
|
%% ifplatform.ins.
|
|
%%
|
|
%% End of file `ifplatform.sty'.
|
|
|