MeVisLab Scripting Reference
|
Inherits QObject.
Public Slots | |
FileManager methods | |
| |
QString | readStringFromFile (const QString &filename) |
bool | writeStringToFile (const QString &filename, const QString &string) |
bool | appendStringToFile (const QString &filename, const QString &string) |
QString | readStringFromFileUTF8 (const QString &filename) |
bool | writeStringToFileUTF8 (const QString &filename, const QString &string) |
bool | appendStringToFileUTF8 (const QString &filename, const QString &string) |
bool | mkdir (const QString &path) |
bool | rmdir (const QString &path) |
bool | recursiveRemoveDir (const QString &path) |
bool | remove (const QString &filename) |
bool | moveFileToTrash (const QString &filename) |
bool | rename (const QString &filename, const QString &newfilename) |
bool | copy (const QString &src, const QString &dst) |
bool | exists (const QString &filename) |
bool | isDir (const QString &filename) |
bool | isReadable (const QString &filename) |
bool | isWritable (const QString &filename) |
QString | getTmpDir () |
QString | getHomeDir () |
bool | macIsApplicationBundle (const QString &filename) |
QString | macGetBundleExecutable (const QString &bundlename) |
QString | macGetBundleDir (const QString &id=QString()) |
QString | macGetUmbrellaBundleDir () |
QString | macGetBundleResourcesDir () |
QString | macGetBundleSharedSupportDir () |
QString | macGetApplicationForId (const QString &id) |
QString | getExecutable (const QString &name) |
QString | getExecutableOnLocalMachine (const QString &name, const QString &bundleId=QString(), const QString &withinBundlePath=QString()) |
QString | getCommonMeVisAppDataDir () |
void | setApplicationSupportUmbrellaDirectoryName (const QString &dirName) |
QString | getLocalApplicationSupportDirectory (const QString &appName=QString()) |
QString | getUserApplicationSupportDirectory (const QString &appName=QString()) |
QString | getLocalApplicationCachesDirectory (const QString &appName=QString()) |
QString | getUserApplicationCachesDirectory (const QString &appName=QString()) |
QStringList | getDrives () |
uint | getFileSize (const QString &filename) |
QDateTime | getCreationDate (const QString &filename) |
QDateTime | getLastModifiedDate (const QString &filename) |
QDateTime | getLastReadDate (const QString &filename) |
QString | normalizePath (const QString &filename) |
QString | cleanupPath (const QString &filename) |
QString | nativePath (const QString &filename) |
QStringList | contentOfDirectory (const QString &path) |
QStringList | contentOfDirectory (const QString &path, const QString &filter) |
QStringList | recursiveContentOfDirectory (const QString &path, const QString &filter) |
QStringList | recursiveContentOfDirectory (const QString &path) |
QMap< QString, QVariant > | splitPath (const QString &path) |
QString | abbreviateFilename (const QString &filename, int length) |
QString | absPath (const QString &filename, const QString ¤tDir) |
QString | getUniqueFilename (const QString &path, const QString &prefix, const QString &postfix) |
bool | isPathInside (const QString &path, const QString &containerPath) |
quint64 | diskCapacity (const QString &path) |
quint64 | availableDiskSpace (const QString &path) |
Global MLABFileManager object available in all scripts.
The MLABFileManager can be used to access the local file system. It can:
|
slot |
Abbreviates the filename so that drive and filename are still visible (length is only a hint, the string might be longer because the full filename will be visible).
|
slot |
Makes the given path absolute if it is relative (by using the currentDir).
|
slot |
Appends string to a file (latin1 encoded).
|
slot |
Appends a string to a file (UTF8 unicode encoded).
|
slot |
Returns the available space of the disk on which the given path exists in bytes.
|
slot |
Normalizes the path to contain "/" forward slashes only and removes "..".
|
slot |
Returns a string list with content of the given directory.
The method does not search recursively and returns directories and files. The returned strings contain filenames relative to path
. NOTE: This does not list hidden nor system files.
|
slot |
Returns a string list with content of the given directory filtered with the given filter.
The method does not search recursively and returns files (not directories) that match the filter. The returned strings contain filenames relative to path
. NOTE: This does not list hidden nor system files.
The filter can contain any number of filters separated by " " or ";". Example: "*.cpp *.h" will return cpp and h files
|
slot |
Copies a file (not a directory!) (returns true if OK).
|
slot |
Returns the capacity of the disk on which the given path exists in bytes.
|
slot |
Returns whether file exists.
|
slot |
Returns the directory that is common to all MeVis applications for sharing their settings.
|
slot |
Returns the creation date/time of the file.
|
slot |
Returns a list of available drives on Windows, on Unix just returns "/" (root).
|
slot |
Returns the absolute path of the given executable (where name is given without debug and file extension).
The executable is searched in all MeVisLab packages (in the bin directories). On macOS it also locates application bundles with the same name in the packages bin directories and some known default locations within MeVisLab and if found returns the main executable of that bundle. It does NOT try to locate the executable outside of the MeVisLab installation.
|
slot |
Returns the absolute path to an executable located somewhere on the user's computer: the executable's name is given without any extension.
First, the function tries to locate the executable within MeVisLab and then on the whole system. Each platform may try a different approach to locate the executable. On macOS you may also pass a bundle id and relative path within the bundle to the directory in which the executable is found. If no relative path within the bundle is given, the function tries some standard locations.
|
slot |
Returns the size of the file.
|
slot |
Returns the users home dir.
|
slot |
Returns the last modified date/time of the file.
|
slot |
Returns the last read date/time of the file.
|
slot |
Returns the absolute path to the directory in which to store discardable cache files available to everyone on this machine.
If the appName argument is provided, use the caches directory with the given name. Otherwise the caches directory of the current, calling application is returned.
|
slot |
Returns the absolute path to the directory in which to store application support data available to everyone on this machine.
If the appName argument is provided, use the application support directory with the given name. Otherwise the application support directory of the current, calling application is returned (This should be the same value as returned by getCommonMeVisAppDataDir() ).
|
slot |
Returns the path to the temporary directory (uses TEMP or TMP environment vars, falls back to /tmp on macOS or Linux.
|
slot |
Creates a unique filename of the form path + prefix + uniqueNumber + postfix, which is guaranteed to be non existent.
Unique numbers start from 0 until a non existent file is found. If the path does not exist, an empty string is returned.
|
slot |
Returns the absolute path to the directory in which to store discardable cache files available to the current user.
If the appName argument is provided, use the caches directory with the given name. Otherwise the caches directory of the current, calling application is returned.
|
slot |
Returns the absolute path to the directory in which to store application support data available to the current user.
If the appName argument is provided, use the application support directory with the given name. Otherwise the application support directory of the current, calling application is returned.
|
slot |
Returns whether file is a directory.
|
slot |
Returns whether path is contained inside containerPath.
The check is performed with and without resolving symbolic links.
|
slot |
Returns whether file is readable.
|
slot |
Returns whether file is writable.
|
slot |
Returns the directory of application bundle with given application id (macOS only).
Looks first in some sub-folders of the MLAB bundle to locate the application and then at the launch database of macOS
|
slot |
Returns the absolute path to the bundle directory of bundle with the given id or the current application if no id is given (macOS only).
|
slot |
Returns the absolute path of the main executable in the given application bundle (macOS only).
|
slot |
Returns the directory of the application resources within the application bundle (macOS only).
|
slot |
Returns the directory of the application shared support within the application bundle (macOS only).
|
slot |
Return absolute path to the umbrella bundle directory in which this bundle is embedded (macOS only).
Return QString() if this bundle is not within an umbrella bundle.
|
slot |
Returns whether the file is an application bundle (macOS only).
|
slot |
Creates a deep directory (returns true if OK).
|
slot |
File is moved to the trash folder on supported systems, otherwise the file is removed (returns true if OK).
This function is useful in all cases where the file represents a user document or a file that may be open and still required by the system, e.g. a dynamic library.
|
slot |
Converts slashes to system default "\" on Windows, "/" on macOS or Linux.
|
slot |
Normalizes the path to contain "/" forward slashes only.
|
slot |
Returns a file as string (assumes latin1 encoding, or utf-8 if a bom is encountered at the start) (is empty when read fails).
|
slot |
Returns a file as string (UTF8 unicode encoded) (is empty when read fails).
|
slot |
Returns a string list with recursive content of the given directory.
The method searches recursively and returns directories and files. NOTE: This does not list hidden nor system files. The returned strings contain filenames relative to path
.
|
slot |
Returns a string list with recursive content of the given directory.
The method searches recursively and returns files (not directories) that match the filter. The returned strings contain filenames relative to path
. NOTE: This does not list hidden nor system files.
The filter can contain any number of filters separated by " " or ";". Example: "*.cpp *.h" will return cpp and h files
|
slot |
Removes a directory and all its content recursively (returns true if OK).
|
slot |
Removes a given file (returns true if OK).
|
slot |
Renames a given file (returns true if OK).
|
slot |
Removes a directory (returns true if ok, directory must be empty).
|
slot |
Set the name of a folder that contains the support data directories of all MeVisLab applications. No such folder is created/used if empty.
Default: 'MeVis' for Windows & Linux, empty for macOS.
|
slot |
Obtains the directory, filename, basename, and extension portions of path.
The returned object has the properties
|
slot |
Writes a string to a file (latin1 encoded).
|
slot |
Writes a string to a file (UTF8 unicode encoded).