VCV Rack API v2
Loading...
Searching...
No Matches
system.hpp
Go to the documentation of this file.
1#pragma once
2#include <vector>
3
4#include <common.hpp>
5
6
7namespace rack {
9namespace system {
10
11
12// Filesystem
13
17std::string join(const std::string& path1, const std::string& path2 = "");
19template <typename... Paths>
20std::string join(const std::string& path1, const std::string& path2, Paths... paths) {
21 return join(join(path1, path2), paths...);
22}
26std::vector<std::string> getEntries(const std::string& dirPath, int depth = 0);
27bool exists(const std::string& path);
29bool isFile(const std::string& path);
31bool isDirectory(const std::string& path);
32uint64_t getFileSize(const std::string& path);
37bool rename(const std::string& srcPath, const std::string& destPath);
42bool copy(const std::string& srcPath, const std::string& destPath);
47bool createDirectory(const std::string& path);
51bool createDirectories(const std::string& path);
52bool createSymbolicLink(const std::string& target, const std::string& link);
56bool remove(const std::string& path);
60int removeRecursively(const std::string& path);
61std::string getWorkingDirectory();
62void setWorkingDirectory(const std::string& path);
63std::string getTempDirectory();
65std::string getAbsolute(const std::string& path);
71std::string getCanonical(const std::string& path);
78std::string getDirectory(const std::string& path);
90std::string getFilename(const std::string& path);
97std::string getStem(const std::string& path);
110std::string getExtension(const std::string& path);
111
112// File read/write
113
117std::vector<uint8_t> readFile(const std::string& path);
118uint8_t* readFile(const std::string& path, size_t* size);
119
123void writeFile(const std::string& path, const std::vector<uint8_t>& data);
124
137void archiveDirectory(const std::string& archivePath, const std::string& dirPath, int compressionLevel = 1);
138std::vector<uint8_t> archiveDirectory(const std::string& dirPath, int compressionLevel = 1);
139
154void unarchiveToDirectory(const std::string& archivePath, const std::string& dirPath);
155void unarchiveToDirectory(const std::vector<uint8_t>& archiveData, const std::string& dirPath);
156
157
158// Threading
159
163void setThreadName(const std::string& name);
164
165// Querying
166
168std::string getStackTrace();
172double getTime();
175double getUnixTime();
177void sleep(double time);
179
180// Applications
181
187void openBrowser(const std::string& url);
192void openDirectory(const std::string& path);
196void runProcessDetached(const std::string& path);
197
201uint32_t getFpuFlags();
202void setFpuFlags(uint32_t flags);
206
208
209
210} // namespace system
211} // namespace rack
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:30
bool createSymbolicLink(const std::string &target, const std::string &link)
bool isFile(const std::string &path)
Returns whether the given path is a file.
bool remove(const std::string &path)
Deletes a file or empty directory.
void unarchiveToDirectory(const std::string &archivePath, const std::string &dirPath)
Extracts an archive into a directory.
std::string getFilename(const std::string &path)
Extracts the filename of the path.
std::string getTempDirectory()
std::string getExtension(const std::string &path)
Extracts the extension of a filename, including the dot.
double getThreadTime()
void runProcessDetached(const std::string &path)
Runs an executable without blocking.
void writeFile(const std::string &path, const std::vector< uint8_t > &data)
Writes a memory buffer to a file, overwriting if already exists.
void sleep(double time)
void setThreadName(const std::string &name)
Sets a name of the current thread for debuggers and OS-specific process viewers.
std::vector< uint8_t > readFile(const std::string &path)
Reads an entire file into a memory buffer.
std::string getOperatingSystemInfo()
int removeRecursively(const std::string &path)
Deletes a file or directory recursively.
int getLogicalCoreCount()
Returns the number of logical simultaneous multithreading (SMT) (e.g.
bool isDirectory(const std::string &path)
Returns whether the given path is a directory.
uint64_t getFileSize(const std::string &path)
std::string getStackTrace()
Returns the caller's human-readable stack trace with "\n"-separated lines.
void openBrowser(const std::string &url)
Opens a URL in a browser.
void setFpuFlags(uint32_t flags)
bool createDirectories(const std::string &path)
Creates all directories up to the path.
std::string getStem(const std::string &path)
Extracts the portion of a filename without the extension.
bool createDirectory(const std::string &path)
Creates a directory.
uint32_t getFpuFlags()
Returns the CPU's floating point unit control flags.
std::string getDirectory(const std::string &path)
Extracts the parent directory of the path.
void resetFpuFlags()
Sets Rack-recommended FPU flags for the current thread.
std::string getAbsolute(const std::string &path)
Returns the absolute path beginning with "/".
std::vector< std::string > getEntries(const std::string &dirPath, int depth=0)
Returns all entries (directories, files, symbolic links, etc) in a directory.
void archiveDirectory(const std::string &archivePath, const std::string &dirPath, int compressionLevel=1)
Compresses the contents of a directory (recursively) to an archive.
void openDirectory(const std::string &path)
Opens Windows Explorer, Finder, etc at a directory location.
bool exists(const std::string &path)
double getUnixTime()
Returns time since 1970-01-01 00:00:00 UTC in seconds.
bool rename(const std::string &srcPath, const std::string &destPath)
Moves a file or directory.
double getTime()
Returns the number of seconds since application launch.
bool copy(const std::string &srcPath, const std::string &destPath)
Copies a file or directory recursively.
PRIVATE void init()
std::string getWorkingDirectory()
std::string getCanonical(const std::string &path)
Returns the canonical (unique) path, following symlinks and "." and ".." fake directories.
std::string join(const std::string &path1, const std::string &path2="")
Joins two paths with a directory separator.
void setWorkingDirectory(const std::string &path)
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9