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}
23
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);
38bool rename(const std::string& srcPath, const std::string& destPath);
43bool copy(const std::string& srcPath, const std::string& destPath);
48bool createDirectory(const std::string& path);
52bool createDirectories(const std::string& path);
53bool createSymbolicLink(const std::string& target, const std::string& link);
57bool remove(const std::string& path);
61int removeRecursively(const std::string& path);
62std::string getWorkingDirectory();
63void setWorkingDirectory(const std::string& path);
64std::string getTempDirectory();
66std::string getAbsolute(const std::string& path);
72std::string getCanonical(const std::string& path);
79std::string getDirectory(const std::string& path);
91std::string getFilename(const std::string& path);
98std::string getStem(const std::string& path);
111std::string getExtension(const std::string& path);
112
113// File read/write
114
118std::vector<uint8_t> readFile(const std::string& path);
119uint8_t* readFile(const std::string& path, size_t* size);
120
124void writeFile(const std::string& path, const std::vector<uint8_t>& data);
125
138void archiveDirectory(const std::string& archivePath, const std::string& dirPath, int compressionLevel = 1);
139std::vector<uint8_t> archiveDirectory(const std::string& dirPath, int compressionLevel = 1);
140
155void unarchiveToDirectory(const std::string& archivePath, const std::string& dirPath);
156void unarchiveToDirectory(const std::vector<uint8_t>& archiveData, const std::string& dirPath);
157
158
159// Threading
160
164void setThreadName(const std::string& name);
165
166// Querying
167
169std::string getStackTrace();
173double getTime();
176double getUnixTime();
178void sleep(double time);
180
181// Applications
182
188void openBrowser(const std::string& url);
193void openDirectory(const std::string& path);
197void runProcessDetached(const std::string& path);
198
202uint32_t getFpuFlags();
203void setFpuFlags(uint32_t flags);
207
209
210
211} // namespace system
212} // namespace rack
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:32
Cross-platform functions for OS, file path, and filesystem routines.
Definition system.hpp:9
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