"Fossies" - the Fresh Open Source Software Archive

Member "pp-2.14.3/src/OSAbstraction.hs" (24 Nov 2021, 1918 Bytes) of package /linux/privat/pp-2.14.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Haskell source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "OSAbstraction.hs": 2.14.2_vs_2.14.3.

    1 {- PP
    2 
    3 Copyright (C) 2015-2021 Christophe Delord
    4 
    5 http://cdelord.fr/pp
    6 
    7 This file is part of PP.
    8 
    9 PP is free software: you can redistribute it and/or modify
   10 it under the terms of the GNU General Public License as published by
   11 the Free Software Foundation, either version 3 of the License, or
   12 (at your option) any later version.
   13 
   14 PP is distributed in the hope that it will be useful,
   15 but WITHOUT ANY WARRANTY; without even the implied warranty of
   16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17 GNU General Public License for more details.
   18 
   19 You should have received a copy of the GNU General Public License
   20 along with PP.  If not, see <http://www.gnu.org/licenses/>.
   21 -}
   22 
   23 {-# LANGUAGE CPP #-}
   24 
   25 module OSAbstraction ( osname
   26                      , osarch
   27                      , cmdexe
   28                      , powershellexe
   29                      , envVarStorage
   30                      , osnl
   31                      )
   32 where
   33 
   34 import System.Info
   35 
   36 #if mingw32_HOST_OS
   37 import Data.Char
   38 #endif
   39 
   40 -- OS name
   41 osname :: String
   42 #if mingw32_HOST_OS
   43 osname = "windows"
   44 #endif
   45 #if linux_HOST_OS || darwin_HOST_OS
   46 osname = os
   47 #endif
   48 
   49 -- machine architecture
   50 osarch :: String
   51 osarch = arch
   52 
   53 -- shell command interpretor for Windows .bat scripts
   54 cmdexe :: String
   55 #if linux_HOST_OS || darwin_HOST_OS
   56 cmdexe = "wine cmd /c"
   57 #endif
   58 #if mingw32_HOST_OS
   59 cmdexe = "cmd /c"
   60 #endif
   61 
   62 -- powershell command interpretor for Windows .ps1 scripts
   63 powershellexe :: String
   64 powershellexe = "powershell -File"
   65 
   66 -- environment variable storage (should be case-insensitive on Windows)
   67 -- Thanks to tajmone (https://github.com/tajmone) for pointing out this difference.
   68 envVarStorage :: String -> String
   69 #if linux_HOST_OS || darwin_HOST_OS
   70 envVarStorage = id
   71 #endif
   72 #if mingw32_HOST_OS
   73 envVarStorage = map toUpper
   74 #endif
   75 
   76 -- OS end of line
   77 osnl :: String
   78 #if mingw32_HOST_OS
   79 osnl = "\r\n"
   80 #endif
   81 #if linux_HOST_OS || darwin_HOST_OS
   82 osnl = "\n"
   83 #endif