filename.hs

来自「Haskell是一种程序语言。特别的」· HS 代码 · 共 35 行

HS
35
字号
-----------------------------------------------------------------------------
-- |
-- Module      :  FileName
-- Copyright   :  Niklas R鰆emo
-- 
-- Maintainer  :  Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>
-- 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)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?