MaSH is built on top of Foldr which means that it has access to all of Foldr’s storage adapters. This means that we can work with any file, regardless of its location, using a common and consistent set of methods. Files and folders are represented in Foldr by the File object.
mash.files.get()
mash.files.get(share|number: share, string: path, user|string?: user) -> File
Retrieves a file from a share using its path and returns a File object. For user-specific shares such as SMB home folders or OneDrive, Google Drive or Dropbox shares an optional user can be specified.
Parameters
share
Either a share object or a number representing the ID key of a share
path
The path to the file using / as a path separator. Note that files stored in Google shares will have non-human readable paths.
user
Either a user object or a string representing the GUID key of a valid LDAP or Foldr user
Natural
set myFile to mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
printline myFile
Standard
myFile = mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
printline(myFile)
Output
File {
"name": "file.txt",
"path": "file.txt",
"modified": "2021-06-09T10:00:01+01:00",
"size": 30,
"is_dir": false,
"mimetype": "text/plain",
"hidden": false,
"extra": [],
"share": {
"id": 1,
"name": "My Home Folder"
}
}
Notes
This method can also be called via the shorthand form:
mash.file(share|number: share, string: path, user|string: ?user)