Overview  Index  Help 
SMLDoc

PathUtility


structure PathUtility : PATH_UTILITY =
struct
  val trPath : string -> string
  val isAbsolute : string -> bool
  val makeAbsolute : {dir : string, path : string} -> string
  val collectFilesInDir : (string -> bool) -> string -> string list
  val splitDirFile : string -> {dir : string, file : string}
  val joinDirFile : {dir : string, file : string} -> string
  val splitBaseExt : string -> {base : string, ext : string option}
  val joinBaseExt : {base : string, ext : string option} -> string
end

Utility functions for file path manipulation.

NOTE: This structure has nothing to do with the module path. It is the Path structure in "path" module that defines functions for that purpose.

Author:
YAMATODANI Kiyoshi
Copyright:
(c) 2006, Tohoku University.
Version:
$Id: StrPathUtility.html,v 1.3 2007/02/17 07:01:58 kiyoshiy Exp $

       
Value detail

trPath

val trPath : string -> string


isAbsolute

val isAbsolute : string -> bool


makeAbsolute

val makeAbsolute : {dir : string, path : string} -> string

convert path string to absolute path.

When operating on cygwin environment, it is convenient to specify paths of source files in Unix style such as "/home/yamato/". If the argument path is in Unix style, this function converts it to Windows style path. But on Windows, OS.FileSys.fullPath can recognizes absolute path strings in Unix style, but OS.Path.isAbsolute/isRelative does not consider those paths as absolute path.

This function considers paths beginning with the "/" as absolute paths.


collectFilesInDir

val collectFilesInDir : (string -> bool) -> string -> string list


splitDirFile

val splitDirFile : string -> {dir : string, file : string}

similar with OS.Path.splitDirFile. But this version recognizes both "/" and "\\" as separator.
   "D:/foo/bar/hoge.txt"  ==> {dir = "D:/foo/bar", file = "hoge.txt"}
   "D:/foo/bar\hoge.txt"  ==> {dir = "D:/foo/bar/hoge", file = "hoge.txt"}
 


joinDirFile

val joinDirFile : {dir : string, file : string} -> string


splitBaseExt

val splitBaseExt : string -> {base : string, ext : string option}


joinBaseExt

val joinBaseExt : {base : string, ext : string option} -> string

 


Overview  Index  Help 
SMLDoc: Documentation generator for SML