Path and library directory utilities for the Io language
Simply place LibPath.io and PathUtil.io in a search path. It's often easiest to simply place them in the root of your package or project.
PathUtil is a small collection of utilities for handling paths within your package or project
getDirectoryPaths
This will return the names of all items found within a provided directory. Directories named '.' and '..' will be omitted.
PathUtil getDirectoryPaths("path/to/somewhere")
// returns list("path", "names", "here")
getSearchPathByDirName
This will return the first path in the search paths which contains the provided directory name.
PathUtil getSearchPathByDirName("myPackage")
// returns "/path/to/myPackage"
LibPath is a proto for setting up and loading library directories within your package or project. Though not intended for use by itself, this can be used as a rudimentary package setup tool.
libPathInstance := LibPath clone
setLaunchPath
Set the launch path if different than the default -- System launchPath:
libPathInstance setLaunchPath("/my/preferred/launch/path")
setLibPathName
Set the path name for your libraries directory if different than the default -- "libs":
libPathInstance setLibPathName("someLibraries")
addPath
Add a search path directly to the Importer search paths:
libPathInstance addPath("/my/search/path")
addPathWithBase
Add a search path to Importer search paths with separate base path and path name:
libPathInstance addPathWithBase("/my/base/path", "pathName")
addPathWithBaseByDirName
Add a search path to Importer search paths with a base path as it is found by directory name:
libPathInstance addPathWithBaseByDirName("myProject", "pathName")
addLibPaths
Add all library paths to Importer search paths based on defined launch path and library path name
libPathInstance addLibPaths()