Commit c8d2e62a authored by GILLES Sebastien's avatar GILLES Sebastien

#1480 Move the content of former FilesystemNS::Folder into Advanced namespace:...

#1480 Move the content of former FilesystemNS::Folder into Advanced namespace: the idea is now to use as much as possible the new \a Directory class.
parent 429a64b0
......@@ -1292,8 +1292,8 @@
BE90E1841A24929A00CCAFDE /* InputData.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BEB6425317CF9315001CEE44 /* InputData.hxx */; };
BE90E18E1A24929A00CCAFDE /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEB991A018F41AC2009ACA4C /* File.cpp */; };
BE90E18F1A24929A00CCAFDE /* File.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEB991A118F41AC2009ACA4C /* File.hpp */; };
BE90E1901A24929A00CCAFDE /* Folder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEB991A218F41AC2009ACA4C /* Folder.cpp */; };
BE90E1911A24929A00CCAFDE /* Folder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEB991A318F41AC2009ACA4C /* Folder.hpp */; };
BE90E1901A24929A00CCAFDE /* Directory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEB991A218F41AC2009ACA4C /* Directory.cpp */; };
BE90E1911A24929A00CCAFDE /* Directory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEB991A318F41AC2009ACA4C /* Directory.hpp */; };
BE90E1921A24929A00CCAFDE /* UniqueId.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE589C281A160ABD00D23130 /* UniqueId.hpp */; };
BE90E1931A24929A00CCAFDE /* UniqueId.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE589C291A160ABD00D23130 /* UniqueId.hxx */; };
BE90E1941A24929A00CCAFDE /* TimeKeep.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2D51D219A736CC00F6D10B /* TimeKeep.cpp */; };
......@@ -4573,8 +4573,8 @@
BEB9170B1AD3D37A0096A3D9 /* ExtendedUnknown.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ExtendedUnknown.hxx; sourceTree = "<group>"; };
BEB991A018F41AC2009ACA4C /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = "<group>"; };
BEB991A118F41AC2009ACA4C /* File.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = File.hpp; sourceTree = "<group>"; };
BEB991A218F41AC2009ACA4C /* Folder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Folder.cpp; sourceTree = "<group>"; };
BEB991A318F41AC2009ACA4C /* Folder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Folder.hpp; sourceTree = "<group>"; };
BEB991A218F41AC2009ACA4C /* Directory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Directory.cpp; sourceTree = "<group>"; };
BEB991A318F41AC2009ACA4C /* Directory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Directory.hpp; sourceTree = "<group>"; };
BEB991B418F42080009ACA4C /* BoolArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoolArray.cpp; sourceTree = "<group>"; };
BEB991B518F42080009ACA4C /* BoolArray.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BoolArray.hpp; sourceTree = "<group>"; };
BEB991B618F42080009ACA4C /* BoolArray.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BoolArray.hxx; sourceTree = "<group>"; };
......@@ -9846,8 +9846,6 @@
children = (
BEB991A018F41AC2009ACA4C /* File.cpp */,
BEB991A118F41AC2009ACA4C /* File.hpp */,
BEB991A218F41AC2009ACA4C /* Folder.cpp */,
BEB991A318F41AC2009ACA4C /* Folder.hpp */,
BE35030722F2E96700D09A4D /* Directory.cpp */,
BE35030922F2E96700D09A4D /* Directory.hpp */,
BE35030822F2E96700D09A4D /* Directory.hxx */,
......@@ -10727,6 +10725,8 @@
BEF9B60B231D6AF1009A680D /* Advanced */ = {
isa = PBXGroup;
children = (
BEB991A218F41AC2009ACA4C /* Directory.cpp */,
BEB991A318F41AC2009ACA4C /* Directory.hpp */,
);
path = Advanced;
sourceTree = "<group>";
......@@ -11523,7 +11523,7 @@
BE90E17B1A24926E00CCAFDE /* Singleton.hpp in Headers */,
BE145A121E54BC49000A2BF5 /* XorHandler.h in Headers */,
BE90E1CD1A2492AA00CCAFDE /* PetscMat.hpp in Headers */,
BE90E1911A24929A00CCAFDE /* Folder.hpp in Headers */,
BE90E1911A24929A00CCAFDE /* Directory.hpp in Headers */,
BE3F2EDC1CD260FE00125E90 /* NonZeroPattern.hpp in Headers */,
BEDEB9241C3C073100B1C71B /* Gmres.hxx in Headers */,
BE3D12C41D9B1FFB00F900F5 /* SnesConvergenceReason.hxx in Headers */,
......@@ -13011,7 +13011,7 @@
BECEF92322DF4A4400D0DDE7 /* ReadBinaryFile.cpp in Sources */,
BE53FC251E0D81A000C5D6F5 /* Traits.cpp in Sources */,
BE4F7D481D87DF5F00BDCF1A /* PrintAndAbort.cpp in Sources */,
BE90E1901A24929A00CCAFDE /* Folder.cpp in Sources */,
BE90E1901A24929A00CCAFDE /* Directory.cpp in Sources */,
BE90E1AC1A24929A00CCAFDE /* MatrixPattern.cpp in Sources */,
BE4B17D51AA5B20D0073516A /* Print.cpp in Sources */,
BE90E16D1A24926E00CCAFDE /* BoolArray.cpp in Sources */,
......@@ -11,7 +11,7 @@
#include "ThirdParty/Wrappers/Mpi/Mpi.hpp"
#include "Utilities/Datetime/Now.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Exceptions/GracefulExit.hpp"
#include "Core/MoReFEMData/Internal/Helper.hpp"
......
......@@ -849,10 +849,9 @@ namespace MoReFEM
// Create the subfolder to store numbering subset data.
// Root processor is in charge of it; other processors must wait until it's done.
auto&& subfolder = GetOutputDirectoryForNumberingSubset(numbering_subset);
if (!FilesystemNS::Folder::DoExist(subfolder)) // \todo #497
FilesystemNS::Folder::Create(subfolder, __FILE__, __LINE__);
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(subfolder)) // \todo #497
Advanced::FilesystemNS::DirectoryNS::Create(subfolder, __FILE__, __LINE__);
}
}
......
......@@ -12,7 +12,7 @@
#include <regex>
#include "Utilities/Exceptions/Exception.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "FiniteElement/FiniteElementSpace/Internal/OutputDirectoryStorage.hpp"
......@@ -33,7 +33,7 @@ namespace MoReFEM::Internal::GodOfDofNS
}
else
{
if (!FilesystemNS::Folder::DoExist(output_directory))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(output_directory))
throw Exception("Folder " + output_directory + " is expected to exist prior to this constructor call!",
__FILE__, __LINE__);
}
......
......@@ -73,7 +73,7 @@ namespace MoReFEM::Advanced::MeshNS
oconv << output_directory << "/mesh_data.lua";
partition_data_file_ = oconv.str();
if (FilesystemNS::File::DoExist(partition_data_file_))
if (::MoReFEM::FilesystemNS::File::DoExist(partition_data_file_))
{
oconv.str("");
oconv << "File " << partition_data_file_ << " already exists!";
......@@ -83,7 +83,7 @@ namespace MoReFEM::Advanced::MeshNS
std::ofstream out;
{
FilesystemNS::File::Create(out, partition_data_file_, __FILE__, __LINE__);
::MoReFEM::FilesystemNS::File::Create(out, partition_data_file_, __FILE__, __LINE__);
out << "Nprocessor_wise_coord = " << mesh.NprocessorWiseCoord() << std::endl;
out << "Nghosted_coord = " << mesh.NghostCoord()<< std::endl;
out << "space_unit = " << mesh.GetSpaceUnit() << std::endl;
......
......@@ -106,8 +106,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR",
__FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Elasticity/ExpectedResults/" + ascii_or_bin
+ std::string("/") + dimension;
......
......@@ -80,8 +80,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(root_dir = environment.GetEnvironmentVariable("MOREFEM_ROOT", __FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR", __FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Heat/ExpectedResults/" + dimension;
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/Heat/") + dimension
......
......@@ -9,7 +9,7 @@
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
# include "Geometry/Mesh/Advanced/DistanceFromMesh.hpp"
......
......@@ -65,8 +65,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(root_dir = environment.GetEnvironmentVariable("MOREFEM_ROOT", __FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR", __FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Hyperelasticity/ExpectedResults/";
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par
......
......@@ -64,8 +64,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(root_dir = environment.GetEnvironmentVariable("MOREFEM_ROOT", __FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR", __FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Laplacian/ExpectedResults/";
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/Laplacian/")
......
......@@ -8,7 +8,7 @@
*/
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "ThirdParty/Wrappers/Petsc/Vector/AccessVectorContent.hpp"
......
......@@ -78,8 +78,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(root_dir = environment.GetEnvironmentVariable("MOREFEM_ROOT", __FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR", __FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/RivlinCube/ExpectedResults/" + geometry;
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/RivlinCube/")
......
......@@ -9,7 +9,7 @@
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/Directory.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
......
......@@ -67,8 +67,8 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(root_dir = environment.GetEnvironmentVariable("MOREFEM_ROOT", __FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(output_dir = environment.GetEnvironmentVariable("MOREFEM_TEST_OUTPUT_DIR", __FILE__, __LINE__));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(root_dir));
BOOST_REQUIRE(Advanced::FilesystemNS::DirectoryNS::DoExist(output_dir));
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Stokes/ExpectedResults/";
......
......@@ -17,7 +17,7 @@
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Core/TimeManager/TimeManagerInstance.hpp"
......@@ -131,10 +131,10 @@ namespace // anonymous
// MoReFEMData initialization).
ret = environment.SubstituteValues("${MOREFEM_TEST_OUTPUT_DIR}/TestWriteLuaFile_not_from_lua_file/");
if (FilesystemNS::Folder::DoExist(ret))
FilesystemNS::Folder::Remove(ret, __FILE__, __LINE__);
if (Advanced::FilesystemNS::DirectoryNS::DoExist(ret))
Advanced::FilesystemNS::DirectoryNS::Remove(ret, __FILE__, __LINE__);
FilesystemNS::Folder::Create(ret, __FILE__, __LINE__);
Advanced::FilesystemNS::DirectoryNS::Create(ret, __FILE__, __LINE__);
first_call = false;
}
......
......@@ -8,7 +8,7 @@
*/
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Geometry/Mesh/ComputeColoring.hpp"
......
......@@ -49,8 +49,8 @@ BOOST_FIXTURE_TEST_CASE(medit_to_ensight, TestNS::FixtureNS::Environment)
std::string directory = environment.SubstituteValues("${MOREFEM_TEST_OUTPUT_DIR}/EnsightMeditMesh");
if (!FilesystemNS::Folder::DoExist(directory))
FilesystemNS::Folder::Create(directory, __FILE__, __LINE__);
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(directory))
Advanced::FilesystemNS::DirectoryNS::Create(directory, __FILE__, __LINE__);
std::string ensight_mesh_file = directory + "/Bar.geo";
medit_mesh.Write<MeshNS::Format::Ensight>(ensight_mesh_file);
......
......@@ -10,7 +10,7 @@
#include "Utilities/Environment/Environment.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Test/Geometry/Movemesh/Model.hpp"
......
......@@ -8,7 +8,7 @@
*/
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "ThirdParty/Wrappers/Petsc/Vector/AccessVectorContent.hpp"
......
......@@ -8,7 +8,7 @@
*/
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Parameters/Parameter.hpp"
......
......@@ -11,7 +11,7 @@
#include <sstream>
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/String/String.hpp"
#include "ThirdParty/Wrappers/Petsc/Vector/AccessVectorContent.hpp"
......
......@@ -8,7 +8,7 @@
*/
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Directory.hpp"
#include "Utilities/Exceptions/Exception.hpp"
......@@ -32,13 +32,13 @@ namespace MoReFEM
{
std::ostringstream oconv;
if (!FilesystemNS::Folder::DoExist(ref_dir.GetPath()))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(ref_dir.GetPath()))
{
oconv << "Reference folder " << ref_dir << " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
if (!FilesystemNS::Folder::DoExist(obtained_dir.GetPath()))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(obtained_dir.GetPath()))
{
oconv << "Result folder " << obtained_dir << " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
......
......@@ -14,7 +14,7 @@
#include "Utilities/Exceptions/Exception.hpp"
#include "Utilities/Numeric/Numeric.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
......@@ -55,13 +55,13 @@ namespace MoReFEM
decltype(auto) ref_dir = a_ref_dir.GetPath();
decltype(auto) obtained_dir = a_obtained_dir.GetPath();
if (!FilesystemNS::Folder::DoExist(ref_dir))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(ref_dir))
{
oconv << "Reference folder " + ref_dir + " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
if (!FilesystemNS::Folder::DoExist(obtained_dir))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(obtained_dir))
{
oconv << "Result folder " + obtained_dir + " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
......
......@@ -62,7 +62,7 @@ BOOST_FIXTURE_TEST_CASE(create, fixture)
FilesystemNS::behaviour::create,
__FILE__, __LINE__);
BOOST_CHECK(FilesystemNS::Folder::DoExist(create));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(create));
BOOST_CHECK_THROW(FilesystemNS::Directory create_once_again(mpi,
path,
......@@ -83,7 +83,7 @@ BOOST_FIXTURE_TEST_CASE(overwrite, fixture)
FilesystemNS::behaviour::overwrite,
__FILE__, __LINE__);
BOOST_CHECK(FilesystemNS::Folder::DoExist(overwrite));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(overwrite));
FilesystemNS::Directory overwrite_once_again(mpi,
test_dir + "/directory_test",
......@@ -100,7 +100,7 @@ BOOST_FIXTURE_TEST_CASE(read_case, fixture) // 'read' can't be used here hence t
const std::string directory_test = test_dir + "/directory_test";
BOOST_CHECK(FilesystemNS::Folder::DoExist(directory_test));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(directory_test));
FilesystemNS::Directory read(mpi,
directory_test,
......@@ -128,7 +128,7 @@ BOOST_FIXTURE_TEST_CASE(quit, fixture)
const std::string directory_test = test_dir + "/directory_test";
BOOST_CHECK(FilesystemNS::Folder::DoExist(directory_test));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(directory_test));
BOOST_CHECK_THROW(FilesystemNS::Directory read(mpi,
directory_test,
......@@ -193,8 +193,8 @@ BOOST_FIXTURE_TEST_CASE(ask_on_rank, fixture)
{
std::string rank_2_dir = directory_test + "Rank_2";
if (!FilesystemNS::Folder::DoExist(rank_2_dir))
FilesystemNS::Folder::Create(rank_2_dir, __FILE__, __LINE__);
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(rank_2_dir))
Advanced::FilesystemNS::DirectoryNS::Create(rank_2_dir, __FILE__, __LINE__);
}
mpi.Barrier();
......@@ -232,7 +232,7 @@ BOOST_FIXTURE_TEST_CASE(subdirectory, fixture)
std::ostringstream oconv;
oconv << directory_test << "Rank_" << mpi.GetRank<int>() << "/Subdirectory";
BOOST_CHECK(FilesystemNS::Folder::DoExist(oconv.str()));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(oconv.str()));
}
......@@ -283,7 +283,7 @@ BOOST_FIXTURE_TEST_CASE(many_subdirectories, fixture)
BOOST_CHECK_EQUAL(subdirectory.GetPath(), directory_test + "/Rank_" + std::to_string(mpi.GetRank<int>())
+ "/Subfolder/Subsubfolder/Subsubsubfolder/");
BOOST_CHECK(FilesystemNS::Folder::DoExist(subdirectory));
BOOST_CHECK(Advanced::FilesystemNS::DirectoryNS::DoExist(subdirectory));
}
......
......@@ -16,7 +16,7 @@
#include "Utilities/Environment/Environment.hpp"
#include "Utilities/Datetime/Now.hpp"
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Test/Tools/Fixture/Environment.hpp"
......@@ -57,8 +57,8 @@ BOOST_FIXTURE_TEST_CASE(same_on_all_processors, Fixture)
if (mpi.IsRootProcessor())
{
if (!FilesystemNS::Folder::DoExist(output_directory))
FilesystemNS::Folder::Create(output_directory, __FILE__, __LINE__);
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(output_directory))
Advanced::FilesystemNS::DirectoryNS::Create(output_directory, __FILE__, __LINE__);
}
mpi.Barrier();
......
/*!
//
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Thu, 3 Oct 2013 14:58:15 +0200
// Copyright (c) Inria. All rights reserved.
//
// \ingroup UtilitiesGroup
// \addtogroup UtilitiesGroup
// \{
*/
#include <sstream>
#include "ThirdParty/IncludeWithoutWarning/Boost/Filesystem.hpp"
#include "Utilities/Filesystem/Advanced/Directory.hpp"
#include "Utilities/Exceptions/Exception.hpp"
namespace MoReFEM::Advanced::FilesystemNS::DirectoryNS
{
bool DoExist(const std::string& folder)
{
try
{
// is_directory also checks it does exist.
return boost::filesystem::is_directory(boost::filesystem::path(folder));
}
catch (const boost::filesystem::filesystem_error& e)
{
std::ostringstream oconv;
oconv << boost::diagnostic_information(e);
throw Exception(oconv.str(), __FILE__, __LINE__);
}
}
void Create(const std::string& folder, const char* invoking_file, int invoking_line)
{
if (DoExist(folder))
throw Exception("Folder " + folder + " already exists!", invoking_file, invoking_line);
try
{
const auto is_ok = boost::filesystem::create_directories(boost::filesystem::path(folder));
// assert(is_ok && "If not, it means DoExist doesn't work as expected...");
static_cast<void>(is_ok);
}
catch (const boost::filesystem::filesystem_error& e)
{
std::ostringstream oconv;
oconv << boost::diagnostic_information(e);
throw Exception(oconv.str(), invoking_file, invoking_line);
}
}
void Remove(const std::string& folder, const char* invoking_file, int invoking_line)
{
if (!DoExist(folder))
throw Exception("Folder " + folder + " doesn't exist!", invoking_file, invoking_line);
try
{
boost::filesystem::remove_all(boost::filesystem::path(folder));
}
catch (const boost::filesystem::filesystem_error& e)
{
std::ostringstream oconv;
oconv << boost::diagnostic_information(e);
throw Exception(oconv.str(), __FILE__, __LINE__);
}
}
} // namespace MoReFEM::Advanced::FilesystemNS::DirectoryNS
/// @} // addtogroup UtilitiesGroup
/*!
//
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Thu, 3 Oct 2013 14:58:15 +0200
// Copyright (c) Inria. All rights reserved.
//
// \ingroup UtilitiesGroup
// \addtogroup UtilitiesGroup
// \{
*/
#ifndef MOREFEM_x_UTILITIES_x_FILESYSTEM_x_ADVANCED_x_DIRECTORY_HPP_
# define MOREFEM_x_UTILITIES_x_FILESYSTEM_x_ADVANCED_x_DIRECTORY_HPP_
# include <string>
namespace MoReFEM::Advanced::FilesystemNS::DirectoryNS
{
/*!
* \class doxygen_hide_directory_advanced_functions
*
* \attention These functionalities were used directly for quite some time in MoReFEM (with a different namespace
* MoReFEM::FilesystemNS::Folder) but are now superseded by the \a Directory class, which is more resilient and
* handle gracefully and in one place the issues that might stem from parallel run. So think again before using
* them: it's likely \a Directory is a betterfit for that.
*/
/*!
* \brief Tells whether a folder exists or not.
*
* \param[in] folder Name of the folder under investigation.
*
* \copydoc doxygen_hide_directory_advanced_functions
*
* \return True if \a folder exists.
*/
bool DoExist(const std::string& folder);
/*!
* \brief Create a folder.
*
* \copydoc doxygen_hide_directory_advanced_functions
*
* This function currently creates it if possible, creating in the process intermediate directory
* that might not exist.
*
* For instance:
*
\code
Create("/tmp/foo/bar", __FILE__, __LINE__);
\endcode
* will create directory foo if it doesn't exist yet.
*
* An exception is thrown if the operation failed.
*
* \param[in] folder Name of the folder to be created.
* \copydoc doxygen_hide_invoking_file_and_line
*/
void Create(const std::string& folder, const char* invoking_file, int invoking_line);
/*!
* \brief Delete a folder.
*
* \copydoc doxygen_hide_directory_advanced_functions
*
* An exception is thrown if the operation failed or if it doesn't exist.
*
* \param[in] folder Name of the folder to be deleted.
* \copydoc doxygen_hide_invoking_file_and_line
*/
void Remove(const std::string& folder, const char* invoking_file, int invoking_line);
} // namespace MoReFEM::Advanced::FilesystemNS::DirectoryNS
/// @} // addtogroup UtilitiesGroup
#endif // MOREFEM_x_UTILITIES_x_FILESYSTEM_x_ADVANCED_x_DIRECTORY_HPP_
### ===================================================================================
### This file is generated automatically by Scripts/generate_cmake_source_list.py.
### Do not edit it manually!
### Convention is that:
### - When a CMake file is manually managed, it is named canonically CMakeLists.txt.
###. - When it is generated automatically, it is named SourceList.cmake.
### ===================================================================================
target_sources(${MOREFEM_UTILITIES}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Directory.cpp"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Directory.hpp"
)
......@@ -117,15 +117,15 @@ namespace MoReFEM::FilesystemNS
}
// At this point, each rank may do its own bidding.
if (Folder::DoExist(path_))
if (Advanced::FilesystemNS::DirectoryNS::DoExist(path_))
{
switch(directory_behaviour_)
{
case behaviour::ask:
case behaviour::overwrite:
Folder::Remove(path_, invoking_file, invoking_line);
assert(!Folder::DoExist(path_));
Folder::Create(path_, invoking_file, invoking_line);
Advanced::FilesystemNS::DirectoryNS::Remove(path_, invoking_file, invoking_line);
assert(!Advanced::FilesystemNS::DirectoryNS::DoExist(path_));
Advanced::FilesystemNS::DirectoryNS::Create(path_, invoking_file, invoking_line);
break;
case behaviour::ignore:
break;
......@@ -156,10 +156,10 @@ namespace MoReFEM::FilesystemNS
case behaviour::ignore:
case behaviour::quit:
case behaviour::create:
Folder::Create(path_, invoking_file, invoking_line);
Advanced::FilesystemNS::DirectoryNS::Create(path_, invoking_file, invoking_line);
break;
case behaviour::read:
if (!Folder::DoExist(path_))
if (!Advanced::FilesystemNS::DirectoryNS::DoExist(path_))
{
std::ostringstream oconv;
oconv << "Directory '" << path_ << "' was expected to exist and could not be found.";
......@@ -179,7 +179,7 @@ namespace MoReFEM::FilesystemNS
decltype(auto) mpi = GetMpi();
const auto rank = mpi.GetRank<int>();
const bool do_path_exist = Folder::DoExist(path_);
const bool do_path_exist = Advanced::FilesystemNS::DirectoryNS::DoExist(path_);
std::vector<int> sent_data { do_path_exist ? rank : -1 };
std::vector<int> gathered_data;
......@@ -395,7 +395,7 @@ namespace MoReFEM::Internal::FilesystemNS
void CheckForSubdirectoryConstructor(const Directory& parent_directory,
const char* invoking_file, int invoking_line)
{
if (!::MoReFEM::FilesystemNS::Folder::DoExist(parent_directory.GetPath()))
if (!::MoReFEM::Advanced::FilesystemNS::DirectoryNS::DoExist(parent_directory.GetPath()))
{
std::ostringstream oconv;
oconv << "Directory '" << parent_directory.GetPath() << "' couldn't be found whereas we were trying to build a "
......
......@@ -16,7 +16,7 @@
# include <memory>
# include "Utilities/Exceptions/Exception.hpp"
# include "Utilities/Filesystem/Folder.hpp"
# include "Utilities/Filesystem/Advanced/Directory.hpp"
# include "Utilities/Containers/Print.hpp"
# include "ThirdParty/Wrappers/Mpi/Mpi.hpp"
......