File: FileUtils.h

package info (click to toggle)
pd-vstplugin 0.6.1-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 2,008 kB
  • sloc: cpp: 22,783; lisp: 2,860; makefile: 37; sh: 26
file content (58 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (2)
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