#hs.fs
Access/inspect the filesystem
This module is partial superset of LuaFileSystem 1.8.0 (http://keplerproject.github.io/luafilesystem/). It has been modified to remove functions which do not apply to macOS filesystems and additional functions providing macOS specific filesystem information have been added.
#Submodules
#API Overview
Functions - API calls offered directly by the extension
- attributes
- chdir
- currentDir
- dir
- displayName
- fileUTI
- fileUTIalternate
- getFinderComments
- link
- lock
- lockDir
- mkdir
- pathFromBookmark
- pathToAbsolute
- pathToBookmark
- rmdir
- setFinderComments
- symlinkAttributes
- tagsAdd
- tagsGet
- tagsRemove
- tagsSet
- temporaryDirectory
- touch
- unlock
- urlFromPath
#API Documentation
#Functions
Signature | hs.fs.attributes(filepath [, aName]) -> table or string or nil,error |
Type | Function |
Description | Gets the attributes of a file |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/libfs.m line 742 |
Signature | hs.fs.chdir(path) -> true or (nil,error) |
Type | Function |
Description | Changes the current working directory to the given path. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 127 |
Signature | hs.fs.currentDir() -> string or (nil,error) |
Type | Function |
Description | Gets the current working directory |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 155 |
Signature | hs.fs.dir(path) -> iter_fn, dir_obj, nil, dir_obj |
Type | Function |
Description | Creates an iterator for walking a filesystem path |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/libfs.m line 473 |
Signature | hs.fs.displayName(filepath) -> string |
Type | Function |
Description | Returns the display name of the file or directory at a specified path. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 1026 |
Signature | hs.fs.fileUTI(path) -> string or nil |
Type | Function |
Description | Returns the Uniform Type Identifier for the file location specified. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 938 |
| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.fs.fileUTIalternate(fileUTI, type) -> string
| | Type | Function | | Description | Returns the fileUTI's equivalent form in an alternate type specification format. | | Parameters |
- a string containing a file UTI, such as one returned by
hs.fs.fileUTI
. - a string specifying the alternate format for the UTI. This string may be one of the following:
extension
- as a file extension, commonly used for platform independent file sharing when file metadata can't be guaranteed to be cross-platform compatible. Generally considered unreliable when other file type identification methods are available.mime
- as a mime-type, commonly used by Internet applications like web browsers and email applications.pasteboard
- as an NSPasteboard type (seehs.pasteboard
).ostype
- four character file type, most common pre OS X, but still used in some legacy APIs.
- the file UTI in the alternate format or nil if the UTI does not have an alternate of the specified type.
Signature | hs.fs.getFinderComments(path) -> string |
Type | Function |
Description | Get the Finder comments for the file or directory at the specified path |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/fs.lua line 68 |
Signature | hs.fs.link(old, new[, symlink]) -> true or (nil,error) |
Type | Function |
Description | Creates a link |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 346 |
Signature | hs.fs.lock(filehandle, mode[, start[, length]]) -> true or (nil,error) |
Type | Function |
Description | Locks a file, or part of it |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 209 |
Signature | hs.fs.lockDir(path, [seconds_stale]) -> lock or (nil,error) |
Type | Function |
Description | Locks a directory |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/libfs.m line 241 |
Signature | hs.fs.mkdir(dirname) -> true or (nil,error) |
Type | Function |
Description | Creates a new directory |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 382 |
Signature | hs.fs.pathFromBookmark(data) -> string | nil, string |
Type | Function |
Description | Gets the file path from a binary encoded bookmark. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/libfs.m line 1078 |
Signature | hs.fs.pathToAbsolute(filepath) -> string |
Type | Function |
Description | Gets the absolute path of a given path |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 999 |
Signature | hs.fs.pathToBookmark(path) -> string | nil |
Type | Function |
Description | Returns the path as binary encoded bookmark data. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 1047 |
Signature | hs.fs.rmdir(dirname) -> true or (nil,error) |
Type | Function |
Description | Removes an existing directory |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 411 |
Signature | hs.fs.setFinderComments(path, comment) -> boolean |
Type | Function |
Description | Set the Finder comments for the file or directory at the specified path to the comment specified |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/fs.lua line 95 |
Signature | hs.fs.symlinkAttributes (filepath [, aname]) -> table or string or nil,error |
Type | Function |
Description | Gets the attributes of a symbolic link |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fs/fs.lua line 127 |
Signature | hs.fs.tagsAdd(filepath, tags) |
Type | Function |
Description | Adds one or more tags to the Finder tags of a file |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 857 |
Signature | hs.fs.tagsGet(filepath) -> table or nil |
Type | Function |
Description | Gets the Finder tags of a file |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 825 |
Signature | hs.fs.tagsRemove(filepath, tags) |
Type | Function |
Description | Removes Finder tags from a file |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 901 |
Signature | hs.fs.tagsSet(filepath, tags) |
Type | Function |
Description | Sets the Finder tags of a file, removing any that are already set |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 880 |
Signature | hs.fs.temporaryDirectory() -> string |
Type | Function |
Description | Returns the path of the temporary directory for the current user. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 924 |
Signature | hs.fs.touch(filepath [, atime [, mtime]]) -> true or (nil,error) |
Type | Function |
Description | Updates the access and modification times of a file |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 599 |
Signature | hs.fs.unlock(filehandle[, start[, length]]) -> true or (nil,error) |
Type | Function |
Description | Unlocks a file or a part of it. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 315 |
Signature | hs.fs.urlFromPath(path) -> string | nil |
Type | Function |
Description | Returns the encoded URL from a path. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fs/libfs.m line 1130 |