Top Documents Download Gallery Repository
Are you looking for a Software Engineer? Check Here

40path Module

The path module provides functions related to path operations. This is a built-in module, so you can use it without being imported.

Below is an example to list path names that exist in the current directory.

println(path.dir('.'))

Below is an example to list path names that exist in the current directory and its child directories.

println(path.walk('.'))

Below is an example to list path names that matches a wild card pattern "*.txt".

println(path.glob('*.txt'))

40.1Module Function

path.absname
path.absname(name:string):map:[uri]
Returns an absolute path name of the given name.

path.basename
path.basename(pathname:string):map
Removes a suffix part of a path name.

path.bottom
path.bottom(pathname:string):map
Returns the last part of a path name.

path.cutbottom
path.cutbottom(pathname:string):map
Returns a path name after eliminating its bottom part.

path.dir
path.dir(directory?:directory, pattern*:string):flat:map:[dir,file,stat] {block?}
Creates an iterator that lists item names in the specified directory. If pathname is omitted, the current directory shall be listed. In default, this returns an iterator as its result value. Specifying the following attributes would customize the returned value:

See the chapter of Mapping Process in Gura Language Manual for the detail.

If a block is specified, it would be evaluated repeatingly with block parameters |value, idx:number| where value is the iterated value and idx the loop index starting from zero. In this case, the last evaluated value of the block would be the result value. If one of the attributes listed above is specified, an iterator or a list of the evaluated value would be returned.

path.dirname
path.dirname(pathname:string):map
Splits a pathname by a directory separator and returns a directory name part.

path.exists
path.exists(pathname:string):map
Returns true if the specified file exists in a file system.

path.extname
path.extname(pathname:string):map
Extracts a suffix part of a path name.

path.filename
path.filename(pathname:string):map
Splits a pathname by a directory separator and returns a file name part.

path.glob
path.glob(pattern:string):flat:map:[dir,file,stat] {block?}
Creates an iterator for item names that match with a pattern supporting UNIX shell-style wild cards. In default, case of characters is distinguished. In default, this returns an iterator as its result value. Specifying the following attributes would customize the returned value:

See the chapter of Mapping Process in Gura Language Manual for the detail.

If a block is specified, it would be evaluated repeatingly with block parameters |value, idx:number| where value is the iterated value and idx the loop index starting from zero. In this case, the last evaluated value of the block would be the result value. If one of the attributes listed above is specified, an iterator or a list of the evaluated value would be returned.

path.join
path.join(paths+:string):map:[uri]
Returns a path name that joins given strings with directory separators.

path.match
path.match(pattern:string, name:string):map
Returns true if a name matches with a pattern that supports UNIX shell-style wild cards. In default, case of characters is distinguished.

path.regulate
path.regulate(name:string):map:[uri]
Returns a regulated path name of the given name.

path.split
path.split(pathname:string):map:[bottom]
Splits a pathname by a directory separator and returns a list containing a directory name as the first element and a base name as the second one. This has the same result as calling path.dirname() and path.filename().

path.splitext
path.splitext(pathname:string):map
Splits a pathname by a dot character indicating a beginning of an extension and returns a list containing a path name without an extention and an extention part.

path.stat
path.stat(directory:directory):map
Returns a stat object associated with the specified item.

path.walk
path.walk(directory?:directory, maxdepth?:number, pattern*:string):flat:map:[dir,file,stat] {block?}
Creates an iterator that recursively lists item names under the specified directory. If pathname is omitted, search starts at the current directory In default, this returns an iterator as its result value. Specifying the following attributes would customize the returned value:

See the chapter of Mapping Process in Gura Language Manual for the detail.

If a block is specified, it would be evaluated repeatingly with block parameters |value, idx:number| where value is the iterated value and idx the loop index starting from zero. In this case, the last evaluated value of the block would be the result value. If one of the attributes listed above is specified, an iterator or a list of the evaluated value would be returned.


Copyright (C) 2011-2017 ypsitau