Skip to content

Commit 1ab632a

Browse files
committed
Update for c++17 filesystem.
1 parent f808ff7 commit 1ab632a

15 files changed

Lines changed: 35 additions & 31 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ if (WIN32)
9999
endif(WIN32)
100100

101101
if(UNIX)
102-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
103-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++")
102+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
103+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++")
104104
#set(CMAKE_EXE_LINKER_FLAGS "-lc++abi")
105105
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
106106
endif()

src/client/build.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ int build_packages(const Config &c, const String &name);
4040
String test_run()
4141
{
4242
// do a test build to extract config string
43-
auto src_dir = temp_directory_path() / "temp" / fs::unique_path();
43+
auto src_dir = temp_directory_path() / "temp" / unique_path();
4444
auto bin_dir = src_dir / "build";
4545

4646
fs::create_directories(src_dir);
4747
write_file(src_dir / CPPAN_FILENAME, "");
4848
SCOPE_EXIT
4949
{
5050
// remove test dir
51-
boost::system::error_code ec;
51+
error_code ec;
5252
fs::remove_all(src_dir, ec);
5353
};
5454

src/client/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void command_init(const Strings &args)
215215
build_project = false;
216216
}
217217

218-
boost::system::error_code ec;
218+
error_code ec;
219219
auto root = current_thread_path();
220220

221221
static const auto err_exist = "File or dir with such name already exist";

src/client/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ try
445445
auto p = cwd;
446446
if (par)
447447
{
448-
p = t / fs::unique_path();
448+
p = t / unique_path();
449449
fs::create_directories(p);
450450
current_thread_path(p);
451451

@@ -454,7 +454,7 @@ try
454454

455455
applyVersionToUrl(project.source, project.pkg.version);
456456
download(project.source);
457-
fs::copy_file(cwd / CPPAN_FILENAME, CPPAN_FILENAME, fs::copy_option::overwrite_if_exists);
457+
fs::copy_file(cwd / CPPAN_FILENAME, CPPAN_FILENAME, fs::copy_options::overwrite_existing);
458458
}
459459
SCOPE_EXIT
460460
{
@@ -607,12 +607,12 @@ void self_upgrade()
607607

608608
auto &s = Settings::get_user_settings();
609609

610-
auto fn = fs::temp_directory_path() / fs::unique_path();
610+
auto fn = fs::temp_directory_path() / unique_path();
611611
std::cout << "Downloading checksum file" << "\n";
612612
download_file(s.remotes[0].url + client + ".md5", fn, 50_MB);
613613
auto md5sum = boost::algorithm::trim_copy(read_file(fn));
614614

615-
fn = fs::temp_directory_path() / fs::unique_path();
615+
fn = fs::temp_directory_path() / unique_path();
616616
std::cout << "Downloading the latest client" << "\n";
617617
download_file(s.remotes[0].url + client, fn, 50_MB);
618618
if (md5sum != md5(fn))
@@ -655,7 +655,7 @@ void self_upgrade_copy(const path &dst)
655655
std::this_thread::sleep_for(std::chrono::seconds(2));
656656
try
657657
{
658-
fs::copy_file(get_program(), dst, fs::copy_option::overwrite_if_exists);
658+
fs::copy_file(get_program(), dst, fs::copy_options::overwrite_existing);
659659
break;
660660
}
661661
catch (std::exception &e)

src/common/database.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void ServiceDatabase::performStartupActions() const
472472
clearConfigHashes();
473473

474474
// also cleanup temp build dir
475-
boost::system::error_code ec;
475+
error_code ec;
476476
fs::remove_all(temp_directory_path(), ec);
477477
}
478478

@@ -608,7 +608,7 @@ Stamps ServiceDatabase::getFileStamps() const
608608
db->execute("select * from FileStamps",
609609
[&st](SQLITE_CALLBACK_ARGS)
610610
{
611-
st[cols[0]] = std::stoll(cols[1]);
611+
st[cols[0]] = fs::file_time_type(fs::file_time_type::duration(std::stoll(cols[1])));
612612
return 0;
613613
});
614614
return st;
@@ -623,7 +623,7 @@ void ServiceDatabase::setFileStamps(const Stamps &stamps) const
623623
}
624624
String q = "replace into FileStamps values ";
625625
for (auto &s : stamps)
626-
q += "('" + normalize_path(s.first) + "', '" + std::to_string(s.second) + "'),";
626+
q += "('" + normalize_path(s.first) + "', '" + std::to_string(s.second.time_since_epoch().count()) + "'),";
627627
q.resize(q.size() - 1);
628628
q += ";";
629629
db->execute(q);
@@ -930,7 +930,7 @@ void PackagesDatabase::download()
930930
auto unpack_dir = get_temp_filename();
931931
auto files = unpack_file(fn, unpack_dir);
932932
for (auto &f : files)
933-
fs::copy_file(f, db_repo_dir / f.filename(), fs::copy_option::overwrite_if_exists);
933+
fs::copy_file(f, db_repo_dir / f.filename(), fs::copy_options::overwrite_existing);
934934
fs::remove_all(unpack_dir);
935935
fs::remove(fn);
936936
};
@@ -968,7 +968,7 @@ void PackagesDatabase::download()
968968
catch (const std::exception &)
969969
{
970970
// cannot throw
971-
boost::system::error_code ec;
971+
error_code ec;
972972
fs::remove_all(db_repo_dir, ec);
973973

974974
download_archive();

src/common/package.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ void cleanPackage(const Package &pkg, int flags)
270270
{
271271
if (fs::exists(p))
272272
{
273-
boost::system::error_code ec;
273+
error_code ec;
274274
fs::remove_all(p, ec);
275275
}
276276
};
277277

278278
auto rm_recursive = [](const auto &pkg, const auto &files, const auto &ext)
279279
{
280-
boost::system::error_code ec;
280+
error_code ec;
281281
for (auto &f : files)
282282
{
283283
auto fn = f.filename().string();

src/common/package_store.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ PackageStore::read_packages_from_file(path p, const String &config_name, bool di
586586
{
587587
auto r = project.pkg.getDirSrc() / f.lexically_relative(root_directory);
588588
create_directories(r.parent_path());
589-
fs::copy_file(f, r, fs::copy_option::overwrite_if_exists);
589+
fs::copy_file(f, r, fs::copy_options::overwrite_existing);
590590
files.insert(r);
591591
}
592592
project.files = files;

src/common/project.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ void Project::findSources(path p)
563563

564564
if (!root_directory.empty() && !pkg.flags[pfLocalProject] &&
565565
fs::absolute(CPPAN_FILENAME) != fs::absolute(root_directory / CPPAN_FILENAME))
566-
fs::copy_file(CPPAN_FILENAME, root_directory / CPPAN_FILENAME, fs::copy_option::overwrite_if_exists);
566+
fs::copy_file(CPPAN_FILENAME, root_directory / CPPAN_FILENAME, fs::copy_options::overwrite_existing);
567567
if (fs::exists(p / CPPAN_FILENAME))
568568
files.insert(p / CPPAN_FILENAME);
569569
else if (fs::exists(current_thread_path() / CPPAN_FILENAME))

src/common/remote.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "filesystem.h"
2121
#include "http.h"
2222

23+
#include <functional>
24+
2325
#define DEFAULT_REMOTE_NAME "origin"
2426

2527
struct Package;

src/common/resolver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "dependency.h"
2020
#include "package_store.h"
2121

22+
#include <functional>
23+
2224
class Resolver
2325
{
2426
public:

0 commit comments

Comments
 (0)