end-of-exe (empty) → 0.1.0.0
raw patch · 6 files changed
+159/−0 lines, 6 filesdep +basedep +directorysetup-changed
Dependencies added: base, directory
Files
- ChangeLog.md +6/−0
- EndOfExe2.hs +78/−0
- LICENSE +20/−0
- README.md +20/−0
- Setup.hs +2/−0
- end-of-exe.cabal +33/−0
+ ChangeLog.md view
@@ -0,0 +1,6 @@+# Revision history for end-of-exe++## 0.1.0.0 -- 2024-01-04d++* First version. Released on an unsuspecting world. Is a fork of the now deprecated mmsyn3 package. Added some generalized functionality to better support other versions of Windows besides 7.+
+ EndOfExe2.hs view
@@ -0,0 +1,78 @@+-- |+-- Module : EndOfExe2+-- Copyright : (c) Oleksandr Zhabenko 2019-2024+-- License : MIT+-- Maintainer : oleksandr.zhabenko@yahoo.com+--+-- A small library to deal with executable endings. Uses a Maybe data representation inside an IO monad.+--+-- Poorly tested for Windows (just Windows 7). Well, it can be extended so that it can basically support also other versions and OSes.+--+-- It is a fork of now deprecated library [mmsyn3](https://hackage.haskell.org/package/mmsyn3).++{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_HADDOCK -show-extensions #-}++module EndOfExe2 where++import GHC.Base+import GHC.List+import qualified System.Directory as D (findExecutable)+import Data.Maybe (isJust,isNothing,fromJust)+import System.IO.Unsafe (unsafePerformIO,unsafeDupablePerformIO)++-- | Can be used instead of 'System.Info.os' to check whether the executable ends in \".exe\". The function returns 'IO' 'Nothing' if there is neither +-- @ys@ nor @(ys ++ ".exe")@ names for executables in the search path. It can also search in other locations and its behaviour is OS dependent. For more information, please, refer to the link: https://hackage.haskell.org/package/directory-1.3.4.0/docs/System-Directory.html#v:findExecutable+maybeEndOfExecutable :: String -> IO (Maybe String)+maybeEndOfExecutable ys = do+ xs <- D.findExecutable ys+ if isJust xs + then return xs+ else do+ zs <- D.findExecutable (ys ++ ".exe")+ if isJust zs+ then return zs+ else return Nothing++-- | The function 'endOfExe' returns 'IO' \"\" if no executable found by 'D.findExecutable'. Otherwise, it returns its path in the 'IO' monad.+endOfExe :: String -> IO String+endOfExe ys = do+ xs <- D.findExecutable ys+ if isJust xs + then return . fromJust $ xs+ else do+ zs <- D.findExecutable (ys ++ ".exe")+ if isJust zs+ then return . fromJust $ zs+ else return ""+ +-- | Gets the proper name of the executable in the system (it must be seen in the directories in the @PATH@ variable). +-- Further you can adopt it to be used +-- inside the 'System.Process.callCommand' as the name of the executable+showE :: String -> Maybe String+showE xs + | null xs = Nothing+ | otherwise = unsafePerformIO . maybeEndOfExecutable $ xs+{-# INLINE showE #-}++-- | Similar to 'showE' but uses 'unsafeDupablePerformIO', which is more efficient, but for the multiprocessor can lead to executing the IO action multiple times.+showEDup :: String -> Maybe String+showEDup xs + | null xs = Nothing+ | otherwise = unsafeDupablePerformIO . maybeEndOfExecutable $ xs+{-# INLINE showEDup #-}++-- | If executable not found, then returns empty 'String'.+showE0 :: String -> String+showE0 xs + | null xs = ""+ | otherwise = unsafePerformIO . endOfExe $ xs+{-# INLINE showE0 #-}++-- | If executable not found, then returns empty 'String'.+showE0Dup :: String -> String+showE0Dup xs + | null xs = ""+ | otherwise = unsafeDupablePerformIO . endOfExe $ xs+{-# INLINE showE0Dup #-}+
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2019-2024 Oleksandr Zhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ README.md view
@@ -0,0 +1,20 @@+ Devotion+ ========++P.S.: the author would like to devote this project to support the [Foundation Gastrostars](https://gastrostars.nl).++The foundation founder is [Emma Kok](https://www.emmakok.nl).++Besides, you can support Ukraine and Ukrainian people. ++All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees.++If you would like to share some financial support with Gastrostars, please, contact the mentioned foundation+using the URL:++[Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte)++or ++[Donation Page](https://gastrostars.nl/doneren)+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ end-of-exe.cabal view
@@ -0,0 +1,33 @@+-- Initial end-of-exe.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: end-of-exe+version: 0.1.0.0+synopsis: A small library to deal with executable endings+description: + A small library to deal with executable endings. Uses a Maybe data representation inside an IO monad. + .+ Poorly tested for Windows (just Windows 7). Well, it can be extended so that it can basically support also other versions and OSes.+ .+ It is a fork of now deprecated library [mmsyn3](https://hackage.haskell.org/package/mmsyn3).++homepage: https://hackage.haskell.org/package/end-of-exe+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: oleksandr.zhabenko@yahoo.com+copyright: Oleksandr Zhabenko+bug-reports: https://github.com/Oleksandr-Zhabenko/end-of-exe/issues+category: System+build-type: Simple+extra-source-files: ChangeLog.md, README.md+cabal-version: >=1.10++library+ exposed-modules: EndOfExe2+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.13 && <5, directory >=1.3.4.0 && <2+ -- hs-source-dirs:+ default-language: Haskell2010+