Skip to content

Commit

Permalink
Filesystem library (#2879)
Browse files Browse the repository at this point in the history
* move mamba_fs.hpp

* Header cleanup

* No util:: dependency in filesystem

* Change header names

* Use std::replace in filesystem
  • Loading branch information
AntoinePrv authored Oct 5, 2023
1 parent 91b6c44 commit 5a302fc
Show file tree
Hide file tree
Showing 59 changed files with 184 additions and 163 deletions.
6 changes: 4 additions & 2 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ endforeach()
set(LIBMAMBA_SOURCES
longpath.manifest
${LIBMAMBA_SOURCE_DIR}/version.cpp
# Filesystem library
${LIBMAMBA_SOURCE_DIR}/fs/filesystem.cpp
# C++ utility library
${LIBMAMBA_SOURCE_DIR}/util/string.cpp
${LIBMAMBA_SOURCE_DIR}/util/path_manip.cpp
Expand Down Expand Up @@ -155,7 +157,6 @@ set(LIBMAMBA_SOURCES
${LIBMAMBA_SOURCE_DIR}/core/transaction_context.cpp
${LIBMAMBA_SOURCE_DIR}/core/link.cpp
${LIBMAMBA_SOURCE_DIR}/core/history.cpp
${LIBMAMBA_SOURCE_DIR}/core/mamba_fs.cpp
${LIBMAMBA_SOURCE_DIR}/core/match_spec.cpp
${LIBMAMBA_SOURCE_DIR}/core/menuinst.cpp
${LIBMAMBA_SOURCE_DIR}/core/output.cpp
Expand Down Expand Up @@ -209,6 +210,8 @@ endforeach()

set(LIBMAMBA_PUBLIC_HEADERS
${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp
# Filesystem library
${LIBMAMBA_INCLUDE_DIR}/mamba/fs/filesystem.hpp
# Utility library
${LIBMAMBA_INCLUDE_DIR}/mamba/util/json.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/util/deprecation.hpp
Expand Down Expand Up @@ -248,7 +251,6 @@ set(LIBMAMBA_PUBLIC_HEADERS
${LIBMAMBA_INCLUDE_DIR}/mamba/core/satisfiability_error.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/history.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/link.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/mamba_fs.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/match_spec.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/menuinst.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/output.hpp
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/api/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "mamba/api/constants.hpp"
#include "mamba/core/context.hpp"
#include "mamba/core/environment.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/output.hpp"
#include "mamba/fs/filesystem.hpp"


namespace mamba
Expand Down
10 changes: 5 additions & 5 deletions libmamba/include/mamba/api/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "mamba/core/common_types.hpp"
#include "mamba/core/context.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down Expand Up @@ -304,21 +304,21 @@ namespace YAML
};

template <>
struct convert<fs::u8path>
struct convert<mamba::fs::u8path>
{
static Node encode(const fs::u8path& rhs)
static Node encode(const mamba::fs::u8path& rhs)
{
return Node(rhs.string());
}

static bool decode(const Node& node, fs::u8path& rhs)
static bool decode(const Node& node, mamba::fs::u8path& rhs)
{
if (!node.IsScalar())
{
return false;
}

rhs = fs::u8path(node.as<std::string>());
rhs = mamba::fs::u8path(node.as<std::string>());
return true;
}
};
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/api/create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <string>

#include "mamba/core/mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/api/install.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include <yaml-cpp/yaml.h>

#include "mamba/core/context.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/package_cache.hpp"
#include "mamba/core/package_info.hpp"
#include "mamba/core/pool.hpp"
#include "mamba/core/repo.hpp"
#include "mamba/core/solver.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/api/shell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <string>
#include <string_view>

#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/palette.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/api/update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <string>
#include <vector>

#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/query.hpp"
#include "mamba/fs/filesystem.hpp"


namespace mamba
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/activation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <utility>
#include <vector>

#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

// TODO write a map that keeps insertion order

Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <vector>

#include "mamba/core/common_types.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/palette.hpp"
#include "mamba/core/tasksync.hpp"
#include "mamba/fs/filesystem.hpp"
#include "mamba/specs/authentification_info.hpp"
#include "mamba/specs/platform.hpp"
#include "mamba/version.hpp"
Expand Down
4 changes: 3 additions & 1 deletion libmamba/include/mamba/core/env_lockfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <tl/expected.hpp>

#include "mamba/fs/filesystem.hpp"

#include "error_handling.hpp"
#include "fsutil.hpp"
#include "package_info.hpp"
Expand Down Expand Up @@ -111,7 +113,7 @@ namespace mamba
/// Read an environment lock YAML file and returns it's structured content or an error if
/// failed.
tl::expected<EnvironmentLockFile, mamba_error>
read_environment_lockfile(ChannelContext& channel_context, const fs::u8path& lockfile_location);
read_environment_lockfile(ChannelContext& channel_context, const mamba::fs::u8path& lockfile_location);


/// Returns `true` if the filename matches names of files which should be interpreted as conda
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <optional>
#include <vector>

#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

#ifdef _WIN32
#include <Shlobj.h>
Expand Down
10 changes: 5 additions & 5 deletions libmamba/include/mamba/core/fsutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

#include <system_error>

namespace fs
{
class u8path;
}

namespace mamba
{
namespace fs
{
class u8path;
}

namespace path
{
bool starts_with_home(const fs::u8path& p);
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/history.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include <unordered_map>
#include <vector>

#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

#include "match_spec.hpp"

namespace mamba
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <tuple>
#include <vector>

#include "mamba/fs/filesystem.hpp"
#include "mamba/util/build.hpp"

#include "mamba_fs.hpp"
#include "match_spec.hpp"
#include "package_paths.hpp"
#include "transaction.hpp"
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/menuinst.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

#include "transaction_context.hpp"

namespace mamba
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/package_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include <string>
#include <vector>

#include "mamba/fs/filesystem.hpp"

#include "fsutil.hpp"
#include "mamba_fs.hpp"
#include "package_info.hpp"

#define PACKAGE_CACHE_MAGIC_FILE "urls.txt"
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/package_download.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
#include <tuple>
#include <vector>

#include "mamba/fs/filesystem.hpp"

#include "fetch.hpp"
#include "mamba_fs.hpp"
#include "package_cache.hpp"
#include "progress_bar.hpp"
#include "tasksync.hpp"
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/package_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <system_error>
#include <vector>

#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down
1 change: 1 addition & 0 deletions libmamba/include/mamba/core/pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace mamba
{
class MatchSpec;
class ChannelContext;
class Context;

namespace solv
{
Expand Down
11 changes: 6 additions & 5 deletions libmamba/include/mamba/core/repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ extern "C"
typedef struct s_Repodata Repodata;
}

namespace fs
{
class u8path;
}

namespace mamba
{

namespace fs
{
class u8path;
}

class PackageInfo;
class PrefixData;

Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <nlohmann/json.hpp>

#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/util.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/shell_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <string>
#include <vector>

#include "mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

extern const char data_micromamba_sh[];
extern const char data_micromamba_csh[];
Expand Down
4 changes: 2 additions & 2 deletions libmamba/include/mamba/core/subdirdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define MAMBA_CORE_SUBDIRDATA_HPP

#include <memory>
#include <regex>
#include <string>

#include <nlohmann/json_fwd.hpp>
Expand All @@ -17,11 +16,12 @@
#include "mamba/core/context.hpp"
#include "mamba/core/download.hpp"
#include "mamba/core/error_handling.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/fetch.hpp"
#include "mamba/core/package_cache.hpp"
#include "mamba/core/pool.hpp"
#include "mamba/core/repo.hpp"
#include "mamba/core/util.hpp"
#include "mamba/fs/filesystem.hpp"

#include "package_handling.hpp"

Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <vector>

#include "mamba/api/install.hpp"
#include "mamba/fs/filesystem.hpp"

#include "mamba_fs.hpp"
#include "match_spec.hpp"
#include "package_cache.hpp"
#include "package_info.hpp"
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/transaction_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

#include <reproc++/reproc.hpp>

#include "mamba/fs/filesystem.hpp"

#include "context.hpp"
#include "mamba_fs.hpp"
#include "match_spec.hpp"
#include "util.hpp"

Expand Down
15 changes: 3 additions & 12 deletions libmamba/include/mamba/core/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,19 @@
#ifndef MAMBA_CORE_UTIL_HPP
#define MAMBA_CORE_UTIL_HPP

#include <array>
#include <chrono>
#include <limits>
#include <fstream>
#include <map>
#include <optional>
#include <sstream>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>

#include <time.h>

#include "mamba/core/error_handling.hpp"
#include "mamba/core/mamba_fs.hpp"
#include "mamba/fs/filesystem.hpp"

#include "nlohmann/json.hpp"
#include "tl/expected.hpp"

#if defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
#include <iomanip>
#endif

#define MAMBA_EMPTY_SHA "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";

namespace mamba
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include <nlohmann/json.hpp>

#include "mamba/core/mamba_fs.hpp"
#include "mamba/core/timeref.hpp"
#include "mamba/core/util.hpp"
#include "mamba/fs/filesystem.hpp"

namespace mamba::validation
{
Expand Down
Loading

0 comments on commit 5a302fc

Please sign in to comment.