1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#pragma once
#include <string>
#include <fstream>
namespace vst {
std::string expandPath(const char *path);
std::string normalizePath(const std::string& path);
std::string userSettingsPath();
bool pathExists(const std::string& path);
bool isDirectory(const std::string& path);
bool isFile(const std::string& path);
bool removeFile(const std::string& path);
bool renameFile(const std::string& from, const std::string& to);
bool createDirectory(const std::string& dir);
std::string fileName(const std::string& path);
std::string fileDirectory(const std::string& path);
std::string fileExtension(const std::string& path);
std::string fileBaseName(const std::string& path);
double fileTimeLastModified(const std::string& path);
// Cross platform fstream, taking UTF-8 file paths.
// Will become obsolete when we ditch macOS versions below 10.15.
class File : public std::fstream {
public:
enum Mode {
READ,
WRITE
};
File(const std::string& path, Mode mode = READ);
std::string readAll();
};
// RAII class for automatic cleanup
class TmpFile : public File {
public:
TmpFile(const std::string& path, Mode mode = READ);
~TmpFile();
protected:
std::string path_;
};
} // vst
|