Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 932793
Collapse All | Expand All

(-)a/common/SC_Codecvt.hpp (-6 / +8 lines)
Lines 39-45 Link Here
39
#pragma once
39
#pragma once
40
40
41
#include <string> // string
41
#include <string> // string
42
#include <boost/filesystem/path.hpp> // path
42
#include <filesystem>
43
43
44
#ifdef _WIN32
44
#ifdef _WIN32
45
#    include <codecvt> // std::codecvt_utf8_utf16, utf16
45
#    include <codecvt> // std::codecvt_utf8_utf16, utf16
Lines 74-82 inline std::string utf16_wcstr_to_utf8_string(const wchar_t* s) { Link Here
74
 *
74
 *
75
 * On POSIX platforms, this just converts using .string(). On Windows, uses
75
 * On POSIX platforms, this just converts using .string(). On Windows, uses
76
 * conversion between UTF-16 and UTF-8. */
76
 * conversion between UTF-16 and UTF-8. */
77
inline std::string path_to_utf8_str(const boost::filesystem::path& p) {
77
inline std::string path_to_utf8_str(const std::filesystem::path& p) {
78
#ifdef _WIN32
78
#ifdef _WIN32
79
    return p.string(std::codecvt_utf8_utf16<wchar_t>());
79
    return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().to_bytes(p.native());
80
#else
80
#else
81
    return p.string();
81
    return p.string();
82
#endif // _WIN32
82
#endif // _WIN32
Lines 86-96 inline std::string path_to_utf8_str(const boost::filesystem::path& p) { Link Here
86
 *
86
 *
87
 * On POSIX platforms, this converts using the default constructor. On Windows,
87
 * On POSIX platforms, this converts using the default constructor. On Windows,
88
 * uses conversion between UTF-16 and UTF-8. */
88
 * uses conversion between UTF-16 and UTF-8. */
89
inline boost::filesystem::path utf8_str_to_path(const std::string& s) {
89
inline std::filesystem::path utf8_str_to_path(const std::string& s) {
90
#ifdef _WIN32
90
#ifdef _WIN32
91
    return boost::filesystem::path(s, std::codecvt_utf8_utf16<wchar_t>());
91
    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
92
    std::wstring wideString = converter.from_bytes(s);
93
    return std::filesystem::path(std::move(wideString));
92
#else
94
#else
93
    return boost::filesystem::path(s);
95
    return std::filesystem::path(s);
94
#endif // _WIN32
96
#endif // _WIN32
95
}
97
}
96
98
(-)a/common/SC_Filesystem.hpp (-2 / +2 lines)
Lines 76-82 Link Here
76
#include <map> // map
76
#include <map> // map
77
#include <algorithm> // std::transform
77
#include <algorithm> // std::transform
78
#include <string> // std::string
78
#include <string> // std::string
79
#include <boost/filesystem/path.hpp> // path
79
#include <filesystem> // std::filesystem
80
80
81
#include "SC_Codecvt.hpp" // path_to_utf8_str
81
#include "SC_Codecvt.hpp" // path_to_utf8_str
82
82
Lines 101-107 public: Link Here
101
    enum class DirName;
101
    enum class DirName;
102
    struct Glob;
102
    struct Glob;
103
103
104
    typedef boost::filesystem::path Path; ///< Path type.
104
    typedef std::filesystem::path Path; ///< Path type.
105
    typedef std::map<DirName, Path> DirMap; ///< Type of directory name-to-path map.
105
    typedef std::map<DirName, Path> DirMap; ///< Type of directory name-to-path map.
106
106
107
    /// SuperCollider common directory names.
107
    /// SuperCollider common directory names.
(-)a/common/SC_Filesystem_macos.cpp (-7 / +5 lines)
Lines 29-37 Link Here
29
29
30
#    include "SC_Filesystem.hpp"
30
#    include "SC_Filesystem.hpp"
31
31
32
// boost
32
#    include <filesystem> // path, parent_path(), canonical, current_path()
33
#    include <boost/filesystem/path.hpp> // path, parent_path()
34
#    include <boost/filesystem/operations.hpp> // canonical, current_path()
35
33
36
// system includes
34
// system includes
37
#    include <Foundation/NSAutoreleasePool.h>
35
#    include <Foundation/NSAutoreleasePool.h>
Lines 98-104 Path SC_Filesystem::resolveIfAlias(const Path& p, bool& isAlias) { Link Here
98
96
99
        // #4252 - URLByResolvingAliasFileAtURL will remove last trailing slash ('/Users/' ->
97
        // #4252 - URLByResolvingAliasFileAtURL will remove last trailing slash ('/Users/' ->
100
        // '/Users', '/Users///' -> '/Users//'). Protect against this case.
98
        // '/Users', '/Users///' -> '/Users//'). Protect against this case.
101
        auto* pEnd = p.c_str() + p.size();
99
        auto* pEnd = p.c_str() + p.string().size();
102
        const auto* mismatchPos = std::mismatch(p.c_str(), pEnd, resolvedNsPath).first;
100
        const auto* mismatchPos = std::mismatch(p.c_str(), pEnd, resolvedNsPath).first;
103
        // note that p.size() >= 1 because empty string would fail 'fileExistsAtPath'
101
        // note that p.size() >= 1 because empty string would fail 'fileExistsAtPath'
104
        if (mismatchPos == pEnd || (mismatchPos == pEnd - 1 && *mismatchPos == '/')) {
102
        if (mismatchPos == pEnd || (mismatchPos == pEnd - 1 && *mismatchPos == '/')) {
Lines 211-224 Path SC_Filesystem::defaultResourceDirectory() { Link Here
211
        uint32_t bufsize = PATH_MAX;
209
        uint32_t bufsize = PATH_MAX;
212
        char relDir[PATH_MAX];
210
        char relDir[PATH_MAX];
213
        if (_NSGetExecutablePath(relDir, &bufsize) == 0) {
211
        if (_NSGetExecutablePath(relDir, &bufsize) == 0) {
214
            ret = boost::filesystem::canonical(relDir); // resolve symlink
212
            ret = std::filesystem::canonical(relDir); // resolve symlink
215
            ret = ret.parent_path();
213
            ret = ret.parent_path();
216
        } else {
214
        } else {
217
            // in case it failed, fall back to current directory
215
            // in case it failed, fall back to current directory
218
            ret = boost::filesystem::current_path();
216
            ret = std::filesystem::current_path();
219
        }
217
        }
220
    }
218
    }
221
    ret = boost::filesystem::canonical(ret); // resolve lingering symlink
219
    ret = std::filesystem::canonical(ret); // resolve lingering symlink
222
    return ret;
220
    return ret;
223
}
221
}
224
222
(-)a/common/SC_Filesystem_win.cpp (-6 / +5 lines)
Lines 30-37 Link Here
30
#    include "SC_Filesystem.hpp"
30
#    include "SC_Filesystem.hpp"
31
#    include "SC_Codecvt.hpp"
31
#    include "SC_Codecvt.hpp"
32
32
33
// boost
33
#    include <filesystem>
34
#    include <boost/filesystem/operations.hpp> // is_directory
35
34
36
// system
35
// system
37
#    include <Shlobj.h> // SHGetKnownFolderPath
36
#    include <Shlobj.h> // SHGetKnownFolderPath
Lines 63-74 SC_Filesystem::Glob* SC_Filesystem::makeGlob(const char* pattern) { Link Here
63
    Glob* glob = new Glob;
62
    Glob* glob = new Glob;
64
63
65
    // use make_preferred() to change / -> \ on Windows
64
    // use make_preferred() to change / -> \ on Windows
66
    boost::filesystem::path path = SC_Codecvt::utf8_str_to_path(pattern).make_preferred();
65
    std::filesystem::path path = SC_Codecvt::utf8_str_to_path(pattern).make_preferred();
67
66
68
    // remove a trailing backslash. Even if searching with 'foo/.', this will
67
    // remove a trailing backslash. Even if searching with 'foo/.', this will
69
    // change to 'foo' harmlessly. Use has_parent_path() because otherwise '.'
68
    // change to 'foo' harmlessly. Use has_parent_path() because otherwise '.'
70
    // (referring to the CWD) won't be recognized as a valid query.
69
    // (referring to the CWD) won't be recognized as a valid query.
71
    if (path.filename_is_dot() && path.has_parent_path())
70
    if (path.filename() == "." && path.has_parent_path())
72
        path = path.parent_path();
71
        path = path.parent_path();
73
72
74
    // expand to home directory, if path starts with tilde
73
    // expand to home directory, if path starts with tilde
Lines 104-117 Path SC_Filesystem::globNext(Glob* glob) { Link Here
104
103
105
        if (!::FindNextFileW(glob->mHandle, &glob->mEntry))
104
        if (!::FindNextFileW(glob->mHandle, &glob->mEntry))
106
            glob->mAtEnd = true;
105
            glob->mAtEnd = true;
107
    } while (glob->mFilename.filename_is_dot() || glob->mFilename.filename_is_dot_dot());
106
    } while (glob->mFilename.filename() == "." || glob->mFilename.filename() == "..");
108
107
109
    // add preferred separator (L'\\') for directories on Windows, to match
108
    // add preferred separator (L'\\') for directories on Windows, to match
110
    // POSIX globbing. boost::filesystem::is_directory won't work for this because
109
    // POSIX globbing. boost::filesystem::is_directory won't work for this because
111
    // in the case of input '.' and '..', the filename here is just a single folder,
110
    // in the case of input '.' and '..', the filename here is just a single folder,
112
    // not a relative path, and so can't be correctly identified. Plus, it's faster
111
    // not a relative path, and so can't be correctly identified. Plus, it's faster
113
    // to check the attributes than to make another system call.
112
    // to check the attributes than to make another system call.
114
    return isDirectory ? glob->mFilename += boost::filesystem::path::preferred_separator : glob->mFilename;
113
    return isDirectory ? glob->mFilename += std::filesystem::path::preferred_separator : glob->mFilename;
115
}
114
}
116
115
117
//============= PRIVATE METHODS ==============//
116
//============= PRIVATE METHODS ==============//
(-)a/editors/sc-ide/core/util/standard_dirs.cpp (-2 / +2 lines)
Lines 22-28 Link Here
22
22
23
#include "SC_Filesystem.hpp" // getDirectory
23
#include "SC_Filesystem.hpp" // getDirectory
24
#include "SC_Codecvt.hpp" // path_to_utf8_str
24
#include "SC_Codecvt.hpp" // path_to_utf8_str
25
#include <boost/filesystem/path.hpp> // path
25
#include <filesystem>
26
26
27
namespace ScIDE {
27
namespace ScIDE {
28
28
Lines 59-65 QString standardDirectory(StandardDirectory type) { Link Here
59
        return QString();
59
        return QString();
60
    }
60
    }
61
61
62
    const boost::filesystem::path path = SC_Filesystem::instance().getDirectory(dn);
62
    const std::filesystem::path path = SC_Filesystem::instance().getDirectory(dn);
63
    return QString(SC_Codecvt::path_to_utf8_str(path).c_str());
63
    return QString(SC_Codecvt::path_to_utf8_str(path).c_str());
64
}
64
}
65
65
(-)a/lang/LangPrimSource/PyrFilePrim.cpp (-30 / +63 lines)
Lines 49-57 Primitives for File i/o. Link Here
49
49
50
/* C++ stdlib headers */
50
/* C++ stdlib headers */
51
#include <tuple>
51
#include <tuple>
52
52
#include <filesystem>
53
/* boost headers */
54
#include <boost/filesystem.hpp>
55
53
56
/* system headers */
54
/* system headers */
57
#ifndef _WIN32
55
#ifndef _WIN32
Lines 70-76 Primitives for File i/o. Link Here
70
68
71
#define DELIMITOR ':'
69
#define DELIMITOR ':'
72
70
73
namespace bfs = boost::filesystem;
71
namespace fs = std::filesystem;
74
72
75
int prFileDelete(struct VMGlobals* g, int numArgsPushed) {
73
int prFileDelete(struct VMGlobals* g, int numArgsPushed) {
76
    PyrSlot *a = g->sp - 1, *b = g->sp;
74
    PyrSlot *a = g->sp - 1, *b = g->sp;
Lines 80-88 int prFileDelete(struct VMGlobals* g, int numArgsPushed) { Link Here
80
    if (error != errNone)
78
    if (error != errNone)
81
        return error;
79
        return error;
82
80
83
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
81
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
84
    boost::system::error_code error_code;
82
    std::error_code error_code;
85
    bfs::remove(p, error_code);
83
    fs::remove(p, error_code);
86
84
87
    if (error_code)
85
    if (error_code)
88
        SetFalse(a);
86
        SetFalse(a);
Lines 100-107 int prFileDeleteAll(struct VMGlobals* g, int numArgsPushed) { Link Here
100
    if (error != errNone)
98
    if (error != errNone)
101
        return error;
99
        return error;
102
100
103
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
101
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
104
    if (bfs::remove_all(p) > 0) {
102
    if (fs::remove_all(p) > 0) {
105
        SetTrue(a);
103
        SetTrue(a);
106
    } else {
104
    } else {
107
        SetFalse(a);
105
        SetFalse(a);
Lines 110-115 int prFileDeleteAll(struct VMGlobals* g, int numArgsPushed) { Link Here
110
    return errNone;
108
    return errNone;
111
}
109
}
112
110
111
std::time_t to_time_t(std::filesystem::file_time_type file_time) {
112
    using namespace std::chrono;
113
    auto sctp = time_point_cast<system_clock::duration>(file_time - std::filesystem::file_time_type::clock::now()
114
                                                        + system_clock::now());
115
    return system_clock::to_time_t(sctp);
116
}
117
113
int prFileMTime(struct VMGlobals* g, int numArgsPushed) {
118
int prFileMTime(struct VMGlobals* g, int numArgsPushed) {
114
    PyrSlot *a = g->sp - 1, *b = g->sp;
119
    PyrSlot *a = g->sp - 1, *b = g->sp;
115
    char filename[PATH_MAX];
120
    char filename[PATH_MAX];
Lines 118-126 int prFileMTime(struct VMGlobals* g, int numArgsPushed) { Link Here
118
    if (error != errNone)
123
    if (error != errNone)
119
        return error;
124
        return error;
120
125
121
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
126
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
122
    time_t mtime = bfs::last_write_time(p);
127
    auto mtime = fs::last_write_time(p);
123
    SetInt(a, mtime);
128
    SetInt(a, to_time_t(mtime));
124
    return errNone;
129
    return errNone;
125
}
130
}
126
131
Lines 132-139 int prFileExists(struct VMGlobals* g, int numArgsPushed) { Link Here
132
    if (error != errNone)
137
    if (error != errNone)
133
        return error;
138
        return error;
134
139
135
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
140
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
136
    bool res = bfs::exists(p);
141
    bool res = fs::exists(p);
137
    SetBool(a, res);
142
    SetBool(a, res);
138
    return errNone;
143
    return errNone;
139
}
144
}
Lines 149-161 int prFileRealPath(struct VMGlobals* g, int numArgsPushed) { Link Here
149
        return err;
154
        return err;
150
155
151
    bool isAlias = false;
156
    bool isAlias = false;
152
    bfs::path p = SC_Codecvt::utf8_str_to_path(ipath);
157
    fs::path p = SC_Codecvt::utf8_str_to_path(ipath);
153
    p = SC_Filesystem::resolveIfAlias(p, isAlias);
158
    p = SC_Filesystem::resolveIfAlias(p, isAlias);
154
    if (p.empty())
159
    if (p.empty())
155
        return errFailed;
160
        return errFailed;
156
161
157
    boost::system::error_code error_code;
162
    std::error_code error_code;
158
    p = bfs::canonical(p, error_code).make_preferred();
163
    p = fs::canonical(p, error_code).make_preferred();
159
    if (error_code) {
164
    if (error_code) {
160
        SetNil(a);
165
        SetNil(a);
161
        return errNone;
166
        return errNone;
Lines 178-185 int prFileMkDir(struct VMGlobals* g, int numArgsPushed) { Link Here
178
    if (error != errNone)
183
    if (error != errNone)
179
        return error;
184
        return error;
180
185
181
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
186
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
182
    bool result = bfs::create_directories(p);
187
    bool result = fs::create_directories(p);
183
188
184
    SetBool(a, result);
189
    SetBool(a, result);
185
    return errNone;
190
    return errNone;
Lines 197-206 int prFileCopy(struct VMGlobals* g, int numArgsPushed) { Link Here
197
    if (error != errNone)
202
    if (error != errNone)
198
        return error;
203
        return error;
199
204
200
    const bfs::path& p1 = SC_Codecvt::utf8_str_to_path(filename1);
205
    const fs::path& p1 = SC_Codecvt::utf8_str_to_path(filename1);
201
    const bfs::path& p2 = SC_Codecvt::utf8_str_to_path(filename2);
206
    const fs::path& p2 = SC_Codecvt::utf8_str_to_path(filename2);
202
    boost::system::error_code error_code;
207
    std::error_code error_code;
203
    bfs::copy(p1, p2, error_code);
208
    fs::copy(p1, p2, error_code);
204
    if (error_code) {
209
    if (error_code) {
205
        std::ostringstream s;
210
        std::ostringstream s;
206
        s << error_code.message() << ": copy from \"" << filename1 << "\" to \"" << filename2 << "\"";
211
        s << error_code.message() << ": copy from \"" << filename1 << "\" to \"" << filename2 << "\"";
Lines 210-215 int prFileCopy(struct VMGlobals* g, int numArgsPushed) { Link Here
210
    return errNone;
215
    return errNone;
211
}
216
}
212
217
218
int prFileTypeToInt(const fs::file_type& type) {
219
    // see https://en.cppreference.com/w/cpp/filesystem/file_type
220
    // and also check this with the `File.type` method located in
221
    // `Common/Files/Files.sc`
222
    switch (type) {
223
    case fs::file_type::none:
224
        return 0;
225
    case fs::file_type::not_found:
226
        return 1;
227
    case fs::file_type::regular:
228
        return 2;
229
    case fs::file_type::directory:
230
        return 3;
231
    case fs::file_type::symlink:
232
        return 4;
233
    case fs::file_type::block:
234
        return 5;
235
    case fs::file_type::character:
236
        return 6;
237
    case fs::file_type::fifo:
238
        return 7;
239
    case fs::file_type::socket:
240
        return 8;
241
    default:
242
        return 0;
243
    }
244
}
245
213
int prFileType(struct VMGlobals* g, int numArgsPushed) {
246
int prFileType(struct VMGlobals* g, int numArgsPushed) {
214
    PyrSlot *a = g->sp - 1, *b = g->sp;
247
    PyrSlot *a = g->sp - 1, *b = g->sp;
215
    char filename[PATH_MAX];
248
    char filename[PATH_MAX];
Lines 218-226 int prFileType(struct VMGlobals* g, int numArgsPushed) { Link Here
218
    if (error != errNone)
251
    if (error != errNone)
219
        return error;
252
        return error;
220
253
221
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
254
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
222
    bfs::file_status s(bfs::symlink_status(p));
255
    fs::file_status s(fs::symlink_status(p));
223
    SetInt(a, s.type());
256
    SetInt(a, prFileTypeToInt(s.type()));
224
    return errNone;
257
    return errNone;
225
}
258
}
226
259
Lines 232-239 int prFileSize(struct VMGlobals* g, int numArgsPushed) { Link Here
232
    if (error != errNone)
265
    if (error != errNone)
233
        return error;
266
        return error;
234
267
235
    const bfs::path& p = SC_Codecvt::utf8_str_to_path(filename);
268
    const fs::path& p = SC_Codecvt::utf8_str_to_path(filename);
236
    uintmax_t sz = bfs::file_size(p);
269
    uintmax_t sz = fs::file_size(p);
237
    SetInt(a, sz);
270
    SetInt(a, sz);
238
    return errNone;
271
    return errNone;
239
}
272
}
Lines 261-267 int prFileOpen(struct VMGlobals* g, int numArgsPushed) { Link Here
261
294
262
    memcpy(filename, slotRawString(b)->s, slotRawObject(b)->size);
295
    memcpy(filename, slotRawString(b)->s, slotRawObject(b)->size);
263
    filename[slotRawString(b)->size] = 0;
296
    filename[slotRawString(b)->size] = 0;
264
    const bfs::path& path = SC_Codecvt::utf8_str_to_path(filename);
297
    const fs::path& path = SC_Codecvt::utf8_str_to_path(filename);
265
298
266
    memcpy(mode, slotRawString(c)->s, slotRawObject(c)->size);
299
    memcpy(mode, slotRawString(c)->s, slotRawObject(c)->size);
267
    mode[slotRawString(c)->size] = 0;
300
    mode[slotRawString(c)->size] = 0;
Lines 288-294 int prFileOpen(struct VMGlobals* g, int numArgsPushed) { Link Here
288
        // check if directory exisits
321
        // check if directory exisits
289
        // create a temporary file (somewhere) for a handle
322
        // create a temporary file (somewhere) for a handle
290
        // the file is deleted automatically when closed
323
        // the file is deleted automatically when closed
291
        if (bfs::is_directory(path)) {
324
        if (fs::is_directory(path)) {
292
            int err;
325
            int err;
293
#    ifdef _MSC_VER
326
#    ifdef _MSC_VER
294
            err = tmpfile_s(&file);
327
            err = tmpfile_s(&file);
(-)a/lang/LangPrimSource/PyrPlatformPrim.cpp (-3 / +3 lines)
Lines 34-48 Primitives for platform dependent directories, constants etc. Link Here
34
#    include "Shlobj.h"
34
#    include "Shlobj.h"
35
#endif
35
#endif
36
36
37
#include <boost/filesystem/path.hpp> // path
37
#include <filesystem>
38
#include <boost/predef/architecture.h>
38
#include <boost/predef/architecture.h>
39
39
40
namespace bfs = boost::filesystem;
40
namespace fs = std::filesystem;
41
using DirName = SC_Filesystem::DirName;
41
using DirName = SC_Filesystem::DirName;
42
42
43
static inline int prPlatform_getDirectory(const struct VMGlobals* g, const DirName dirname) {
43
static inline int prPlatform_getDirectory(const struct VMGlobals* g, const DirName dirname) {
44
    PyrSlot* a = g->sp;
44
    PyrSlot* a = g->sp;
45
    const bfs::path& p = SC_Filesystem::instance().getDirectory(dirname);
45
    const fs::path& p = SC_Filesystem::instance().getDirectory(dirname);
46
    PyrString* string = newPyrString(g->gc, SC_Codecvt::path_to_utf8_str(p).c_str(), 0, true);
46
    PyrString* string = newPyrString(g->gc, SC_Codecvt::path_to_utf8_str(p).c_str(), 0, true);
47
    SetObject(a, string);
47
    SetObject(a, string);
48
    return errNone;
48
    return errNone;
(-)a/lang/LangPrimSource/PyrPrimitive.cpp (-5 / +5 lines)
Lines 63-75 Link Here
63
63
64
#include "SCDocPrim.h"
64
#include "SCDocPrim.h"
65
65
66
#include <boost/filesystem/path.hpp> // path
66
#include <filesystem>
67
67
68
#ifdef __clang__
68
#ifdef __clang__
69
#    pragma clang diagnostic ignored "-Warray-bounds"
69
#    pragma clang diagnostic ignored "-Warray-bounds"
70
#endif
70
#endif
71
71
72
namespace bfs = boost::filesystem;
72
namespace fs = std::filesystem;
73
73
74
int yyparse();
74
int yyparse();
75
75
Lines 3580-3586 static int prLanguageConfig_addLibraryPath(struct VMGlobals* g, int numArgsPushe Link Here
3580
    if (error)
3580
    if (error)
3581
        return errWrongType;
3581
        return errWrongType;
3582
3582
3583
    const bfs::path& native_path = SC_Codecvt::utf8_str_to_path(path);
3583
    const fs::path& native_path = SC_Codecvt::utf8_str_to_path(path);
3584
    if (pathType == includePaths)
3584
    if (pathType == includePaths)
3585
        gLanguageConfig->addIncludedDirectory(native_path);
3585
        gLanguageConfig->addIncludedDirectory(native_path);
3586
    else
3586
    else
Lines 3604-3610 static int prLanguageConfig_removeLibraryPath(struct VMGlobals* g, int numArgsPu Link Here
3604
    if (error)
3604
    if (error)
3605
        return errWrongType;
3605
        return errWrongType;
3606
3606
3607
    const bfs::path& native_path = SC_Codecvt::utf8_str_to_path(path);
3607
    const fs::path& native_path = SC_Codecvt::utf8_str_to_path(path);
3608
    if (pathType == includePaths)
3608
    if (pathType == includePaths)
3609
        gLanguageConfig->removeIncludedDirectory(native_path);
3609
        gLanguageConfig->removeIncludedDirectory(native_path);
3610
    else
3610
    else
Lines 3635-3641 static int prLanguageConfig_getCurrentConfigPath(struct VMGlobals* g, int numArg Link Here
3635
3635
3636
static int prLanguageConfig_writeConfigFile(struct VMGlobals* g, int numArgsPushed) {
3636
static int prLanguageConfig_writeConfigFile(struct VMGlobals* g, int numArgsPushed) {
3637
    PyrSlot* fileString = g->sp;
3637
    PyrSlot* fileString = g->sp;
3638
    bfs::path config_path;
3638
    fs::path config_path;
3639
3639
3640
    if (NotNil(fileString)) {
3640
    if (NotNil(fileString)) {
3641
        char path[MAXPATHLEN];
3641
        char path[MAXPATHLEN];
(-)a/lang/LangPrimSource/PyrStringPrim.cpp (-8 / +9 lines)
Lines 45-57 Primitives for String. Link Here
45
#include <boost/regex.hpp>
45
#include <boost/regex.hpp>
46
#include <boost/intrusive/list.hpp>
46
#include <boost/intrusive/list.hpp>
47
#include <boost/intrusive/unordered_set.hpp>
47
#include <boost/intrusive/unordered_set.hpp>
48
#include <boost/filesystem/fstream.hpp> // ifstream
48
49
#include <boost/filesystem/path.hpp> // path
49
#include <fstream>
50
#include <filesystem>
50
51
51
#include <yaml-cpp/yaml.h>
52
#include <yaml-cpp/yaml.h>
52
53
53
using namespace std;
54
using namespace std;
54
namespace bfs = boost::filesystem;
55
namespace fs = std::filesystem;
55
56
56
int prStringAsSymbol(struct VMGlobals* g, int numArgsPushed) {
57
int prStringAsSymbol(struct VMGlobals* g, int numArgsPushed) {
57
    PyrSlot* a;
58
    PyrSlot* a;
Lines 531-539 int prString_PathMatch(struct VMGlobals* g, int numArgsPushed) { Link Here
531
    }
532
    }
532
533
533
    // read all paths into a vector
534
    // read all paths into a vector
534
    std::vector<bfs::path> paths;
535
    std::vector<fs::path> paths;
535
    while (true) {
536
    while (true) {
536
        const bfs::path& matched_path = SC_Filesystem::globNext(glob);
537
        const fs::path& matched_path = SC_Filesystem::globNext(glob);
537
        if (matched_path.empty())
538
        if (matched_path.empty())
538
            break;
539
            break;
539
        else
540
        else
Lines 827-833 int prString_StandardizePath(struct VMGlobals* g, int /* numArgsPushed */) { Link Here
827
    if (err != errNone)
828
    if (err != errNone)
828
        return err;
829
        return err;
829
830
830
    bfs::path p = SC_Codecvt::utf8_str_to_path(ipath);
831
    fs::path p = SC_Codecvt::utf8_str_to_path(ipath);
831
    p = SC_Filesystem::instance().expandTilde(p);
832
    p = SC_Filesystem::instance().expandTilde(p);
832
    bool isAlias;
833
    bool isAlias;
833
    p = SC_Filesystem::resolveIfAlias(p, isAlias);
834
    p = SC_Filesystem::resolveIfAlias(p, isAlias);
Lines 968-975 int prString_ParseYAMLFile(struct VMGlobals* g, int numArgsPushed) { Link Here
968
969
969
    string str((const char*)slotRawString(arg)->s, slotRawString(arg)->size);
970
    string str((const char*)slotRawString(arg)->s, slotRawString(arg)->size);
970
971
971
    const bfs::path& path = SC_Codecvt::utf8_str_to_path(str);
972
    const fs::path& path = SC_Codecvt::utf8_str_to_path(str);
972
    bfs::ifstream fin(path);
973
    std::ifstream fin(path);
973
    YAML::Node doc = YAML::Load(fin);
974
    YAML::Node doc = YAML::Load(fin);
974
    yaml_traverse(g, doc, nullptr, arg);
975
    yaml_traverse(g, doc, nullptr, arg);
975
976
(-)a/lang/LangPrimSource/PyrUnixPrim.cpp (-2 / +3 lines)
Lines 26-31 Link Here
26
#include <cstring>
26
#include <cstring>
27
#include <errno.h>
27
#include <errno.h>
28
#include <signal.h>
28
#include <signal.h>
29
#include <boost/date_time/posix_time/posix_time_io.hpp>
29
#include <tuple>
30
#include <tuple>
30
#include <vector>
31
#include <vector>
Lines 46-52 Primitives for Unix. Link Here
46
46
47
#include "SC_Lock.h"
47
#include "SC_Lock.h"
48
48
49
#include <boost/filesystem.hpp>
49
#include <filesystem>
50
50
51
#ifdef _WIN32
51
#ifdef _WIN32
52
#    include "SC_Win32Utils.h"
52
#    include "SC_Win32Utils.h"
Lines 54-60 Primitives for Unix. Link Here
54
#    include <libgen.h>
54
#    include <libgen.h>
55
#endif
55
#endif
56
56
57
namespace bfs = boost::filesystem;
57
namespace fs = std::filesystem;
58
58
59
extern bool compiledOK;
59
extern bool compiledOK;
60
PyrSymbol* s_unixCmdAction;
60
PyrSymbol* s_unixCmdAction;
(-)a/lang/LangSource/PyrLexer.cpp (-35 / +34 lines)
Lines 36-44 Link Here
36
#    include <sys/param.h>
36
#    include <sys/param.h>
37
#endif
37
#endif
38
38
39
#include <boost/filesystem/path.hpp>
39
#include <filesystem>
40
#include <boost/filesystem/operations.hpp>
40
#include <fstream>
41
#include "boost_string_file.hpp"
42
41
43
#include "PyrParseNode.h"
42
#include "PyrParseNode.h"
44
#include "Bison/lang11d_tab.h"
43
#include "Bison/lang11d_tab.h"
Lines 84-95 int gNumCompiledFiles; Link Here
84
thisProcess.interpreter.executeFile("Macintosh HD:score").size.postln;
83
thisProcess.interpreter.executeFile("Macintosh HD:score").size.postln;
85
*/
84
*/
86
85
87
namespace bfs = boost::filesystem;
86
namespace fs = std::filesystem;
88
using DirName = SC_Filesystem::DirName;
87
using DirName = SC_Filesystem::DirName;
89
88
90
PyrSymbol* gCompilingFileSym = nullptr;
89
PyrSymbol* gCompilingFileSym = nullptr;
91
VMGlobals* gCompilingVMGlobals = nullptr;
90
VMGlobals* gCompilingVMGlobals = nullptr;
92
static bfs::path gCompileDir;
91
static fs::path gCompileDir;
93
92
94
//#define DEBUGLEX 1
93
//#define DEBUGLEX 1
95
bool gDebugLexer = false;
94
bool gDebugLexer = false;
Lines 102-108 int lastClosedFuncCharNo = 0; Link Here
102
101
103
const char* binopchars = "!@%&*-+=|<>?/";
102
const char* binopchars = "!@%&*-+=|<>?/";
104
char yytext[MAXYYLEN];
103
char yytext[MAXYYLEN];
105
bfs::path currfilename;
104
fs::path currfilename;
106
std::string printingCurrfilename; // for error reporting
105
std::string printingCurrfilename; // for error reporting
107
106
108
int yylen;
107
int yylen;
Lines 122-128 int textpos; Link Here
122
int errLineOffset, errCharPosOffset;
121
int errLineOffset, errCharPosOffset;
123
int parseFailed = 0;
122
int parseFailed = 0;
124
bool compiledOK = false;
123
bool compiledOK = false;
125
std::set<bfs::path> compiledDirectories;
124
std::set<fs::path> compiledDirectories;
126
125
127
/* so the text editor's dumb paren matching will work */
126
/* so the text editor's dumb paren matching will work */
128
#define OPENPAREN '('
127
#define OPENPAREN '('
Lines 170-187 double sc_strtof(const char* str, int n, int base) { Link Here
170
    return z;
169
    return z;
171
}
170
}
172
171
173
bool startLexer(PyrSymbol* fileSym, const bfs::path& p, int startPos, int endPos, int lineOffset);
172
bool startLexer(PyrSymbol* fileSym, const fs::path& p, int startPos, int endPos, int lineOffset);
174
bool startLexer(PyrSymbol* fileSym, const bfs::path& p, int startPos, int endPos, int lineOffset) {
173
bool startLexer(PyrSymbol* fileSym, const fs::path& p, int startPos, int endPos, int lineOffset) {
175
    const char* filename = fileSym->name;
174
    const char* filename = fileSym->name;
176
175
177
    textlen = -1;
176
    textlen = -1;
178
177
179
    if (!fileSym->u.source) {
178
    if (!fileSym->u.source) {
180
        try {
179
        try {
181
            bfs::ifstream file;
180
            std::ifstream file;
182
            file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
181
            file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
183
            file.open(p, std::ios_base::binary);
182
            file.open(p, std::ios_base::binary);
184
            size_t sz = bfs::file_size(p);
183
            size_t sz = fs::file_size(p);
185
184
186
            text = (char*)pyr_pool_compile->Alloc((sz + 1) * sizeof(char));
185
            text = (char*)pyr_pool_compile->Alloc((sz + 1) * sizeof(char));
187
            MEMFAIL(text);
186
            MEMFAIL(text);
Lines 225-231 bool startLexer(PyrSymbol* fileSym, const bfs::path& p, int startPos, int endPos Link Here
225
    zzval = 0;
224
    zzval = 0;
226
    parseFailed = 0;
225
    parseFailed = 0;
227
    lexCmdLine = 0;
226
    lexCmdLine = 0;
228
    currfilename = bfs::path(filename);
227
    currfilename = fs::path(filename);
229
    printingCurrfilename = "file '" + SC_Codecvt::path_to_utf8_str(currfilename) + "'";
228
    printingCurrfilename = "file '" + SC_Codecvt::path_to_utf8_str(currfilename) + "'";
230
    maxlinestarts = 1000;
229
    maxlinestarts = 1000;
231
    linestarts = (int*)pyr_pool_compile->Alloc(maxlinestarts * sizeof(int*));
230
    linestarts = (int*)pyr_pool_compile->Alloc(maxlinestarts * sizeof(int*));
Lines 261-267 void startLexerCmdLine(char* textbuf, int textbuflen) { Link Here
261
    zzval = 0;
260
    zzval = 0;
262
    parseFailed = 0;
261
    parseFailed = 0;
263
    lexCmdLine = 1;
262
    lexCmdLine = 1;
264
    currfilename = bfs::path("interpreted text");
263
    currfilename = fs::path("interpreted text");
265
    printingCurrfilename = currfilename.string();
264
    printingCurrfilename = currfilename.string();
266
    maxlinestarts = 1000;
265
    maxlinestarts = 1000;
267
    linestarts = (int*)pyr_pool_compile->Alloc(maxlinestarts * sizeof(int*));
266
    linestarts = (int*)pyr_pool_compile->Alloc(maxlinestarts * sizeof(int*));
Lines 1721-1727 void compileClass(PyrSymbol* fileSym, int startPos, int endPos, int lineOffset) Link Here
1721
    gCompilingVMGlobals = nullptr;
1720
    gCompilingVMGlobals = nullptr;
1722
    gRootParseNode = nullptr;
1721
    gRootParseNode = nullptr;
1723
    initParserPool();
1722
    initParserPool();
1724
    if (startLexer(fileSym, bfs::path(), startPos, endPos, lineOffset)) {
1723
    if (startLexer(fileSym, fs::path(), startPos, endPos, lineOffset)) {
1725
        // postfl("->Parsing %s\n", fileSym->name); fflush(stdout);
1724
        // postfl("->Parsing %s\n", fileSym->name); fflush(stdout);
1726
        parseFailed = yyparse();
1725
        parseFailed = yyparse();
1727
        // postfl("<-Parsing %s %d\n", fileSym->name, parseFailed); fflush(stdout);
1726
        // postfl("<-Parsing %s %d\n", fileSym->name, parseFailed); fflush(stdout);
Lines 1733-1739 void compileClass(PyrSymbol* fileSym, int startPos, int endPos, int lineOffset) Link Here
1733
            // postfl("done compiling\n");fflush(stdout);
1732
            // postfl("done compiling\n");fflush(stdout);
1734
        } else {
1733
        } else {
1735
            compileErrors++;
1734
            compileErrors++;
1736
            bfs::path pathname(fileSym->name);
1735
            fs::path pathname(fileSym->name);
1737
            error("file '%s' parse failed\n", SC_Codecvt::path_to_utf8_str(pathname).c_str());
1736
            error("file '%s' parse failed\n", SC_Codecvt::path_to_utf8_str(pathname).c_str());
1738
            postfl("error parsing\n");
1737
            postfl("error parsing\n");
1739
        }
1738
        }
Lines 1942-1948 void finiPassOne() { Link Here
1942
/**
1941
/**
1943
 * \brief \c true if \c dir is one of the language config's default classlib directories
1942
 * \brief \c true if \c dir is one of the language config's default classlib directories
1944
 */
1943
 */
1945
static bool isDefaultClassLibraryDirectory(const bfs::path& dir) {
1944
static bool isDefaultClassLibraryDirectory(const fs::path& dir) {
1946
    auto const& defaultDirs = gLanguageConfig->defaultClassLibraryDirectories();
1945
    auto const& defaultDirs = gLanguageConfig->defaultClassLibraryDirectories();
1947
    auto const iter = std::find(defaultDirs.begin(), defaultDirs.end(), dir);
1946
    auto const iter = std::find(defaultDirs.begin(), defaultDirs.end(), dir);
1948
    return iter != defaultDirs.end();
1947
    return iter != defaultDirs.end();
Lines 1955-1964 static bool isDefaultClassLibraryDirectory(const bfs::path& dir) { Link Here
1955
 * try to create it, silently ignoring failure (most likely from permissions failure).
1954
 * try to create it, silently ignoring failure (most likely from permissions failure).
1956
 * Otherwise, warn the user to help catch mistyped/missing directory names. See #3468.
1955
 * Otherwise, warn the user to help catch mistyped/missing directory names. See #3468.
1957
 */
1956
 */
1958
static void passOne_HandleMissingDirectory(const bfs::path& dir) {
1957
static void passOne_HandleMissingDirectory(const fs::path& dir) {
1959
    if (isDefaultClassLibraryDirectory(dir)) {
1958
    if (isDefaultClassLibraryDirectory(dir)) {
1960
        boost::system::error_code ec {};
1959
        std::error_code ec {};
1961
        bfs::create_directories(dir, ec);
1960
        fs::create_directories(dir, ec);
1962
    } else {
1961
    } else {
1963
        post("WARNING: Could not open directory: '%s'\n"
1962
        post("WARNING: Could not open directory: '%s'\n"
1964
             "\tTo resolve this, either create the directory or remove it from your compilation paths.\n\n",
1963
             "\tTo resolve this, either create the directory or remove it from your compilation paths.\n\n",
Lines 1966-1972 static void passOne_HandleMissingDirectory(const bfs::path& dir) { Link Here
1966
    }
1965
    }
1967
}
1966
}
1968
1967
1969
bfs::path relativeToCompileDir(const bfs::path& p) { return bfs::relative(p, gCompileDir); }
1968
fs::path relativeToCompileDir(const fs::path& p) { return fs::relative(p, gCompileDir); }
1970
1969
1971
/** \brief Determines whether the directory should be skipped during compilation.
1970
/** \brief Determines whether the directory should be skipped during compilation.
1972
 *
1971
 *
Lines 1976-1982 bfs::path relativeToCompileDir(const bfs::path& p) { return bfs::relative(p, gCo Link Here
1976
 * - the language configuration says this path is excluded
1975
 * - the language configuration says this path is excluded
1977
 * - SC_Filesystem::shouldNotCompileDirectory(dir) returns `true`
1976
 * - SC_Filesystem::shouldNotCompileDirectory(dir) returns `true`
1978
 */
1977
 */
1979
static bool passOne_ShouldSkipDirectory(const bfs::path& dir) {
1978
static bool passOne_ShouldSkipDirectory(const fs::path& dir) {
1980
    return (compiledDirectories.find(dir) != compiledDirectories.end())
1979
    return (compiledDirectories.find(dir) != compiledDirectories.end())
1981
        || (gLanguageConfig && gLanguageConfig->pathIsExcluded(dir))
1980
        || (gLanguageConfig && gLanguageConfig->pathIsExcluded(dir))
1982
        || (SC_Filesystem::instance().shouldNotCompileDirectory(dir));
1981
        || (SC_Filesystem::instance().shouldNotCompileDirectory(dir));
Lines 2003-2026 static bool passOne_ShouldSkipDirectory(const bfs::path& dir) { Link Here
2003
 * \returns `true` if processing was successful, `false` if it failed.
2002
 * \returns `true` if processing was successful, `false` if it failed.
2004
 *   See above for what constitutes success and failure conditions.
2003
 *   See above for what constitutes success and failure conditions.
2005
 */
2004
 */
2006
static bool passOne_ProcessDir(const bfs::path& dir) {
2005
static bool passOne_ProcessDir(const fs::path& dir) {
2007
    // Prefer non-throwing versions of filesystem functions, since they are actually not unexpected
2006
    // Prefer non-throwing versions of filesystem functions, since they are actually not unexpected
2008
    // and because it's faster to use error codes.
2007
    // and because it's faster to use error codes.
2009
    boost::system::error_code ec;
2008
    std::error_code ec;
2010
2009
2011
    // Perform tilde expansion on incoming dir.
2010
    // Perform tilde expansion on incoming dir.
2012
    const bfs::path expdir = SC_Filesystem::instance().expandTilde(dir);
2011
    const fs::path expdir = SC_Filesystem::instance().expandTilde(dir);
2013
2012
2014
    // Using a recursive_directory_iterator is much faster than actually calling this function
2013
    // Using a recursive_directory_iterator is much faster than actually calling this function
2015
    // recursively. Speedup from the switch was about 1.5x. _Do_ recurse on symlinks.
2014
    // recursively. Speedup from the switch was about 1.5x. _Do_ recurse on symlinks.
2016
    bfs::recursive_directory_iterator rditer(expdir, bfs::symlink_option::recurse, ec);
2015
    fs::recursive_directory_iterator rditer(expdir, fs::directory_options::follow_directory_symlink, ec);
2017
2016
2018
    // Check preconditions: are we able to access the file, and should we compile it according to
2017
    // Check preconditions: are we able to access the file, and should we compile it according to
2019
    // the language configuration?
2018
    // the language configuration?
2020
    if (ec) {
2019
    if (ec) {
2021
        // If we got an error, post a warning if it was because the target wasn't found, and return success.
2020
        // If we got an error, post a warning if it was because the target wasn't found, and return success.
2022
        // Otherwise, post the error and fail.
2021
        // Otherwise, post the error and fail.
2023
        if (ec.default_error_condition().value() == boost::system::errc::no_such_file_or_directory) {
2022
        if (ec.default_error_condition() == std::errc::no_such_file_or_directory) {
2024
            passOne_HandleMissingDirectory(expdir);
2023
            passOne_HandleMissingDirectory(expdir);
2025
            return true;
2024
            return true;
2026
        } else {
2025
        } else {
Lines 2042-2055 static bool passOne_ProcessDir(const bfs::path& dir) { Link Here
2042
2041
2043
    // Invariant: we have processed (or begun to process) every directory or file already
2042
    // Invariant: we have processed (or begun to process) every directory or file already
2044
    // touched by the iterator.
2043
    // touched by the iterator.
2045
    while (rditer != bfs::end(rditer)) {
2044
    while (rditer != fs::end(rditer)) {
2046
        const bfs::path path = *rditer;
2045
        const fs::path path = *rditer;
2047
2046
2048
        // If the file is a directory, perform the same checks as above to see if we should
2047
        // If the file is a directory, perform the same checks as above to see if we should
2049
        // skip compilation on it.
2048
        // skip compilation on it.
2050
        if (bfs::is_directory(path)) {
2049
        if (fs::is_directory(path)) {
2051
            if (passOne_ShouldSkipDirectory(path)) {
2050
            if (passOne_ShouldSkipDirectory(path)) {
2052
                rditer.no_push(); // don't "push" into the next level of the hierarchy
2051
                rditer.disable_recursion_pending(); // don't "push" into the next level of the hierarchy
2053
            } else {
2052
            } else {
2054
                // Mark this directory as compiled.
2053
                // Mark this directory as compiled.
2055
                // By not calling no_push(), we allow the iterator to enter the directory
2054
                // By not calling no_push(), we allow the iterator to enter the directory
Lines 2062-2069 static bool passOne_ProcessDir(const bfs::path& dir) { Link Here
2062
            // - resolution failed: returns empty path: let the user know
2061
            // - resolution failed: returns empty path: let the user know
2063
            // - it was not an alias, or was an alias that wasn't a directory: try to process it as a source file
2062
            // - it was not an alias, or was an alias that wasn't a directory: try to process it as a source file
2064
            bool isAlias = false;
2063
            bool isAlias = false;
2065
            const bfs::path& respath = SC_Filesystem::resolveIfAlias(path, isAlias);
2064
            const fs::path& respath = SC_Filesystem::resolveIfAlias(path, isAlias);
2066
            if (isAlias && bfs::is_directory(respath)) {
2065
            if (isAlias && fs::is_directory(respath)) {
2067
                // If the resolved alias is a directory, recurse on it.
2066
                // If the resolved alias is a directory, recurse on it.
2068
                if (!passOne_ProcessDir(respath)) {
2067
                if (!passOne_ProcessDir(respath)) {
2069
                    return false;
2068
                    return false;
Lines 2095-2102 bool passOne() { Link Here
2095
}
2094
}
2096
2095
2097
/// True if file doesn't begin with '.', and ends with either '.sc' or '.rtf'
2096
/// True if file doesn't begin with '.', and ends with either '.sc' or '.rtf'
2098
bool isValidSourceFileName(const bfs::path& path) {
2097
bool isValidSourceFileName(const fs::path& path) {
2099
    const bfs::path& ext = path.extension();
2098
    const fs::path& ext = path.extension();
2100
    return path.filename().c_str()[0] != '.' && // must not be hidden file
2099
    return path.filename().c_str()[0] != '.' && // must not be hidden file
2101
        ((ext == ".sc") || (ext == ".rtf" && path.stem().extension() == ".sc"));
2100
        ((ext == ".sc") || (ext == ".rtf" && path.stem().extension() == ".sc"));
2102
}
2101
}
Lines 2110-2116 bool isValidSourceFileName(const bfs::path& path) { Link Here
2110
 * \returns Whether parsing was successful. The only failure condition occurs
2109
 * \returns Whether parsing was successful. The only failure condition occurs
2111
 * when the file can't be opened.
2110
 * when the file can't be opened.
2112
 */
2111
 */
2113
bool passOne_ProcessOneFile(const bfs::path& path) {
2112
bool passOne_ProcessOneFile(const fs::path& path) {
2114
    bool success = true;
2113
    bool success = true;
2115
2114
2116
    const std::string path_str = SC_Codecvt::path_to_utf8_str(path);
2115
    const std::string path_str = SC_Codecvt::path_to_utf8_str(path);
(-)a/lang/LangSource/PyrLexer.h (-4 / +4 lines)
Lines 25-31 Link Here
25
#include "PyrSymbol.h"
25
#include "PyrSymbol.h"
26
#include "SC_Export.h"
26
#include "SC_Export.h"
27
#include "SCBase.h"
27
#include "SCBase.h"
28
#include <boost/filesystem/path.hpp>
28
#include <filesystem>
29
29
30
extern int charno, lineno, linepos;
30
extern int charno, lineno, linepos;
31
extern int* linestarts;
31
extern int* linestarts;
Lines 78-87 void startLexerCmdLine(char* textbuf, int textbuflen); Link Here
78
int yylex();
78
int yylex();
79
void yyerror(const char* s);
79
void yyerror(const char* s);
80
void fatal();
80
void fatal();
81
bool isValidSourceFileName(const boost::filesystem::path& path);
81
bool isValidSourceFileName(const std::filesystem::path& path);
82
bool passOne_ProcessOneFile(const boost::filesystem::path& path);
82
bool passOne_ProcessOneFile(const std::filesystem::path& path);
83
83
84
boost::filesystem::path relativeToCompileDir(const boost::filesystem::path&);
84
std::filesystem::path relativeToCompileDir(const std::filesystem::path&);
85
85
86
void initLexer();
86
void initLexer();
87
87
(-)a/lang/LangSource/PyrParseNode.cpp (-2 / +2 lines)
Lines 41-47 Link Here
41
#include "SC_LanguageConfig.hpp"
41
#include "SC_LanguageConfig.hpp"
42
#include "SC_Codecvt.hpp"
42
#include "SC_Codecvt.hpp"
43
43
44
namespace bfs = boost::filesystem;
44
namespace fs = std::filesystem;
45
45
46
AdvancingAllocPool gParseNodePool;
46
AdvancingAllocPool gParseNodePool;
47
47
Lines 289-295 PyrClassExtNode* newPyrClassExtNode(PyrSlotNode* className, PyrMethodNode* metho Link Here
289
void PyrClassExtNode::compile(PyrSlot* result) {
289
void PyrClassExtNode::compile(PyrSlot* result) {
290
    PyrClass* classobj = slotRawSymbol(&mClassName->mSlot)->u.classobj;
290
    PyrClass* classobj = slotRawSymbol(&mClassName->mSlot)->u.classobj;
291
    if (!classobj) {
291
    if (!classobj) {
292
        const bfs::path relpath = relativeToCompileDir(bfs::path(gCompilingFileSym->name));
292
        const fs::path relpath = relativeToCompileDir(fs::path(gCompilingFileSym->name));
293
        error("Class extension for nonexistent class '%s'\n     In file:'%s'\n",
293
        error("Class extension for nonexistent class '%s'\n     In file:'%s'\n",
294
              slotRawSymbol(&mClassName->mSlot)->name, SC_Codecvt::path_to_utf8_str(relpath).c_str());
294
              slotRawSymbol(&mClassName->mSlot)->name, SC_Codecvt::path_to_utf8_str(relpath).c_str());
295
        return;
295
        return;
(-)a/lang/LangSource/SC_LanguageConfig.cpp (-13 / +13 lines)
Lines 29-36 Link Here
29
#include <algorithm> // std::find
29
#include <algorithm> // std::find
30
#include <functional> // std::function
30
#include <functional> // std::function
31
31
32
#include <boost/filesystem/operations.hpp> // exists (, canonical?)
32
#include <filesystem>
33
#include <boost/filesystem/fstream.hpp> // ofstream
33
#include <fstream>
34
#include <yaml-cpp/yaml.h> // YAML
34
#include <yaml-cpp/yaml.h> // YAML
35
35
36
SC_LanguageConfig::Path SC_LanguageConfig::gConfigFile;
36
SC_LanguageConfig::Path SC_LanguageConfig::gConfigFile;
Lines 46-52 const char* SCLANG_YAML_CONFIG_FILENAME = "sclang_conf.yaml"; Link Here
46
static const char* EXCLUDE_DEFAULT_PATHS = "excludeDefaultPaths";
46
static const char* EXCLUDE_DEFAULT_PATHS = "excludeDefaultPaths";
47
47
48
using DirName = SC_Filesystem::DirName;
48
using DirName = SC_Filesystem::DirName;
49
namespace bfs = boost::filesystem;
49
namespace fs = std::filesystem;
50
50
51
void SC_LanguageConfig::setExcludeDefaultPaths(bool value) {
51
void SC_LanguageConfig::setExcludeDefaultPaths(bool value) {
52
    if (mExcludeDefaultPaths != value) {
52
    if (mExcludeDefaultPaths != value) {
Lines 104-116 bool SC_LanguageConfig::removeIncludedDirectory(const Path& path) { return remov Link Here
104
bool SC_LanguageConfig::removeExcludedDirectory(const Path& path) { return removePath(mExcludedDirectories, path); }
104
bool SC_LanguageConfig::removeExcludedDirectory(const Path& path) { return removePath(mExcludedDirectories, path); }
105
105
106
static void processPathList(const char* nodeName, YAML::Node& doc,
106
static void processPathList(const char* nodeName, YAML::Node& doc,
107
                            const std::function<void(const boost::filesystem::path&)>& func) {
107
                            const std::function<void(const std::filesystem::path&)>& func) {
108
    const YAML::Node& items = doc[nodeName];
108
    const YAML::Node& items = doc[nodeName];
109
    if (items && items.IsSequence()) {
109
    if (items && items.IsSequence()) {
110
        for (auto const& item : items) {
110
        for (auto const& item : items) {
111
            const std::string& path = item.as<std::string>("");
111
            const std::string& path = item.as<std::string>("");
112
            if (!path.empty()) {
112
            if (!path.empty()) {
113
                const boost::filesystem::path& native_path = SC_Codecvt::utf8_str_to_path(path);
113
                const std::filesystem::path& native_path = SC_Codecvt::utf8_str_to_path(path);
114
                func(native_path);
114
                func(native_path);
115
            }
115
            }
116
        }
116
        }
Lines 138-144 bool SC_LanguageConfig::readLibraryConfigYAML(const Path& fileName, bool standal Link Here
138
138
139
    using namespace YAML;
139
    using namespace YAML;
140
    try {
140
    try {
141
        bfs::ifstream fin(fileName);
141
        std::ifstream fin(fileName);
142
        Node doc = Load(fin);
142
        Node doc = Load(fin);
143
        if (doc) {
143
        if (doc) {
144
            processBool(
144
            processBool(
Lines 160-166 bool SC_LanguageConfig::readLibraryConfigYAML(const Path& fileName, bool standal Link Here
160
}
160
}
161
161
162
bool SC_LanguageConfig::writeLibraryConfigYAML(const Path& fileName) {
162
bool SC_LanguageConfig::writeLibraryConfigYAML(const Path& fileName) {
163
    if (!bfs::exists(fileName.parent_path()))
163
    if (!fs::exists(fileName.parent_path()))
164
        return false;
164
        return false;
165
165
166
    using namespace YAML;
166
    using namespace YAML;
Lines 174-186 bool SC_LanguageConfig::writeLibraryConfigYAML(const Path& fileName) { Link Here
174
174
175
    out << Key << INCLUDE_PATHS;
175
    out << Key << INCLUDE_PATHS;
176
    out << Value << BeginSeq;
176
    out << Value << BeginSeq;
177
    for (const bfs::path& it : gLanguageConfig->mIncludedDirectories)
177
    for (const fs::path& it : gLanguageConfig->mIncludedDirectories)
178
        out << SC_Codecvt::path_to_utf8_str(it);
178
        out << SC_Codecvt::path_to_utf8_str(it);
179
    out << EndSeq;
179
    out << EndSeq;
180
180
181
    out << Key << EXCLUDE_PATHS;
181
    out << Key << EXCLUDE_PATHS;
182
    out << Value << BeginSeq;
182
    out << Value << BeginSeq;
183
    for (const bfs::path& it : gLanguageConfig->mExcludedDirectories)
183
    for (const fs::path& it : gLanguageConfig->mExcludedDirectories)
184
        out << SC_Codecvt::path_to_utf8_str(it);
184
        out << SC_Codecvt::path_to_utf8_str(it);
185
    out << EndSeq;
185
    out << EndSeq;
186
186
Lines 192-198 bool SC_LanguageConfig::writeLibraryConfigYAML(const Path& fileName) { Link Here
192
192
193
    out << EndMap;
193
    out << EndMap;
194
194
195
    bfs::ofstream fout(fileName);
195
    std::ofstream fout(fileName);
196
    fout << out.c_str();
196
    fout << out.c_str();
197
    return fout.good();
197
    return fout.good();
198
}
198
}
Lines 207-226 bool SC_LanguageConfig::defaultLibraryConfig(bool standalone) { Link Here
207
bool SC_LanguageConfig::readLibraryConfig(bool standalone) {
207
bool SC_LanguageConfig::readLibraryConfig(bool standalone) {
208
    bool configured = false;
208
    bool configured = false;
209
209
210
    if (bfs::exists(gConfigFile))
210
    if (fs::exists(gConfigFile))
211
        configured = readLibraryConfigYAML(gConfigFile, standalone);
211
        configured = readLibraryConfigYAML(gConfigFile, standalone);
212
212
213
    if (!configured && !standalone) {
213
    if (!configured && !standalone) {
214
        const Path userYamlConfigFile =
214
        const Path userYamlConfigFile =
215
            SC_Filesystem::instance().getDirectory(DirName::UserConfig) / SCLANG_YAML_CONFIG_FILENAME;
215
            SC_Filesystem::instance().getDirectory(DirName::UserConfig) / SCLANG_YAML_CONFIG_FILENAME;
216
216
217
        if (bfs::exists(userYamlConfigFile))
217
        if (fs::exists(userYamlConfigFile))
218
            configured = readLibraryConfigYAML(userYamlConfigFile, standalone);
218
            configured = readLibraryConfigYAML(userYamlConfigFile, standalone);
219
219
220
        if (!configured) {
220
        if (!configured) {
221
            const Path globalYamlConfigFile = Path("/etc") / SCLANG_YAML_CONFIG_FILENAME;
221
            const Path globalYamlConfigFile = Path("/etc") / SCLANG_YAML_CONFIG_FILENAME;
222
222
223
            if (bfs::exists(globalYamlConfigFile))
223
            if (fs::exists(globalYamlConfigFile))
224
                configured = readLibraryConfigYAML(globalYamlConfigFile, standalone);
224
                configured = readLibraryConfigYAML(globalYamlConfigFile, standalone);
225
        }
225
        }
226
    }
226
    }
(-)a/lang/LangSource/SC_LanguageConfig.hpp (-2 / +2 lines)
Lines 25-31 Link Here
25
25
26
#include <vector>
26
#include <vector>
27
#include <string>
27
#include <string>
28
#include <boost/filesystem/path.hpp>
28
#include <filesystem>
29
29
30
class SC_LanguageConfig;
30
class SC_LanguageConfig;
31
extern SC_LanguageConfig* gLanguageConfig;
31
extern SC_LanguageConfig* gLanguageConfig;
Lines 42-48 extern const char* SCLANG_YAML_CONFIG_FILENAME; Link Here
42
 */
42
 */
43
class SC_LanguageConfig {
43
class SC_LanguageConfig {
44
public:
44
public:
45
    typedef boost::filesystem::path Path;
45
    typedef std::filesystem::path Path;
46
    typedef std::vector<Path> DirVector;
46
    typedef std::vector<Path> DirVector;
47
47
48
    const DirVector& includedDirectories() const { return mIncludedDirectories; }
48
    const DirVector& includedDirectories() const { return mIncludedDirectories; }
(-)a/lang/LangSource/SC_TerminalClient.cpp (-3 / +2 lines)
Lines 61-67 Link Here
61
#include "SC_LanguageConfig.hpp"
61
#include "SC_LanguageConfig.hpp"
62
#include "SC_Version.hpp"
62
#include "SC_Version.hpp"
63
63
64
#include <boost/filesystem/operations.hpp>
64
#include <filesystem>
65
65
66
using namespace boost::placeholders;
66
using namespace boost::placeholders;
67
67
Lines 255-262 int SC_TerminalClient::run(int argc, char** argv) { Link Here
255
255
256
    // Create config directory so that it can be used by Quarks, etc. See #2919.
256
    // Create config directory so that it can be used by Quarks, etc. See #2919.
257
    if (!opt.mStandalone && !opt.mLibraryConfigFile)
257
    if (!opt.mStandalone && !opt.mLibraryConfigFile)
258
        boost::filesystem::create_directories(
258
        std::filesystem::create_directories(SC_Filesystem::instance().getDirectory(SC_Filesystem::DirName::UserConfig));
259
            SC_Filesystem::instance().getDirectory(SC_Filesystem::DirName::UserConfig));
260
259
261
    // startup library
260
    // startup library
262
    compileLibrary(opt.mStandalone);
261
    compileLibrary(opt.mStandalone);
(-)a/server/scsynth/SC_GraphDef.cpp (-14 / +23 lines)
Lines 45-54 Link Here
45
#include <stdexcept>
45
#include <stdexcept>
46
#include <string>
46
#include <string>
47
47
48
#include <boost/filesystem/operations.hpp> // recursive_directory_iterator
48
#include <filesystem>
49
#include "boost_string_file.hpp" // load_string_file
49
#include <fstream>
50
50
51
namespace bfs = boost::filesystem;
51
namespace fs = std::filesystem;
52
52
53
extern Malloc gMalloc;
53
extern Malloc gMalloc;
54
54
Lines 601-607 GraphDef* GraphDef_LoadGlob(World* inWorld, const char* pattern, GraphDef* inLis Link Here
601
    if (!glob)
601
    if (!glob)
602
        return inList;
602
        return inList;
603
603
604
    bfs::path path;
604
    fs::path path;
605
    while (!(path = SC_Filesystem::globNext(glob)).empty()) {
605
    while (!(path = SC_Filesystem::globNext(glob)).empty()) {
606
        if (path.extension() == ".scsyndef") {
606
        if (path.extension() == ".scsyndef") {
607
            inList = GraphDef_Load(inWorld, path, inList);
607
            inList = GraphDef_Load(inWorld, path, inList);
Lines 614-623 GraphDef* GraphDef_LoadGlob(World* inWorld, const char* pattern, GraphDef* inLis Link Here
614
    return inList;
614
    return inList;
615
}
615
}
616
616
617
GraphDef* GraphDef_Load(World* inWorld, const bfs::path& path, GraphDef* inList) {
617
std::string load_file(const std::filesystem::path& file_path) {
618
    std::ifstream file(file_path);
619
    if (!file.is_open()) {
620
        throw std::runtime_error("Could not open file: " + file_path.string());
621
    }
622
    std::stringstream buffer;
623
    buffer << file.rdbuf();
624
    return buffer.str();
625
}
626
627
GraphDef* GraphDef_Load(World* inWorld, const fs::path& path, GraphDef* inList) {
618
    try {
628
    try {
619
        std::string file_contents;
629
        std::string file_contents = load_file(path);
620
        bfs::load_string_file(path, file_contents);
621
        inList = GraphDefLib_Read(inWorld, &file_contents[0], inList);
630
        inList = GraphDefLib_Read(inWorld, &file_contents[0], inList);
622
    } catch (const std::exception& e) {
631
    } catch (const std::exception& e) {
623
        scprintf("exception in GraphDef_Load: %s\n", e.what());
632
        scprintf("exception in GraphDef_Load: %s\n", e.what());
Lines 632-652 GraphDef* GraphDef_Load(World* inWorld, const bfs::path& path, GraphDef* inList) Link Here
632
    return inList;
641
    return inList;
633
}
642
}
634
643
635
GraphDef* GraphDef_LoadDir(World* inWorld, const bfs::path& dirname, GraphDef* inList) {
644
GraphDef* GraphDef_LoadDir(World* inWorld, const fs::path& dirname, GraphDef* inList) {
636
    boost::system::error_code ec;
645
    std::error_code ec;
637
    bfs::recursive_directory_iterator rditer(dirname, bfs::symlink_option::recurse, ec);
646
    fs::recursive_directory_iterator rditer(dirname, fs::directory_options::follow_directory_symlink, ec);
638
647
639
    if (ec) {
648
    if (ec) {
640
        scprintf("*** ERROR: open directory failed '%s'\n", SC_Codecvt::path_to_utf8_str(dirname).c_str());
649
        scprintf("*** ERROR: open directory failed '%s'\n", SC_Codecvt::path_to_utf8_str(dirname).c_str());
641
        return inList;
650
        return inList;
642
    }
651
    }
643
652
644
    while (rditer != bfs::end(rditer)) {
653
    while (rditer != fs::end(rditer)) {
645
        const bfs::path path = *rditer;
654
        const fs::path path = *rditer;
646
655
647
        if (bfs::is_directory(path)) {
656
        if (fs::is_directory(path)) {
648
            if (SC_Filesystem::instance().shouldNotCompileDirectory(path))
657
            if (SC_Filesystem::instance().shouldNotCompileDirectory(path))
649
                rditer.no_push();
658
                rditer.disable_recursion_pending();
650
            else
659
            else
651
                ; // do nothing; recursion will happen automatically
660
                ; // do nothing; recursion will happen automatically
652
        } else if (path.extension() == ".scsyndef") { // ordinary file
661
        } else if (path.extension() == ".scsyndef") { // ordinary file
(-)a/server/scsynth/SC_GraphDef.h (-3 / +3 lines)
Lines 22-28 Link Here
22
22
23
#include "SC_SynthDef.h"
23
#include "SC_SynthDef.h"
24
#include "HashTable.h"
24
#include "HashTable.h"
25
#include <boost/filesystem/path.hpp> // path
25
#include <filesystem>
26
26
27
struct ParamSpec {
27
struct ParamSpec {
28
    int32 mName[kSCNameLen];
28
    int32 mName[kSCNameLen];
Lines 71-78 struct GraphDef { Link Here
71
typedef struct GraphDef GraphDef;
71
typedef struct GraphDef GraphDef;
72
72
73
GraphDef* GraphDef_Recv(World* inWorld, char* buffer, GraphDef* inList);
73
GraphDef* GraphDef_Recv(World* inWorld, char* buffer, GraphDef* inList);
74
GraphDef* GraphDef_Load(struct World* inWorld, const boost::filesystem::path& path, GraphDef* inList);
74
GraphDef* GraphDef_Load(struct World* inWorld, const std::filesystem::path& path, GraphDef* inList);
75
GraphDef* GraphDef_LoadDir(struct World* inWorld, const boost::filesystem::path& path, GraphDef* inList);
75
GraphDef* GraphDef_LoadDir(struct World* inWorld, const std::filesystem::path& path, GraphDef* inList);
76
GraphDef* GraphDef_LoadGlob(World* inWorld, const char* pattern, GraphDef* inList);
76
GraphDef* GraphDef_LoadGlob(World* inWorld, const char* pattern, GraphDef* inList);
77
SCErr GraphDef_Remove(World* inWorld, int32* inName);
77
SCErr GraphDef_Remove(World* inWorld, int32* inName);
78
SCErr GraphDef_DeleteMsg(struct World* inWorld, GraphDef* inDef);
78
SCErr GraphDef_DeleteMsg(struct World* inWorld, GraphDef* inDef);
(-)a/server/scsynth/SC_Lib_Cintf.cpp (-17 / +16 lines)
Lines 44-51 Link Here
44
#    include <sys/param.h>
44
#    include <sys/param.h>
45
#endif // _WIN32
45
#endif // _WIN32
46
46
47
#include <boost/filesystem/path.hpp> // path
47
#include <filesystem>
48
#include <boost/filesystem/operations.hpp> // is_directory
49
48
50
#ifdef __APPLE__
49
#ifdef __APPLE__
51
extern "C" {
50
extern "C" {
Lines 55-61 extern "C" { Link Here
55
char gTempVal;
54
char gTempVal;
56
#endif // __APPLE__
55
#endif // __APPLE__
57
56
58
namespace bfs = boost::filesystem;
57
namespace fs = std::filesystem;
59
58
60
Malloc gMalloc;
59
Malloc gMalloc;
61
HashTable<SC_LibCmd, Malloc>* gCmdLib;
60
HashTable<SC_LibCmd, Malloc>* gCmdLib;
Lines 66-72 extern struct InterfaceTable gInterfaceTable; Link Here
66
SC_LibCmd* gCmdArray[NUMBER_OF_COMMANDS];
65
SC_LibCmd* gCmdArray[NUMBER_OF_COMMANDS];
67
66
68
void initMiscCommands();
67
void initMiscCommands();
69
static bool PlugIn_LoadDir(const bfs::path& dir, bool reportError);
68
static bool PlugIn_LoadDir(const fs::path& dir, bool reportError);
70
std::vector<void*> open_handles;
69
std::vector<void*> open_handles;
71
#ifdef __APPLE__
70
#ifdef __APPLE__
72
void read_section(const struct mach_header* mhp, unsigned long slide, const char* segname, const char* sectname) {
71
void read_section(const struct mach_header* mhp, unsigned long slide, const char* segname, const char* sectname) {
Lines 180-193 void initialize_library(const char* uGensPluginPath) { Link Here
180
    if (loadUGensExtDirs) {
179
    if (loadUGensExtDirs) {
181
#ifdef SC_PLUGIN_DIR
180
#ifdef SC_PLUGIN_DIR
182
        // load globally installed plugins
181
        // load globally installed plugins
183
        if (bfs::is_directory(SC_PLUGIN_DIR)) {
182
        if (fs::is_directory(SC_PLUGIN_DIR)) {
184
            PlugIn_LoadDir(SC_PLUGIN_DIR, true);
183
            PlugIn_LoadDir(SC_PLUGIN_DIR, true);
185
        }
184
        }
186
#endif // SC_PLUGIN_DIR
185
#endif // SC_PLUGIN_DIR
187
       // load default plugin directory
186
       // load default plugin directory
188
        const bfs::path pluginDir = SC_Filesystem::instance().getDirectory(DirName::Resource) / SC_PLUGIN_DIR_NAME;
187
        const fs::path pluginDir = SC_Filesystem::instance().getDirectory(DirName::Resource) / SC_PLUGIN_DIR_NAME;
189
188
190
        if (bfs::is_directory(pluginDir)) {
189
        if (fs::is_directory(pluginDir)) {
191
            PlugIn_LoadDir(pluginDir, true);
190
            PlugIn_LoadDir(pluginDir, true);
192
        }
191
        }
193
    }
192
    }
Lines 195-205 void initialize_library(const char* uGensPluginPath) { Link Here
195
    // get extension directories
194
    // get extension directories
196
    if (loadUGensExtDirs) {
195
    if (loadUGensExtDirs) {
197
        // load system extension plugins
196
        // load system extension plugins
198
        const bfs::path sysExtDir = SC_Filesystem::instance().getDirectory(DirName::SystemExtension);
197
        const fs::path sysExtDir = SC_Filesystem::instance().getDirectory(DirName::SystemExtension);
199
        PlugIn_LoadDir(sysExtDir, false);
198
        PlugIn_LoadDir(sysExtDir, false);
200
199
201
        // load user extension plugins
200
        // load user extension plugins
202
        const bfs::path userExtDir = SC_Filesystem::instance().getDirectory(DirName::UserExtension);
201
        const fs::path userExtDir = SC_Filesystem::instance().getDirectory(DirName::UserExtension);
203
        PlugIn_LoadDir(userExtDir, false);
202
        PlugIn_LoadDir(userExtDir, false);
204
203
205
        // load user plugin directories
204
        // load user plugin directories
Lines 281-287 bool checkServerVersion(void* f, const char* filename) { Link Here
281
    return true;
280
    return true;
282
}
281
}
283
282
284
static bool PlugIn_Load(const bfs::path& filename) {
283
static bool PlugIn_Load(const fs::path& filename) {
285
#ifdef _WIN32
284
#ifdef _WIN32
286
    HINSTANCE hinstance = LoadLibraryW(filename.wstring().c_str());
285
    HINSTANCE hinstance = LoadLibraryW(filename.wstring().c_str());
287
    // here, we have to use a utf-8 version of the string for printing
286
    // here, we have to use a utf-8 version of the string for printing
Lines 365-373 static bool PlugIn_Load(const bfs::path& filename) { Link Here
365
#endif // _WIN32
364
#endif // _WIN32
366
}
365
}
367
366
368
static bool PlugIn_LoadDir(const bfs::path& dir, bool reportError) {
367
static bool PlugIn_LoadDir(const fs::path& dir, bool reportError) {
369
    boost::system::error_code ec;
368
    std::error_code ec;
370
    bfs::recursive_directory_iterator rditer(dir, bfs::symlink_option::recurse, ec);
369
    fs::recursive_directory_iterator rditer(dir, fs::directory_options::follow_directory_symlink, ec);
371
370
372
    if (ec) {
371
    if (ec) {
373
        if (reportError) {
372
        if (reportError) {
Lines 378-389 static bool PlugIn_LoadDir(const bfs::path& dir, bool reportError) { Link Here
378
        return false;
377
        return false;
379
    }
378
    }
380
379
381
    while (rditer != bfs::end(rditer)) {
380
    while (rditer != fs::end(rditer)) {
382
        const bfs::path path = *rditer;
381
        const fs::path path = *rditer;
383
382
384
        if (bfs::is_directory(path)) {
383
        if (fs::is_directory(path)) {
385
            if (SC_Filesystem::instance().shouldNotCompileDirectory(path))
384
            if (SC_Filesystem::instance().shouldNotCompileDirectory(path))
386
                rditer.no_push();
385
                rditer.disable_recursion_pending();
387
            else
386
            else
388
                ; // do nothing; recursion for free
387
                ; // do nothing; recursion for free
389
        } else if (path.extension() == SC_PLUGIN_EXT) {
388
        } else if (path.extension() == SC_PLUGIN_EXT) {
(-)a/server/scsynth/SC_SequencedCommand.cpp (-3 / +2 lines)
Lines 30-37 Link Here
30
#include "../../common/SC_SndFileHelpers.hpp"
30
#include "../../common/SC_SndFileHelpers.hpp"
31
#include "SC_WorldOptions.h"
31
#include "SC_WorldOptions.h"
32
32
33
/* boost headers */
33
#include <filesystem>
34
#include <boost/filesystem.hpp>
35
34
36
const size_t ERR_BUF_SIZE(512);
35
const size_t ERR_BUF_SIZE(512);
37
36
Lines 1407-1413 LoadSynthDefDirCmd::~LoadSynthDefDirCmd() { World_Free(mWorld, mFilename); } Link Here
1407
void LoadSynthDefDirCmd::CallDestructor() { this->~LoadSynthDefDirCmd(); }
1406
void LoadSynthDefDirCmd::CallDestructor() { this->~LoadSynthDefDirCmd(); }
1408
1407
1409
bool LoadSynthDefDirCmd::Stage2() {
1408
bool LoadSynthDefDirCmd::Stage2() {
1410
    if (!boost::filesystem::exists(mFilename)) {
1409
    if (!std::filesystem::exists(mFilename)) {
1411
        char str[ERR_BUF_SIZE];
1410
        char str[ERR_BUF_SIZE];
1412
        snprintf(str, ERR_BUF_SIZE, "Could not load synthdefs. Directory '%s' does not exist\n", mFilename);
1411
        snprintf(str, ERR_BUF_SIZE, "Could not load synthdefs. Directory '%s' does not exist\n", mFilename);
1413
        SendFailure(&mReplyAddress, "/d_loadDir", mFilename);
1412
        SendFailure(&mReplyAddress, "/d_loadDir", mFilename);
(-)a/server/scsynth/SC_World.cpp (-3 / +3 lines)
Lines 75-83 Link Here
75
75
76
#include "server_shm.hpp"
76
#include "server_shm.hpp"
77
77
78
#include <boost/filesystem/path.hpp> // path
78
#include <filesystem>
79
79
80
namespace bfs = boost::filesystem;
80
namespace fs = std::filesystem;
81
81
82
InterfaceTable gInterfaceTable;
82
InterfaceTable gInterfaceTable;
83
PrintFunc gPrint = nullptr;
83
PrintFunc gPrint = nullptr;
Lines 271-277 void World_LoadGraphDefs(World* world) { Link Here
271
            GraphDef_Define(world, list);
271
            GraphDef_Define(world, list);
272
        }
272
        }
273
    } else {
273
    } else {
274
        bfs::path path = SC_Filesystem::instance().getDirectory(DirName::UserAppSupport) / "synthdefs";
274
        fs::path path = SC_Filesystem::instance().getDirectory(DirName::UserAppSupport) / "synthdefs";
275
        if (world->mVerbosity > 0)
275
        if (world->mVerbosity > 0)
276
            scprintf("Loading synthdefs from default path: %s\n", SC_Codecvt::path_to_utf8_str(path).c_str());
276
            scprintf("Loading synthdefs from default path: %s\n", SC_Codecvt::path_to_utf8_str(path).c_str());
277
        list = GraphDef_LoadDir(world, path, list);
277
        list = GraphDef_LoadDir(world, path, list);
(-)a/server/supernova/sc/sc_synth_definition.cpp (-2 / +2 lines)
Lines 19-25 Link Here
19
#include <iostream>
19
#include <iostream>
20
#include <future>
20
#include <future>
21
21
22
#include <boost/filesystem/operations.hpp>
22
#include <filesystem>
23
#include <boost/range/iterator_range.hpp>
23
#include <boost/range/iterator_range.hpp>
24
24
25
#include "sc_synth.hpp"
25
#include "sc_synth.hpp"
Lines 49-55 std::vector<sc_synthdef> sc_read_synthdefs_file(path const& file) { Link Here
49
}
49
}
50
50
51
std::vector<sc_synthdef> sc_read_synthdefs_dir(path const& dir) {
51
std::vector<sc_synthdef> sc_read_synthdefs_dir(path const& dir) {
52
    using namespace boost::filesystem;
52
    using namespace std::filesystem;
53
    using namespace std;
53
    using namespace std;
54
54
55
    typedef vector<sc_synthdef> def_vector;
55
    typedef vector<sc_synthdef> def_vector;
(-)a/server/supernova/sc/sc_synth_definition.hpp (-2 / +2 lines)
Lines 18-24 Link Here
18
18
19
#pragma once
19
#pragma once
20
20
21
#include <boost/filesystem/path.hpp>
21
#include <filesystem>
22
22
23
#include "sc_synthdef.hpp"
23
#include "sc_synthdef.hpp"
24
24
Lines 27-33 Link Here
27
27
28
namespace nova {
28
namespace nova {
29
29
30
using boost::filesystem::path;
30
using std::filesystem::path;
31
31
32
/* read synthdefs from path pattern */
32
/* read synthdefs from path pattern */
33
std::vector<sc_synthdef> sc_read_synthdefs_file(path const& filename);
33
std::vector<sc_synthdef> sc_read_synthdefs_file(path const& filename);
(-)a/server/supernova/sc/sc_synthdef.cpp (-1 / +1 lines)
Lines 137-143 std::vector<sc_synthdef> read_synthdefs(const char* buffer, const char* buffer_e Link Here
137
    return ret;
137
    return ret;
138
}
138
}
139
139
140
std::vector<sc_synthdef> read_synthdef_file(boost::filesystem::path const& filename) {
140
std::vector<sc_synthdef> read_synthdef_file(std::filesystem::path const& filename) {
141
    using namespace std;
141
    using namespace std;
142
142
143
    ifstream stream;
143
    ifstream stream;
(-)a/server/supernova/sc/sc_synthdef.hpp (-2 / +2 lines)
Lines 22-30 Link Here
22
#include <map>
22
#include <map>
23
#include <string>
23
#include <string>
24
#include <vector>
24
#include <vector>
25
#include <filesystem>
25
26
26
#include <boost/align/aligned_allocator.hpp>
27
#include <boost/align/aligned_allocator.hpp>
27
#include <boost/filesystem/path.hpp>
28
28
29
#include "utilities/named_hash_entry.hpp"
29
#include "utilities/named_hash_entry.hpp"
30
30
Lines 134-139 private: Link Here
134
};
134
};
135
135
136
std::vector<sc_synthdef> read_synthdefs(const char* buffer, const char* buffer_end);
136
std::vector<sc_synthdef> read_synthdefs(const char* buffer, const char* buffer_end);
137
std::vector<sc_synthdef> read_synthdef_file(boost::filesystem::path const& filename);
137
std::vector<sc_synthdef> read_synthdef_file(std::filesystem::path const& filename);
138
138
139
} /* namespace nova */
139
} /* namespace nova */
(-)a/server/supernova/sc/sc_ugen_factory.cpp (-5 / +5 lines)
Lines 25-31 Link Here
25
#    include "SC_Win32Utils.h"
25
#    include "SC_Win32Utils.h"
26
#endif
26
#endif
27
27
28
#include <boost/filesystem.hpp>
28
#include <filesystem>
29
29
30
#include "sc_ugen_factory.hpp"
30
#include "sc_ugen_factory.hpp"
31
31
Lines 215-222 bool sc_plugin_container::run_cmd_plugin(World* world, const char* name, struct Link Here
215
}
215
}
216
216
217
217
218
void sc_ugen_factory::load_plugin_folder(boost::filesystem::path const& path) {
218
void sc_ugen_factory::load_plugin_folder(std::filesystem::path const& path) {
219
    using namespace boost::filesystem;
219
    using namespace std::filesystem;
220
220
221
    directory_iterator end;
221
    directory_iterator end;
222
222
Lines 249-255 static bool check_api_version(int (*api_version)(), std::string const& filename) Link Here
249
}
249
}
250
250
251
#ifdef DLOPEN
251
#ifdef DLOPEN
252
void sc_ugen_factory::load_plugin(boost::filesystem::path const& path) {
252
void sc_ugen_factory::load_plugin(std::filesystem::path const& path) {
253
    using namespace std;
253
    using namespace std;
254
254
255
    // Ignore files that don't have the extension of an SC plugin
255
    // Ignore files that don't have the extension of an SC plugin
Lines 305-311 void sc_ugen_factory::close_handles(void) { Link Here
305
305
306
#elif defined(_WIN32)
306
#elif defined(_WIN32)
307
307
308
void sc_ugen_factory::load_plugin(boost::filesystem::path const& path) {
308
void sc_ugen_factory::load_plugin(std::filesystem::path const& path) {
309
    // Ignore files that don't have the extension of an SC plugin
309
    // Ignore files that don't have the extension of an SC plugin
310
    if (path.extension() != SC_PLUGIN_EXT) {
310
    if (path.extension() != SC_PLUGIN_EXT) {
311
        return;
311
        return;
(-)a/server/supernova/sc/sc_ugen_factory.hpp (-2 / +2 lines)
Lines 177-184 public: Link Here
177
    uint32_t ugen_count(void) const { return ugen_count_; }
177
    uint32_t ugen_count(void) const { return ugen_count_; }
178
    /* @} */
178
    /* @} */
179
179
180
    void load_plugin_folder(boost::filesystem::path const& path);
180
    void load_plugin_folder(std::filesystem::path const& path);
181
    void load_plugin(boost::filesystem::path const& path);
181
    void load_plugin(std::filesystem::path const& path);
182
182
183
private:
183
private:
184
    void close_handles(void);
184
    void close_handles(void);
(-)a/server/supernova/server/main.cpp (-1 / +1 lines)
Lines 25-31 Link Here
25
#include "SC_Win32Utils.h"
25
#include "SC_Win32Utils.h"
26
#include "SC_ServerBootDelayWarning.h"
26
#include "SC_ServerBootDelayWarning.h"
27
27
28
#include <boost/filesystem/path.hpp>
28
#include <filesystem>
29
#include <boost/algorithm/string.hpp>
29
#include <boost/algorithm/string.hpp>
30
30
31
#include "server.hpp"
31
#include "server.hpp"
(-)a/testsuite/server/supernova/sc_plugin_loader_test.cpp (-2 / +2 lines)
Lines 2-8 Link Here
2
2
3
#include <iostream>
3
#include <iostream>
4
4
5
#include <boost/filesystem.hpp>
5
#include <filesystem>
6
6
7
#include "sc/sc_ugen_factory.hpp"
7
#include "sc/sc_ugen_factory.hpp"
8
#include "server/memory_pool.hpp"
8
#include "server/memory_pool.hpp"
Lines 11-17 Link Here
11
using namespace nova;
11
using namespace nova;
12
using namespace std;
12
using namespace std;
13
13
14
boost::filesystem::path base_path("/home/tim/workspace/nova-server/debug_plugins/");
14
std::filesystem::path base_path("/home/tim/workspace/nova-server/debug_plugins/");
15
15
16
BOOST_AUTO_TEST_CASE(ugen_factory_test_1) {
16
BOOST_AUTO_TEST_CASE(ugen_factory_test_1) {
17
    server_arguments::initialize(0, 0);
17
    server_arguments::initialize(0, 0);

Return to bug 932793