Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/hmake/FileName.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


-----------------------------------------------------------------------------
-- |
-- Module      :  FileName
-- Copyright   :  Niklas R�o
-- 
-- Maintainer  :  Malcolm Wallace <[email protected]>
-- Stability   :  Stable
-- Portability :  All
-- 
-- Fix up filenames for Unix/RiscOS differences.
-----------------------------------------------------------------------------

module FileName (fixFileName, fixFile) where

import Argv

fixFileName = id

-- | The command-line option -nounix is used to determine whether to
--   format a file pathname for RiscOS or unix.
fixFile :: DecodedArgs
        -> String -- ^ directory path
        -> String -- ^ filename
        -> String -- ^ extension (suffix)
        -> String
fixFile opts p file suf =
  if isUnix opts
  then (case (p,last p) of
          ("",_)  -> ""
          (_,'/') -> p
          (_,_)   -> p++"/") ++ toPath file ++ '.':suf
  else p ++ suf ++ '.':file

toPath = map (\c-> if (c=='.') then '/' else c)

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].