mirror of https://github.com/mamba-org/mamba.git
Use `fs::u8path` instead of `fs::path` to fix utf-8 paths issues on Windows
This commit is contained in:
parent
ef9f0ef871
commit
8b4010a56f
|
@ -376,10 +376,10 @@ namespace mamba
|
|||
using grouped_config_type = std::pair<std::string, std::vector<Configurable*>>;
|
||||
std::vector<grouped_config_type> get_grouped_config();
|
||||
|
||||
std::vector<fs::path> sources();
|
||||
std::vector<fs::path> valid_sources();
|
||||
std::vector<fs::u8path> sources();
|
||||
std::vector<fs::u8path> valid_sources();
|
||||
|
||||
void set_rc_values(std::vector<fs::path> possible_rc_paths, const RCConfigLevel& level);
|
||||
void set_rc_values(std::vector<fs::u8path> possible_rc_paths, const RCConfigLevel& level);
|
||||
|
||||
void load();
|
||||
|
||||
|
@ -427,16 +427,16 @@ namespace mamba
|
|||
const std::string& name,
|
||||
std::vector<std::string>&);
|
||||
|
||||
static YAML::Node load_rc_file(const fs::path& file);
|
||||
static YAML::Node load_rc_file(const fs::u8path& file);
|
||||
|
||||
static std::vector<fs::path> compute_default_rc_sources(const RCConfigLevel& level);
|
||||
static std::vector<fs::u8path> compute_default_rc_sources(const RCConfigLevel& level);
|
||||
|
||||
std::vector<fs::path> get_existing_rc_sources(
|
||||
const std::vector<fs::path>& possible_rc_paths);
|
||||
std::vector<fs::u8path> get_existing_rc_sources(
|
||||
const std::vector<fs::u8path>& possible_rc_paths);
|
||||
|
||||
std::vector<fs::path> m_sources;
|
||||
std::vector<fs::path> m_valid_sources;
|
||||
std::map<fs::path, YAML::Node> m_rc_yaml_nodes_cache;
|
||||
std::vector<fs::u8path> m_sources;
|
||||
std::vector<fs::u8path> m_valid_sources;
|
||||
std::map<fs::u8path, YAML::Node> m_rc_yaml_nodes_cache;
|
||||
|
||||
bool m_load_lock = false;
|
||||
|
||||
|
@ -570,14 +570,15 @@ namespace mamba
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void ConfigurableImpl<fs::path>::dump_json(nlohmann::json& node,
|
||||
const std::string& name) const
|
||||
inline void ConfigurableImpl<fs::u8path>::dump_json(nlohmann::json& node,
|
||||
const std::string& name) const
|
||||
{
|
||||
node[name] = m_value.string();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void ConfigurableImpl<std::vector<fs::path>>::dump_json(nlohmann::json& node, const std::string& name) const
|
||||
inline void ConfigurableImpl<std::vector<fs::u8path>>::dump_json(
|
||||
nlohmann::json& node, const std::string& name) const
|
||||
{
|
||||
std::vector<std::string> values(m_value.size());
|
||||
std::transform(m_value.begin(),
|
||||
|
|
|
@ -295,21 +295,21 @@ namespace YAML
|
|||
};
|
||||
|
||||
template <>
|
||||
struct convert<fs::path>
|
||||
struct convert<fs::u8path>
|
||||
{
|
||||
static Node encode(const fs::path& rhs)
|
||||
static Node encode(const fs::u8path& rhs)
|
||||
{
|
||||
return Node(rhs.string());
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, fs::path& rhs)
|
||||
static bool decode(const Node& node, fs::u8path& rhs)
|
||||
{
|
||||
if (!node.IsScalar())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
rhs = fs::path(node.as<std::string>());
|
||||
rhs = fs::u8path(node.as<std::string>());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace mamba
|
|||
|
||||
namespace detail
|
||||
{
|
||||
void store_platform_config(const fs::path& prefix, const std::string& platform);
|
||||
void store_platform_config(const fs::u8path& prefix, const std::string& platform);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace mamba
|
|||
int is_retry = 0);
|
||||
|
||||
void install_explicit_specs(const std::vector<std::string>& specs, bool create_env = false);
|
||||
void install_lockfile_specs(const fs::path& lockfile_specs, bool create_env = false);
|
||||
void install_lockfile_specs(const fs::u8path& lockfile_specs, bool create_env = false);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void create_target_directory(const fs::path prefix);
|
||||
void create_target_directory(const fs::u8path prefix);
|
||||
|
||||
void create_empty_target(const fs::path& prefix);
|
||||
void create_empty_target(const fs::u8path& prefix);
|
||||
|
||||
void file_specs_hook(std::vector<std::string>& file_specs);
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace mamba
|
|||
|
||||
bool eval_selector(const std::string& selector);
|
||||
|
||||
yaml_file_contents read_yaml_file(fs::path yaml_file);
|
||||
yaml_file_contents read_yaml_file(fs::u8path yaml_file);
|
||||
|
||||
std::tuple<std::vector<PackageInfo>, std::vector<MatchSpec>> parse_urls_to_package_info(
|
||||
const std::vector<std::string>& urls);
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace mamba
|
|||
std::vector<std::string> unset_vars;
|
||||
std::vector<std::pair<std::string, std::string>> set_vars;
|
||||
std::vector<std::pair<std::string, std::string>> export_vars;
|
||||
std::vector<fs::path> activate_scripts;
|
||||
std::vector<fs::path> deactivate_scripts;
|
||||
std::vector<fs::u8path> activate_scripts;
|
||||
std::vector<fs::u8path> deactivate_scripts;
|
||||
};
|
||||
|
||||
class Activator
|
||||
|
@ -52,22 +52,23 @@ namespace mamba
|
|||
virtual std::string shell_extension() = 0;
|
||||
virtual std::string shell() = 0;
|
||||
|
||||
std::vector<fs::path> get_activate_scripts(const fs::path& prefix);
|
||||
std::vector<fs::path> get_deactivate_scripts(const fs::path& prefix);
|
||||
std::vector<fs::u8path> get_activate_scripts(const fs::u8path& prefix);
|
||||
std::vector<fs::u8path> get_deactivate_scripts(const fs::u8path& prefix);
|
||||
|
||||
std::string get_default_env(const fs::path& prefix);
|
||||
std::string get_default_env(const fs::u8path& prefix);
|
||||
std::vector<std::pair<std::string, std::string>> get_environment_vars(
|
||||
const fs::path& prefix);
|
||||
const fs::u8path& prefix);
|
||||
|
||||
std::string get_prompt_modifier(const fs::path& prefix,
|
||||
std::string get_prompt_modifier(const fs::u8path& prefix,
|
||||
const std::string& conda_default_env,
|
||||
int old_conda_shlvl);
|
||||
|
||||
std::vector<fs::path> get_clean_dirs();
|
||||
std::vector<fs::u8path> get_clean_dirs();
|
||||
|
||||
std::string add_prefix_to_path(const fs::path& prefix, int old_conda_shlvl);
|
||||
std::string replace_prefix_in_path(const fs::path& old_prefix, const fs::path& new_prefix);
|
||||
std::string remove_prefix_from_path(const fs::path& prefix);
|
||||
std::string add_prefix_to_path(const fs::u8path& prefix, int old_conda_shlvl);
|
||||
std::string replace_prefix_in_path(const fs::u8path& old_prefix,
|
||||
const fs::u8path& new_prefix);
|
||||
std::string remove_prefix_from_path(const fs::u8path& prefix);
|
||||
|
||||
void get_export_unset_vars(
|
||||
EnvironmentTransform& envt,
|
||||
|
@ -75,15 +76,15 @@ namespace mamba
|
|||
|
||||
EnvironmentTransform build_reactivate();
|
||||
EnvironmentTransform build_deactivate();
|
||||
EnvironmentTransform build_activate(const fs::path& prefix);
|
||||
EnvironmentTransform build_activate(const fs::u8path& prefix);
|
||||
|
||||
std::string activate(const fs::path& prefix, bool stack);
|
||||
std::string activate(const fs::u8path& prefix, bool stack);
|
||||
std::string reactivate();
|
||||
std::string deactivate();
|
||||
|
||||
virtual std::string hook_preamble() = 0;
|
||||
virtual std::string hook_postamble() = 0;
|
||||
virtual fs::path hook_source_path() = 0;
|
||||
virtual fs::u8path hook_source_path() = 0;
|
||||
|
||||
std::string hook();
|
||||
|
||||
|
@ -110,7 +111,7 @@ namespace mamba
|
|||
|
||||
std::string hook_preamble() override;
|
||||
std::string hook_postamble() override;
|
||||
fs::path hook_source_path() override;
|
||||
fs::u8path hook_source_path() override;
|
||||
};
|
||||
|
||||
class CmdExeActivator : public Activator
|
||||
|
@ -127,7 +128,7 @@ namespace mamba
|
|||
|
||||
std::string hook_preamble() override;
|
||||
std::string hook_postamble() override;
|
||||
fs::path hook_source_path() override;
|
||||
fs::u8path hook_source_path() override;
|
||||
};
|
||||
|
||||
class PowerShellActivator : public Activator
|
||||
|
@ -144,7 +145,7 @@ namespace mamba
|
|||
|
||||
std::string hook_preamble() override;
|
||||
std::string hook_postamble() override;
|
||||
fs::path hook_source_path() override;
|
||||
fs::u8path hook_source_path() override;
|
||||
};
|
||||
|
||||
class XonshActivator : public Activator
|
||||
|
@ -161,7 +162,7 @@ namespace mamba
|
|||
|
||||
std::string hook_preamble() override;
|
||||
std::string hook_postamble() override;
|
||||
fs::path hook_source_path() override;
|
||||
fs::u8path hook_source_path() override;
|
||||
};
|
||||
|
||||
class FishActivator : public Activator
|
||||
|
@ -178,11 +179,11 @@ namespace mamba
|
|||
|
||||
std::string hook_preamble() override;
|
||||
std::string hook_postamble() override;
|
||||
fs::path hook_source_path() override;
|
||||
fs::u8path hook_source_path() override;
|
||||
};
|
||||
|
||||
|
||||
std::vector<fs::path> get_path_dirs(const fs::path& prefix);
|
||||
std::vector<fs::u8path> get_path_dirs(const fs::u8path& prefix);
|
||||
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ namespace mamba
|
|||
|
||||
class Logger;
|
||||
|
||||
std::string env_name(const fs::path& prefix);
|
||||
fs::path locate_prefix_by_name(const std::string& name);
|
||||
std::string env_name(const fs::u8path& prefix);
|
||||
fs::u8path locate_prefix_by_name(const std::string& name);
|
||||
|
||||
// Context singleton class
|
||||
class Context
|
||||
|
@ -120,14 +120,14 @@ namespace mamba
|
|||
bool experimental = false;
|
||||
bool debug = false;
|
||||
|
||||
fs::path target_prefix;
|
||||
fs::path root_prefix;
|
||||
fs::path conda_prefix;
|
||||
fs::u8path target_prefix;
|
||||
fs::u8path root_prefix;
|
||||
fs::u8path conda_prefix;
|
||||
|
||||
// TODO check writable and add other potential dirs
|
||||
std::vector<fs::path> envs_dirs;
|
||||
std::vector<fs::path> pkgs_dirs;
|
||||
std::optional<fs::path> env_lockfile;
|
||||
std::vector<fs::u8path> envs_dirs;
|
||||
std::vector<fs::u8path> pkgs_dirs;
|
||||
std::optional<fs::u8path> env_lockfile;
|
||||
|
||||
bool use_index_cache = false;
|
||||
std::size_t local_repodata_ttl = 1; // take from header
|
||||
|
@ -223,7 +223,7 @@ namespace mamba
|
|||
|
||||
std::string channel_alias = "https://conda.anaconda.org";
|
||||
std::map<std::string, AuthenticationInfo>& authentication_info();
|
||||
std::vector<fs::path> token_locations{ "~/.continuum/anaconda-client/tokens" };
|
||||
std::vector<fs::u8path> token_locations{ "~/.continuum/anaconda-client/tokens" };
|
||||
|
||||
bool override_channels_enabled = true;
|
||||
|
||||
|
|
|
@ -106,7 +106,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(
|
||||
const fs::path& lockfile_location);
|
||||
const fs::u8path& lockfile_location);
|
||||
|
||||
|
||||
/// Returns `true` if the filename matches names of files which should be interpreted as conda
|
||||
|
|
|
@ -49,14 +49,14 @@ namespace mamba
|
|||
bool set(const std::string& key, const std::string& value);
|
||||
void unset(const std::string& key);
|
||||
|
||||
fs::path which(const std::string& exe, const std::string& override_path = "");
|
||||
fs::path which(const std::string& exe, const std::vector<fs::path>& search_paths);
|
||||
fs::u8path which(const std::string& exe, const std::string& override_path = "");
|
||||
fs::u8path which(const std::string& exe, const std::vector<fs::u8path>& search_paths);
|
||||
std::map<std::string, std::string> copy();
|
||||
std::string platform();
|
||||
fs::path home_directory();
|
||||
fs::u8path home_directory();
|
||||
|
||||
fs::path expand_user(const fs::path& path);
|
||||
fs::path shrink_user(const fs::path& path);
|
||||
fs::u8path expand_user(const fs::u8path& path);
|
||||
fs::u8path shrink_user(const fs::u8path& path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,20 +16,20 @@ namespace mamba
|
|||
{
|
||||
const char PREFIX_MAGIC_FILE[] = "conda-meta/history";
|
||||
|
||||
bool is_conda_environment(const fs::path& prefix);
|
||||
bool is_conda_environment(const fs::u8path& prefix);
|
||||
|
||||
class EnvironmentsManager
|
||||
{
|
||||
public:
|
||||
void register_env(const fs::path& location);
|
||||
void unregister_env(const fs::path& location);
|
||||
std::set<fs::path> list_all_known_prefixes();
|
||||
void register_env(const fs::u8path& location);
|
||||
void unregister_env(const fs::u8path& location);
|
||||
std::set<fs::u8path> list_all_known_prefixes();
|
||||
|
||||
private:
|
||||
std::set<std::string> clean_environments_txt(const fs::path& env_txt_file,
|
||||
const fs::path& location);
|
||||
std::set<std::string> clean_environments_txt(const fs::u8path& env_txt_file,
|
||||
const fs::u8path& location);
|
||||
std::string remove_trailing_slash(std::string p);
|
||||
fs::path get_environments_txt_file(const fs::path& home) const;
|
||||
fs::u8path get_environments_txt_file(const fs::u8path& home) const;
|
||||
};
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace mamba
|
|||
{
|
||||
namespace path
|
||||
{
|
||||
inline bool starts_with_home(const fs::path& p)
|
||||
inline bool starts_with_home(const fs::u8path& p)
|
||||
{
|
||||
std::string path = p.string();
|
||||
return path[0] == '~'
|
||||
|
@ -28,12 +28,12 @@ namespace mamba
|
|||
}
|
||||
|
||||
// TODO more error handling
|
||||
inline void create_directories_sudo_safe(const fs::path& path)
|
||||
inline void create_directories_sudo_safe(const fs::u8path& path)
|
||||
{
|
||||
if (fs::is_directory(path))
|
||||
return;
|
||||
|
||||
fs::path base_dir = path.parent_path();
|
||||
fs::u8path base_dir = path.parent_path();
|
||||
if (!fs::is_directory(base_dir))
|
||||
{
|
||||
create_directories_sudo_safe(base_dir);
|
||||
|
@ -48,7 +48,7 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
inline bool touch(fs::path path, bool mkdir = false, bool sudo_safe = false)
|
||||
inline bool touch(fs::u8path path, bool mkdir = false, bool sudo_safe = false)
|
||||
{
|
||||
// TODO error handling!
|
||||
path = env::expand_user(path);
|
||||
|
@ -96,7 +96,7 @@ namespace mamba
|
|||
// - a file name that does not exist but the parent directory in the path exists and we
|
||||
// are able to create a file with that name in that directory for writing.
|
||||
// Returns `false` otherwise.
|
||||
inline bool is_writable(const fs::path& path) noexcept
|
||||
inline bool is_writable(const fs::u8path& path) noexcept
|
||||
{
|
||||
const auto& path_to_write_in = fs::exists(path) ? path : path.parent_path();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace mamba
|
|||
class History
|
||||
{
|
||||
public:
|
||||
History(const fs::path& prefix);
|
||||
History(const fs::u8path& prefix);
|
||||
|
||||
struct ParseResult
|
||||
{
|
||||
|
@ -51,8 +51,8 @@ namespace mamba
|
|||
std::unordered_map<std::string, MatchSpec> get_requested_specs_map();
|
||||
void add_entry(const History::UserRequest& entry);
|
||||
|
||||
fs::path m_prefix;
|
||||
fs::path m_history_file_path;
|
||||
fs::u8path m_prefix;
|
||||
fs::u8path m_history_file_path;
|
||||
};
|
||||
|
||||
} // namespace mamba
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace mamba
|
|||
{
|
||||
public:
|
||||
UnlinkPackage(const PackageInfo& pkg_info,
|
||||
const fs::path& cache_path,
|
||||
const fs::u8path& cache_path,
|
||||
TransactionContext* context);
|
||||
|
||||
bool execute();
|
||||
|
@ -43,7 +43,7 @@ namespace mamba
|
|||
bool unlink_path(const nlohmann::json& path_data);
|
||||
|
||||
PackageInfo m_pkg_info;
|
||||
fs::path m_cache_path;
|
||||
fs::u8path m_cache_path;
|
||||
std::string m_specifier;
|
||||
TransactionContext* m_context;
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ namespace mamba
|
|||
{
|
||||
public:
|
||||
LinkPackage(const PackageInfo& pkg_info,
|
||||
const fs::path& cache_path,
|
||||
const fs::u8path& cache_path,
|
||||
TransactionContext* context);
|
||||
|
||||
bool execute();
|
||||
|
@ -61,16 +61,16 @@ namespace mamba
|
|||
private:
|
||||
std::tuple<std::string, std::string> link_path(const PathData& path_data,
|
||||
bool noarch_python);
|
||||
std::vector<fs::path> compile_pyc_files(const std::vector<fs::path>& py_files);
|
||||
auto create_python_entry_point(const fs::path& path,
|
||||
std::vector<fs::u8path> compile_pyc_files(const std::vector<fs::u8path>& py_files);
|
||||
auto create_python_entry_point(const fs::u8path& path,
|
||||
const python_entry_point_parsed& entry_point);
|
||||
void create_application_entry_point(const fs::path& source_full_path,
|
||||
const fs::path& target_full_path,
|
||||
const fs::path& python_full_path);
|
||||
void create_application_entry_point(const fs::u8path& source_full_path,
|
||||
const fs::u8path& target_full_path,
|
||||
const fs::u8path& python_full_path);
|
||||
|
||||
PackageInfo m_pkg_info;
|
||||
fs::path m_cache_path;
|
||||
fs::path m_source;
|
||||
fs::u8path m_cache_path;
|
||||
fs::u8path m_source;
|
||||
std::vector<std::string> m_clobber_warnings;
|
||||
TransactionContext* m_context;
|
||||
};
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
void remove_menu_from_json(const fs::path& json_file, TransactionContext* context);
|
||||
void create_menu_from_json(const fs::path& json_file, TransactionContext* context);
|
||||
void remove_menu_from_json(const fs::u8path& json_file, TransactionContext* context);
|
||||
void create_menu_from_json(const fs::u8path& json_file, TransactionContext* context);
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ namespace mamba
|
|||
class PackageCacheData
|
||||
{
|
||||
public:
|
||||
PackageCacheData(const fs::path& path);
|
||||
PackageCacheData(const fs::u8path& path);
|
||||
|
||||
bool create_directory();
|
||||
void set_writable(Writable writable);
|
||||
Writable is_writable();
|
||||
fs::path path() const;
|
||||
fs::u8path path() const;
|
||||
void clear_query_cache(const PackageInfo& s);
|
||||
|
||||
bool has_valid_tarball(const PackageInfo& s);
|
||||
|
@ -47,20 +47,20 @@ namespace mamba
|
|||
std::map<std::string, bool> m_valid_tarballs;
|
||||
std::map<std::string, bool> m_valid_extracted_dir;
|
||||
Writable m_writable = Writable::UNKNOWN;
|
||||
fs::path m_path;
|
||||
fs::u8path m_path;
|
||||
};
|
||||
|
||||
class MultiPackageCache
|
||||
{
|
||||
public:
|
||||
MultiPackageCache(const std::vector<fs::path>& pkgs_dirs);
|
||||
MultiPackageCache(const std::vector<fs::u8path>& pkgs_dirs);
|
||||
|
||||
std::vector<fs::path> paths() const;
|
||||
std::vector<fs::u8path> paths() const;
|
||||
|
||||
fs::path get_tarball_path(const PackageInfo& s, bool return_empty = true);
|
||||
fs::path get_extracted_dir_path(const PackageInfo& s, bool return_empty = true);
|
||||
fs::u8path get_tarball_path(const PackageInfo& s, bool return_empty = true);
|
||||
fs::u8path get_extracted_dir_path(const PackageInfo& s, bool return_empty = true);
|
||||
|
||||
fs::path first_writable_path();
|
||||
fs::u8path first_writable_path();
|
||||
PackageCacheData& first_writable_cache(bool create = false);
|
||||
std::vector<PackageCacheData*> writable_caches();
|
||||
|
||||
|
@ -68,8 +68,8 @@ namespace mamba
|
|||
|
||||
private:
|
||||
std::vector<PackageCacheData> m_caches;
|
||||
std::map<std::string, fs::path> m_cached_tarballs;
|
||||
std::map<std::string, fs::path> m_cached_extracted_dirs;
|
||||
std::map<std::string, fs::u8path> m_cached_tarballs;
|
||||
std::map<std::string, fs::u8path> m_cached_extracted_dirs;
|
||||
};
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -22,21 +22,23 @@ namespace mamba
|
|||
zstd
|
||||
};
|
||||
|
||||
void create_archive(const fs::path& directory,
|
||||
const fs::path& destination,
|
||||
void create_archive(const fs::u8path& directory,
|
||||
const fs::u8path& destination,
|
||||
compression_algorithm,
|
||||
int compression_level);
|
||||
void create_package(const fs::path& directory, const fs::path& out_file, int compression_level);
|
||||
void create_package(const fs::u8path& directory,
|
||||
const fs::u8path& out_file,
|
||||
int compression_level);
|
||||
|
||||
void extract_archive(const fs::path& file, const fs::path& destination);
|
||||
void extract_conda(const fs::path& file,
|
||||
const fs::path& dest_dir,
|
||||
void extract_archive(const fs::u8path& file, const fs::u8path& destination);
|
||||
void extract_conda(const fs::u8path& file,
|
||||
const fs::u8path& dest_dir,
|
||||
const std::vector<std::string>& parts = { "info", "pkg" });
|
||||
void extract(const fs::path& file, const fs::path& destination);
|
||||
fs::path extract(const fs::path& file);
|
||||
void extract_subproc(const fs::path& file, const fs::path& dest);
|
||||
bool transmute(const fs::path& pkg_file, const fs::path& target, int compression_level);
|
||||
bool validate(const fs::path& pkg_folder);
|
||||
void extract(const fs::u8path& file, const fs::u8path& destination);
|
||||
fs::u8path extract(const fs::u8path& file);
|
||||
void extract_subproc(const fs::u8path& file, const fs::u8path& dest);
|
||||
bool transmute(const fs::u8path& pkg_file, const fs::u8path& target, int compression_level);
|
||||
bool validate(const fs::u8path& pkg_folder);
|
||||
} // namespace mamba
|
||||
|
||||
#endif // MAMBA_PACKAGE_HANDLING_HPP
|
||||
|
|
|
@ -62,9 +62,9 @@ namespace mamba
|
|||
bool no_link = false;
|
||||
};
|
||||
|
||||
std::map<std::string, PrefixFileParse> read_has_prefix(const fs::path& path);
|
||||
std::set<std::string> read_no_link(const fs::path& info_dir);
|
||||
std::vector<PathData> read_paths(const fs::path& directory);
|
||||
std::map<std::string, PrefixFileParse> read_has_prefix(const fs::u8path& path);
|
||||
std::set<std::string> read_no_link(const fs::u8path& info_dir);
|
||||
std::vector<PathData> read_paths(const fs::u8path& directory);
|
||||
} // namespace mamba
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace mamba
|
|||
{
|
||||
std::string python_pin(const PrefixData& prefix_data, const std::vector<std::string>& specs);
|
||||
|
||||
std::vector<std::string> file_pins(const fs::path& file);
|
||||
std::vector<std::string> file_pins(const fs::u8path& file);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,23 +21,23 @@ namespace mamba
|
|||
public:
|
||||
using package_map = std::unordered_map<std::string, PackageInfo>;
|
||||
|
||||
static expected_t<PrefixData> create(const fs::path& prefix_path);
|
||||
static expected_t<PrefixData> create(const fs::u8path& prefix_path);
|
||||
|
||||
void add_packages(const std::vector<PackageInfo>& packages);
|
||||
const package_map& records() const;
|
||||
void load_single_record(const fs::path& path);
|
||||
void load_single_record(const fs::u8path& path);
|
||||
|
||||
History& history();
|
||||
const fs::path& path() const;
|
||||
const fs::u8path& path() const;
|
||||
std::vector<PackageInfo> sorted_records() const;
|
||||
|
||||
private:
|
||||
PrefixData(const fs::path& prefix_path);
|
||||
PrefixData(const fs::u8path& prefix_path);
|
||||
void load();
|
||||
|
||||
History m_history;
|
||||
std::unordered_map<std::string, PackageInfo> m_package_records;
|
||||
fs::path m_prefix_path;
|
||||
fs::u8path m_prefix_path;
|
||||
};
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace mamba
|
|||
void add_package_info(Repodata*, const PackageInfo& pkg_info);
|
||||
void add_pip_as_python_dependency();
|
||||
|
||||
const fs::path& index_file();
|
||||
const fs::u8path& index_file();
|
||||
|
||||
Id id() const;
|
||||
std::string name() const;
|
||||
|
@ -100,7 +100,7 @@ namespace mamba
|
|||
*/
|
||||
static MRepo& create(MPool& pool,
|
||||
const std::string& name,
|
||||
const fs::path& filename,
|
||||
const fs::u8path& filename,
|
||||
const RepoMetadata& meta,
|
||||
const Channel& channel);
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace mamba
|
|||
|
||||
MRepo(MPool& pool,
|
||||
const std::string& name,
|
||||
const fs::path& filename,
|
||||
const fs::u8path& filename,
|
||||
const RepoMetadata& meta,
|
||||
const Channel& channel);
|
||||
|
||||
|
@ -137,9 +137,9 @@ namespace mamba
|
|||
|
||||
MRepo(MPool& pool, const std::string& name, const std::vector<PackageInfo>& uris);
|
||||
|
||||
bool read_file(const fs::path& filename);
|
||||
bool read_file(const fs::u8path& filename);
|
||||
|
||||
fs::path m_json_file, m_solv_file;
|
||||
fs::u8path m_json_file, m_solv_file;
|
||||
std::string m_url;
|
||||
|
||||
RepoMetadata m_metadata;
|
||||
|
|
|
@ -27,44 +27,44 @@ namespace mamba
|
|||
std::string guess_shell();
|
||||
|
||||
#ifdef _WIN32
|
||||
void init_cmd_exe_registry(const std::wstring& reg_path, const fs::path& conda_prefix);
|
||||
void init_cmd_exe_registry(const std::wstring& reg_path, const fs::u8path& conda_prefix);
|
||||
#endif
|
||||
|
||||
fs::path get_self_exe_path();
|
||||
fs::u8path get_self_exe_path();
|
||||
std::string get_hook_contents(const std::string& shell);
|
||||
|
||||
// this function calls cygpath to convert win path to unix
|
||||
std::string native_path_to_unix(const std::string& path, bool is_a_path_env = false);
|
||||
|
||||
std::string rcfile_content(const fs::path& env_prefix,
|
||||
std::string rcfile_content(const fs::u8path& env_prefix,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe);
|
||||
const fs::u8path& mamba_exe);
|
||||
|
||||
std::string xonsh_content(const fs::path& env_prefix,
|
||||
std::string xonsh_content(const fs::u8path& env_prefix,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe);
|
||||
const fs::u8path& mamba_exe);
|
||||
|
||||
void modify_rc_file(const fs::path& file_path,
|
||||
const fs::path& conda_prefix,
|
||||
void modify_rc_file(const fs::u8path& file_path,
|
||||
const fs::u8path& conda_prefix,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe);
|
||||
const fs::u8path& mamba_exe);
|
||||
|
||||
void reset_rc_file(const fs::path& file_path,
|
||||
void reset_rc_file(const fs::u8path& file_path,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe);
|
||||
const fs::u8path& mamba_exe);
|
||||
|
||||
// we need this function during linking...
|
||||
void init_root_prefix_cmdexe(const fs::path& root_prefix);
|
||||
void deinit_root_prefix_cmdexe(const fs::path& root_prefix);
|
||||
void init_root_prefix(const std::string& shell, const fs::path& root_prefix);
|
||||
void deinit_root_prefix(const std::string& shell, const fs::path& root_prefix);
|
||||
void init_root_prefix_cmdexe(const fs::u8path& root_prefix);
|
||||
void deinit_root_prefix_cmdexe(const fs::u8path& root_prefix);
|
||||
void init_root_prefix(const std::string& shell, const fs::u8path& root_prefix);
|
||||
void deinit_root_prefix(const std::string& shell, const fs::u8path& root_prefix);
|
||||
|
||||
std::string powershell_contents(const fs::path& conda_prefix);
|
||||
void init_powershell(const fs::path& profile_path, const fs::path& conda_prefix);
|
||||
void deinit_powershell(const fs::path& profile_path, const fs::path& conda_prefix);
|
||||
std::string powershell_contents(const fs::u8path& conda_prefix);
|
||||
void init_powershell(const fs::u8path& profile_path, const fs::u8path& conda_prefix);
|
||||
void deinit_powershell(const fs::u8path& profile_path, const fs::u8path& conda_prefix);
|
||||
|
||||
void init_shell(const std::string& shell, const fs::path& conda_prefix);
|
||||
void deinit_shell(const std::string& shell, const fs::path& conda_prefix);
|
||||
void init_shell(const std::string& shell, const fs::u8path& conda_prefix);
|
||||
void deinit_shell(const std::string& shell, const fs::u8path& conda_prefix);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace mamba
|
|||
MSubdirData& operator=(MSubdirData&&);
|
||||
|
||||
// TODO return seconds as double
|
||||
fs::file_time_type::duration check_cache(const fs::path& cache_file,
|
||||
fs::file_time_type::duration check_cache(const fs::u8path& cache_file,
|
||||
const fs::file_time_type::clock::time_point& ref);
|
||||
bool loaded() const;
|
||||
|
||||
|
@ -87,9 +87,9 @@ namespace mamba
|
|||
bool m_json_cache_valid = false;
|
||||
bool m_solv_cache_valid = false;
|
||||
|
||||
fs::path m_valid_cache_path;
|
||||
fs::path m_expired_cache_path;
|
||||
fs::path m_writable_pkgs_dir;
|
||||
fs::u8path m_valid_cache_path;
|
||||
fs::u8path m_expired_cache_path;
|
||||
fs::u8path m_writable_pkgs_dir;
|
||||
|
||||
ProgressProxy m_progress_bar;
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace mamba
|
|||
// concatenate base url and repodata depending on repodata value
|
||||
// and old behavior support.
|
||||
std::string cache_fn_url(const std::string& url);
|
||||
std::string create_cache_dir(const fs::path& cache_path);
|
||||
std::string create_cache_dir(const fs::u8path& cache_path);
|
||||
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace mamba
|
|||
PackageDownloadExtractTarget(Solvable* solvable);
|
||||
PackageDownloadExtractTarget(const PackageInfo& pkg_info);
|
||||
|
||||
void write_repodata_record(const fs::path& base_path);
|
||||
void write_repodata_record(const fs::u8path& base_path);
|
||||
void add_url();
|
||||
bool finalize_callback();
|
||||
bool finished();
|
||||
|
@ -86,7 +86,7 @@ namespace mamba
|
|||
std::unique_ptr<DownloadTarget> m_target;
|
||||
|
||||
std::string m_url, m_name, m_filename;
|
||||
fs::path m_tarball_path, m_cache_path;
|
||||
fs::u8path m_tarball_path, m_cache_path;
|
||||
|
||||
std::future<bool> m_extract_future;
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace mamba
|
|||
|
||||
TransactionContext m_transaction_context;
|
||||
MultiPackageCache m_multi_cache;
|
||||
const fs::path m_cache_path;
|
||||
const fs::u8path m_cache_path;
|
||||
std::vector<Solvable*> m_to_install, m_to_remove;
|
||||
|
||||
History::UserRequest m_history_entry;
|
||||
|
@ -175,7 +175,7 @@ namespace mamba
|
|||
MultiPackageCache& package_caches);
|
||||
|
||||
MTransaction create_explicit_transaction_from_lockfile(MPool& pool,
|
||||
const fs::path& env_lockfile_path,
|
||||
const fs::u8path& env_lockfile_path,
|
||||
MultiPackageCache& package_caches);
|
||||
} // namespace mamba
|
||||
|
||||
|
|
|
@ -20,28 +20,28 @@ namespace mamba
|
|||
{
|
||||
std::string compute_short_python_version(const std::string& long_version);
|
||||
// supply short python version, e.g. 2.7, 3.5...
|
||||
fs::path get_python_short_path(const std::string& python_version);
|
||||
fs::path get_python_site_packages_short_path(const std::string& python_version);
|
||||
fs::path get_bin_directory_short_path();
|
||||
fs::path get_python_noarch_target_path(const std::string& source_short_path,
|
||||
const fs::path& target_site_packages_short_path);
|
||||
fs::u8path get_python_short_path(const std::string& python_version);
|
||||
fs::u8path get_python_site_packages_short_path(const std::string& python_version);
|
||||
fs::u8path get_bin_directory_short_path();
|
||||
fs::u8path get_python_noarch_target_path(const std::string& source_short_path,
|
||||
const fs::u8path& target_site_packages_short_path);
|
||||
|
||||
class TransactionContext
|
||||
{
|
||||
public:
|
||||
TransactionContext();
|
||||
TransactionContext& operator=(const TransactionContext&);
|
||||
TransactionContext(const fs::path& target_prefix,
|
||||
TransactionContext(const fs::u8path& target_prefix,
|
||||
const std::pair<std::string, std::string>& py_versions,
|
||||
const std::vector<MatchSpec>& requested_specs);
|
||||
~TransactionContext();
|
||||
bool try_pyc_compilation(const std::vector<fs::path>& py_files);
|
||||
bool try_pyc_compilation(const std::vector<fs::u8path>& py_files);
|
||||
void wait_for_pyc_compilation();
|
||||
|
||||
bool has_python;
|
||||
fs::path target_prefix;
|
||||
fs::path site_packages_path;
|
||||
fs::path python_path;
|
||||
fs::u8path target_prefix;
|
||||
fs::u8path site_packages_path;
|
||||
fs::u8path python_path;
|
||||
std::string python_version;
|
||||
std::string old_python_version;
|
||||
std::string short_python_version;
|
||||
|
|
|
@ -47,16 +47,16 @@ namespace mamba
|
|||
|
||||
bool is_package_file(const std::string_view& fn);
|
||||
|
||||
bool lexists(const fs::path& p);
|
||||
bool lexists(const fs::path& p, std::error_code& ec);
|
||||
std::vector<fs::path> filter_dir(const fs::path& dir, const std::string& suffix);
|
||||
bool paths_equal(const fs::path& lhs, const fs::path& rhs);
|
||||
bool lexists(const fs::u8path& p);
|
||||
bool lexists(const fs::u8path& p, std::error_code& ec);
|
||||
std::vector<fs::u8path> filter_dir(const fs::u8path& dir, const std::string& suffix);
|
||||
bool paths_equal(const fs::u8path& lhs, const fs::u8path& rhs);
|
||||
|
||||
std::string read_contents(const fs::path& path,
|
||||
std::string read_contents(const fs::u8path& path,
|
||||
std::ios::openmode mode = std::ios::in | std::ios::binary);
|
||||
std::vector<std::string> read_lines(const fs::path& path);
|
||||
std::vector<std::string> read_lines(const fs::u8path& path);
|
||||
|
||||
inline void make_executable(const fs::path& p)
|
||||
inline void make_executable(const fs::u8path& p)
|
||||
{
|
||||
fs::permissions(p,
|
||||
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_read
|
||||
|
@ -73,11 +73,11 @@ namespace mamba
|
|||
TemporaryDirectory& operator=(const TemporaryDirectory&) = delete;
|
||||
TemporaryDirectory& operator=(TemporaryDirectory&&) = default;
|
||||
|
||||
fs::path& path();
|
||||
operator fs::path();
|
||||
const fs::u8path& path() const;
|
||||
operator fs::u8path();
|
||||
|
||||
private:
|
||||
fs::path m_path;
|
||||
fs::u8path m_path;
|
||||
};
|
||||
|
||||
class TemporaryFile
|
||||
|
@ -90,11 +90,11 @@ namespace mamba
|
|||
TemporaryFile& operator=(const TemporaryFile&) = delete;
|
||||
TemporaryFile& operator=(TemporaryFile&&) = default;
|
||||
|
||||
fs::path& path();
|
||||
operator fs::path();
|
||||
fs::u8path& path();
|
||||
operator fs::u8path();
|
||||
|
||||
private:
|
||||
fs::path m_path;
|
||||
fs::u8path m_path;
|
||||
};
|
||||
|
||||
const std::size_t MAMBA_LOCK_POS = 21;
|
||||
|
@ -102,23 +102,23 @@ namespace mamba
|
|||
class LockFile
|
||||
{
|
||||
public:
|
||||
LockFile(const fs::path& path);
|
||||
LockFile(const fs::path& path, const std::chrono::seconds& timeout);
|
||||
LockFile(const fs::u8path& path);
|
||||
LockFile(const fs::u8path& path, const std::chrono::seconds& timeout);
|
||||
~LockFile();
|
||||
|
||||
LockFile(const LockFile&) = delete;
|
||||
LockFile& operator=(const LockFile&) = delete;
|
||||
LockFile& operator=(LockFile&&) = default;
|
||||
|
||||
static std::unique_ptr<LockFile> try_lock(const fs::path& path) noexcept;
|
||||
static std::unique_ptr<LockFile> try_lock(const fs::u8path& path) noexcept;
|
||||
|
||||
int fd() const;
|
||||
fs::path path() const;
|
||||
fs::path lockfile_path() const;
|
||||
fs::u8path path() const;
|
||||
fs::u8path lockfile_path() const;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Using file descriptor on Windows may cause false negative
|
||||
static bool is_locked(const fs::path& path);
|
||||
static bool is_locked(const fs::u8path& path);
|
||||
#else
|
||||
// Opening a new file descriptor on Unix would clear locks
|
||||
static bool is_locked(int fd);
|
||||
|
@ -126,8 +126,8 @@ namespace mamba
|
|||
static int read_pid(int fd);
|
||||
|
||||
private:
|
||||
fs::path m_path;
|
||||
fs::path m_lock;
|
||||
fs::u8path m_path;
|
||||
fs::u8path m_lock;
|
||||
std::chrono::seconds m_timeout;
|
||||
int m_fd = -1;
|
||||
bool m_locked;
|
||||
|
@ -246,7 +246,7 @@ namespace mamba
|
|||
void split_package_extension(const std::string& file,
|
||||
std::string& name,
|
||||
std::string& extension);
|
||||
fs::path strip_package_extension(const std::string& file);
|
||||
fs::u8path strip_package_extension(const std::string& file);
|
||||
|
||||
template <class T>
|
||||
inline bool vector_is_prefix(const std::vector<T>& prefix, const std::vector<T>& vec)
|
||||
|
@ -259,7 +259,7 @@ namespace mamba
|
|||
{
|
||||
struct PlusEqual
|
||||
{
|
||||
template<typename T, typename U>
|
||||
template <typename T, typename U>
|
||||
auto operator()(T& left, const U& right)
|
||||
{
|
||||
left += right;
|
||||
|
@ -383,8 +383,8 @@ namespace mamba
|
|||
std::string quote_for_shell(const std::vector<std::string>& arguments,
|
||||
const std::string& shell = "");
|
||||
|
||||
std::size_t clean_trash_files(const fs::path& prefix, bool deep_clean);
|
||||
std::size_t remove_or_rename(const fs::path& path);
|
||||
std::size_t clean_trash_files(const fs::u8path& prefix, bool deep_clean);
|
||||
std::size_t remove_or_rename(const fs::u8path& path);
|
||||
|
||||
// Unindent a string literal
|
||||
std::string unindent(const char* p);
|
||||
|
@ -403,21 +403,21 @@ namespace mamba
|
|||
|
||||
std::time_t parse_utc_timestamp(const std::string& timestamp);
|
||||
|
||||
std::ofstream open_ofstream(const fs::path& path,
|
||||
std::ofstream open_ofstream(const fs::u8path& path,
|
||||
std::ios::openmode mode = std::ios::out | std::ios::binary);
|
||||
|
||||
std::ifstream open_ifstream(const fs::path& path,
|
||||
std::ifstream open_ifstream(const fs::u8path& path,
|
||||
std::ios::openmode mode = std::ios::in | std::ios::binary);
|
||||
|
||||
bool ensure_comspec_set();
|
||||
std::unique_ptr<TemporaryFile> wrap_call(const fs::path& root_prefix,
|
||||
const fs::path& prefix,
|
||||
std::unique_ptr<TemporaryFile> wrap_call(const fs::u8path& root_prefix,
|
||||
const fs::u8path& prefix,
|
||||
bool dev_mode,
|
||||
bool debug_wrapper_scripts,
|
||||
const std::vector<std::string>& arguments);
|
||||
|
||||
std::tuple<std::vector<std::string>, std::unique_ptr<TemporaryFile>> prepare_wrapped_call(
|
||||
const fs::path& prefix, const std::vector<std::string>& cmd);
|
||||
const fs::u8path& prefix, const std::vector<std::string>& cmd);
|
||||
|
||||
/// Returns `true` if the filename matches names of files which should be interpreted as YAML.
|
||||
/// NOTE: this does not check if the file exists.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace mamba
|
||||
{
|
||||
bool is_admin();
|
||||
fs::path get_self_exe_path();
|
||||
fs::u8path get_self_exe_path();
|
||||
|
||||
using PID =
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -21,11 +21,11 @@ namespace validate
|
|||
{
|
||||
using nlohmann::json;
|
||||
|
||||
std::string sha256sum(const fs::path& path);
|
||||
std::string md5sum(const fs::path& path);
|
||||
bool sha256(const fs::path& path, const std::string& validation);
|
||||
bool md5(const fs::path& path, const std::string& validation);
|
||||
bool file_size(const fs::path& path, std::uintmax_t validation);
|
||||
std::string sha256sum(const fs::u8path& path);
|
||||
std::string md5sum(const fs::u8path& path);
|
||||
bool sha256(const fs::u8path& path, const std::string& validation);
|
||||
bool md5(const fs::u8path& path, const std::string& validation);
|
||||
bool file_size(const fs::u8path& path, std::uintmax_t validation);
|
||||
|
||||
const std::size_t MAMBA_SHA256_SIZE_HEX = 64;
|
||||
const std::size_t MAMBA_SHA256_SIZE_BYTES = 32;
|
||||
|
@ -354,7 +354,7 @@ namespace validate
|
|||
std::string compatible_prefix() const;
|
||||
std::vector<std::string> upgrade_prefix() const;
|
||||
|
||||
bool is_compatible(const fs::path& p) const;
|
||||
bool is_compatible(const fs::u8path& p) const;
|
||||
bool is_compatible(const json& j) const;
|
||||
bool is_compatible(const std::string& version) const;
|
||||
|
||||
|
@ -410,7 +410,7 @@ namespace validate
|
|||
friend void from_json(const json& j, RoleBase* r);
|
||||
|
||||
protected:
|
||||
json read_json_file(const fs::path& p, bool update = false) const;
|
||||
json read_json_file(const fs::u8path& p, bool update = false) const;
|
||||
|
||||
/**
|
||||
* Check that a threshold of valid signatures is met
|
||||
|
@ -467,13 +467,13 @@ namespace validate
|
|||
public:
|
||||
virtual ~RootRole() = default;
|
||||
|
||||
std::unique_ptr<RootRole> update(fs::path path);
|
||||
std::unique_ptr<RootRole> update(fs::u8path path);
|
||||
std::unique_ptr<RootRole> update(json j);
|
||||
|
||||
std::vector<fs::path> possible_update_files();
|
||||
std::vector<fs::u8path> possible_update_files();
|
||||
|
||||
virtual std::unique_ptr<RepoIndexChecker> build_index_checker(
|
||||
const std::string& url, const fs::path& cache_path) const = 0;
|
||||
const std::string& url, const fs::u8path& cache_path) const = 0;
|
||||
|
||||
protected:
|
||||
RootRole(std::shared_ptr<SpecBase> spec);
|
||||
|
@ -492,7 +492,7 @@ namespace validate
|
|||
public:
|
||||
virtual ~RepoIndexChecker() = default;
|
||||
virtual void verify_index(const json& j) const = 0;
|
||||
virtual void verify_index(const fs::path& p) const = 0;
|
||||
virtual void verify_index(const fs::u8path& p) const = 0;
|
||||
virtual void verify_package(const json& signed_data, const json& signatures) const = 0;
|
||||
|
||||
protected:
|
||||
|
@ -515,31 +515,31 @@ namespace validate
|
|||
* @param cache_path Path to the cache directory
|
||||
*/
|
||||
RepoChecker(const std::string& base_url,
|
||||
const fs::path& ref_path,
|
||||
const fs::path& cache_path = "");
|
||||
const fs::u8path& ref_path,
|
||||
const fs::u8path& cache_path = "");
|
||||
|
||||
// Forwarding to a ``RepoIndexChecker`` implementation
|
||||
void verify_index(const json& j) const;
|
||||
void verify_index(const fs::path& p) const;
|
||||
void verify_index(const fs::u8path& p) const;
|
||||
void verify_package(const json& signed_data, const json& signatures) const;
|
||||
|
||||
void generate_index_checker();
|
||||
|
||||
const fs::path& cache_path();
|
||||
const fs::u8path& cache_path();
|
||||
|
||||
std::size_t root_version();
|
||||
|
||||
private:
|
||||
std::string m_base_url;
|
||||
std::size_t m_root_version = 0;
|
||||
fs::path m_ref_path;
|
||||
fs::path m_cache_path;
|
||||
fs::u8path m_ref_path;
|
||||
fs::u8path m_cache_path;
|
||||
|
||||
fs::path initial_trusted_root();
|
||||
fs::path ref_root();
|
||||
fs::path cached_root();
|
||||
fs::u8path initial_trusted_root();
|
||||
fs::u8path ref_root();
|
||||
fs::u8path cached_root();
|
||||
|
||||
void persist_file(const fs::path& file_path);
|
||||
void persist_file(const fs::u8path& file_path);
|
||||
|
||||
std::unique_ptr<RepoIndexChecker> p_index_checker;
|
||||
|
||||
|
@ -572,13 +572,13 @@ namespace validate
|
|||
class RootImpl final : public RootRole
|
||||
{
|
||||
public:
|
||||
RootImpl(const fs::path& p);
|
||||
RootImpl(const fs::u8path& p);
|
||||
RootImpl(const json& j);
|
||||
|
||||
RoleFullKeys self_keys() const override;
|
||||
|
||||
std::unique_ptr<RepoIndexChecker> build_index_checker(
|
||||
const std::string& url, const fs::path& cache_path) const override;
|
||||
const std::string& url, const fs::u8path& cache_path) const override;
|
||||
|
||||
friend void to_json(json& j, const RootImpl& r);
|
||||
friend void from_json(const json& j, RootImpl& r);
|
||||
|
@ -643,7 +643,7 @@ namespace validate
|
|||
, public V06RoleBaseExtension
|
||||
{
|
||||
public:
|
||||
RootImpl(const fs::path& p);
|
||||
RootImpl(const fs::u8path& p);
|
||||
RootImpl(const json& j);
|
||||
RootImpl(const std::string& json_str);
|
||||
|
||||
|
@ -652,7 +652,7 @@ namespace validate
|
|||
* from repository base URL.
|
||||
*/
|
||||
std::unique_ptr<RepoIndexChecker> build_index_checker(
|
||||
const std::string& url, const fs::path& cache_path) const override;
|
||||
const std::string& url, const fs::u8path& cache_path) const override;
|
||||
|
||||
RoleFullKeys self_keys() const override;
|
||||
|
||||
|
@ -661,7 +661,7 @@ namespace validate
|
|||
const std::string& pk,
|
||||
const unsigned char* sk) const;
|
||||
|
||||
KeyMgrRole create_key_mgr(const fs::path& p) const;
|
||||
KeyMgrRole create_key_mgr(const fs::u8path& p) const;
|
||||
KeyMgrRole create_key_mgr(const json& j) const;
|
||||
|
||||
friend void to_json(json& j, const RootImpl& r);
|
||||
|
@ -692,7 +692,7 @@ namespace validate
|
|||
, public V06RoleBaseExtension
|
||||
{
|
||||
public:
|
||||
KeyMgrRole(const fs::path& p,
|
||||
KeyMgrRole(const fs::u8path& p,
|
||||
const RoleFullKeys& keys,
|
||||
const std::shared_ptr<SpecBase> spec);
|
||||
KeyMgrRole(const json& j,
|
||||
|
@ -705,15 +705,15 @@ namespace validate
|
|||
// std::set<std::string> roles() const override;
|
||||
RoleFullKeys self_keys() const override;
|
||||
|
||||
PkgMgrRole create_pkg_mgr(const fs::path& p) const;
|
||||
PkgMgrRole create_pkg_mgr(const fs::u8path& p) const;
|
||||
PkgMgrRole create_pkg_mgr(const json& j) const;
|
||||
|
||||
/**
|
||||
* Return a ``RepoIndexChecker`` implementation (derived class)
|
||||
* from repository base URL.
|
||||
*/
|
||||
std::unique_ptr<RepoIndexChecker> build_index_checker(const std::string& url,
|
||||
const fs::path& cache_path) const;
|
||||
std::unique_ptr<RepoIndexChecker> build_index_checker(
|
||||
const std::string& url, const fs::u8path& cache_path) const;
|
||||
|
||||
friend void to_json(json& j, const KeyMgrRole& r);
|
||||
friend void from_json(const json& j, KeyMgrRole& r);
|
||||
|
@ -746,7 +746,7 @@ namespace validate
|
|||
{
|
||||
public:
|
||||
PkgMgrRole(const RoleFullKeys& keys, const std::shared_ptr<SpecBase> spec);
|
||||
PkgMgrRole(const fs::path& p,
|
||||
PkgMgrRole(const fs::u8path& p,
|
||||
const RoleFullKeys& keys,
|
||||
const std::shared_ptr<SpecBase> spec);
|
||||
PkgMgrRole(const json& j,
|
||||
|
@ -756,7 +756,7 @@ namespace validate
|
|||
const RoleFullKeys& keys,
|
||||
const std::shared_ptr<SpecBase> spec);
|
||||
|
||||
void verify_index(const fs::path& p) const override;
|
||||
void verify_index(const fs::u8path& p) const override;
|
||||
void verify_index(const json& j) const override;
|
||||
void verify_package(const json& signed_data, const json& signatures) const override;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace mamba
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
MRepo& create_repo_from_pkgs_dir(MPool& pool, const fs::path& pkgs_dir)
|
||||
MRepo& create_repo_from_pkgs_dir(MPool& pool, const fs::u8path& pkgs_dir)
|
||||
{
|
||||
if (!fs::exists(pkgs_dir))
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace mamba
|
|||
PrefixData& prefix_data = sprefix_data.value();
|
||||
for (const auto& entry : fs::directory_iterator(pkgs_dir))
|
||||
{
|
||||
fs::path repodata_record_json = entry.path() / "info" / "repodata_record.json";
|
||||
fs::u8path repodata_record_json = entry.path() / "info" / "repodata_record.json";
|
||||
if (!fs::exists(repodata_record_json))
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace mamba
|
|||
|
||||
Console::stream() << "Collect information..";
|
||||
|
||||
std::vector<fs::path> envs;
|
||||
std::vector<fs::u8path> envs;
|
||||
|
||||
MultiPackageCache caches(ctx.pkgs_dirs);
|
||||
if (!ctx.dry_run && (clean_index || clean_all))
|
||||
|
@ -156,7 +156,7 @@ namespace mamba
|
|||
|
||||
auto collect_tarballs = [&]()
|
||||
{
|
||||
std::vector<fs::path> res;
|
||||
std::vector<fs::u8path> res;
|
||||
std::size_t total_size = 0;
|
||||
std::vector<printers::FormattedString> header = { "Package file", "Size" };
|
||||
mamba::printers::Table t(header);
|
||||
|
@ -230,7 +230,7 @@ namespace mamba
|
|||
|
||||
auto collect_package_folders = [&]()
|
||||
{
|
||||
std::vector<fs::path> res;
|
||||
std::vector<fs::u8path> res;
|
||||
std::size_t total_size = 0;
|
||||
std::vector<printers::FormattedString> header = { "Package folder", "Size" };
|
||||
mamba::printers::Table t(header);
|
||||
|
@ -246,7 +246,8 @@ namespace mamba
|
|||
{
|
||||
if (p.is_directory() && fs::exists(p.path() / "info" / "index.json"))
|
||||
{
|
||||
if (installed_pkgs.find(p.path().filename().string()) != installed_pkgs.end())
|
||||
if (installed_pkgs.find(p.path().filename().string())
|
||||
!= installed_pkgs.end())
|
||||
{
|
||||
// do not remove installed packages
|
||||
continue;
|
||||
|
|
|
@ -422,7 +422,7 @@ namespace mamba
|
|||
file_spec_env_name_hook(name);
|
||||
|
||||
auto& config = Configuration::instance();
|
||||
auto& root_prefix = config.at("root_prefix").value<fs::path>();
|
||||
auto& root_prefix = config.at("root_prefix").value<fs::u8path>();
|
||||
|
||||
auto& env_name = config.at("env_name");
|
||||
|
||||
|
@ -445,7 +445,7 @@ namespace mamba
|
|||
|
||||
if (!name.empty())
|
||||
{
|
||||
fs::path prefix;
|
||||
fs::u8path prefix;
|
||||
if (name == "base")
|
||||
{
|
||||
prefix = root_prefix;
|
||||
|
@ -457,7 +457,7 @@ namespace mamba
|
|||
|
||||
if (!config.at("target_prefix").cli_configured()
|
||||
&& config.at("env_name").cli_configured())
|
||||
config.at("target_prefix").set_cli_value<fs::path>(prefix);
|
||||
config.at("target_prefix").set_cli_value<fs::u8path>(prefix);
|
||||
|
||||
if (!config.at("target_prefix").api_configured()
|
||||
&& config.at("env_name").api_configured())
|
||||
|
@ -465,10 +465,10 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void target_prefix_hook(fs::path& prefix)
|
||||
void target_prefix_hook(fs::u8path& prefix)
|
||||
{
|
||||
auto& config = Configuration::instance();
|
||||
auto& root_prefix = config.at("root_prefix").value<fs::path>();
|
||||
auto& root_prefix = config.at("root_prefix").value<fs::u8path>();
|
||||
|
||||
if (!prefix.empty())
|
||||
{
|
||||
|
@ -509,7 +509,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void root_prefix_hook(fs::path& prefix)
|
||||
void root_prefix_hook(fs::u8path& prefix)
|
||||
{
|
||||
auto& env_name = Configuration::instance().at("env_name");
|
||||
|
||||
|
@ -571,7 +571,7 @@ namespace mamba
|
|||
void rc_loading_hook(const RCConfigLevel& level)
|
||||
{
|
||||
auto& config = Configuration::instance();
|
||||
auto& rc_files = config.at("rc_files").value<std::vector<fs::path>>();
|
||||
auto& rc_files = config.at("rc_files").value<std::vector<fs::u8path>>();
|
||||
config.set_rc_values(rc_files, level);
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void rc_files_hook(std::vector<fs::path>& files)
|
||||
void rc_files_hook(std::vector<fs::u8path>& files)
|
||||
{
|
||||
auto& ctx = Context::instance();
|
||||
|
||||
|
@ -741,12 +741,12 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> fallback_envs_dirs_hook()
|
||||
std::vector<fs::u8path> fallback_envs_dirs_hook()
|
||||
{
|
||||
return { Context::instance().root_prefix / "envs" };
|
||||
}
|
||||
|
||||
void envs_dirs_hook(std::vector<fs::path>& dirs)
|
||||
void envs_dirs_hook(std::vector<fs::u8path>& dirs)
|
||||
{
|
||||
for (auto& d : dirs)
|
||||
{
|
||||
|
@ -759,21 +759,21 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> fallback_pkgs_dirs_hook()
|
||||
std::vector<fs::u8path> fallback_pkgs_dirs_hook()
|
||||
{
|
||||
std::vector<fs::path> paths = { Context::instance().root_prefix / "pkgs",
|
||||
env::home_directory() / ".mamba" / "pkgs" };
|
||||
std::vector<fs::u8path> paths = { Context::instance().root_prefix / "pkgs",
|
||||
env::home_directory() / ".mamba" / "pkgs" };
|
||||
#ifdef _WIN32
|
||||
auto appdata = env::get("APPDATA");
|
||||
if (appdata)
|
||||
{
|
||||
paths.push_back(fs::path(appdata.value()) / ".mamba" / "pkgs");
|
||||
paths.push_back(fs::u8path(appdata.value()) / ".mamba" / "pkgs");
|
||||
}
|
||||
#endif
|
||||
return paths;
|
||||
}
|
||||
|
||||
void pkgs_dirs_hook(std::vector<fs::path>& dirs)
|
||||
void pkgs_dirs_hook(std::vector<fs::u8path>& dirs)
|
||||
{
|
||||
for (auto& d : dirs)
|
||||
{
|
||||
|
@ -799,7 +799,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
fs::path get_conda_root_prefix()
|
||||
fs::u8path get_conda_root_prefix()
|
||||
{
|
||||
std::vector<std::string> args = { "conda", "config", "--show", "root_prefix", "--json" };
|
||||
std::string out, err;
|
||||
|
@ -836,13 +836,12 @@ namespace mamba
|
|||
{
|
||||
bool has_config_name(const std::string& file)
|
||||
{
|
||||
return fs::path(file).filename() == ".condarc" || fs::path(file).filename() == "condarc"
|
||||
|| fs::path(file).filename() == ".mambarc"
|
||||
|| fs::path(file).filename() == "mambarc" || ends_with(file, ".yml")
|
||||
|| ends_with(file, ".yaml");
|
||||
const auto filename = fs::u8path(file).filename();
|
||||
return filename == ".condarc" || filename == "condarc" || filename == ".mambarc"
|
||||
|| filename == "mambarc" || ends_with(file, ".yml") || ends_with(file, ".yaml");
|
||||
}
|
||||
|
||||
bool is_config_file(const fs::path& path)
|
||||
bool is_config_file(const fs::u8path& path)
|
||||
{
|
||||
return fs::exists(path) && (!fs::is_directory(path)) && has_config_name(path.string());
|
||||
}
|
||||
|
@ -1532,7 +1531,7 @@ namespace mamba
|
|||
not be considered as logs (see log_level).)")));
|
||||
|
||||
// Config
|
||||
insert(Configurable("rc_files", std::vector<fs::path>({}))
|
||||
insert(Configurable("rc_files", std::vector<fs::u8path>({}))
|
||||
.group("Config sources")
|
||||
.set_env_var_names({ "MAMBARC", "CONDARC" })
|
||||
.needs({ "no_rc" })
|
||||
|
@ -1589,11 +1588,11 @@ namespace mamba
|
|||
return res;
|
||||
}
|
||||
|
||||
std::vector<fs::path> Configuration::compute_default_rc_sources(const RCConfigLevel& level)
|
||||
std::vector<fs::u8path> Configuration::compute_default_rc_sources(const RCConfigLevel& level)
|
||||
{
|
||||
auto& ctx = Context::instance();
|
||||
|
||||
std::vector<fs::path> system;
|
||||
std::vector<fs::u8path> system;
|
||||
if constexpr (on_mac || on_linux)
|
||||
{
|
||||
system = { "/etc/conda/.condarc", "/etc/conda/condarc",
|
||||
|
@ -1609,23 +1608,23 @@ namespace mamba
|
|||
"C:\\ProgramData\\conda\\.mambarc" };
|
||||
}
|
||||
|
||||
std::vector<fs::path> root = { ctx.root_prefix / ".condarc",
|
||||
ctx.root_prefix / "condarc",
|
||||
ctx.root_prefix / "condarc.d",
|
||||
ctx.root_prefix / ".mambarc" };
|
||||
std::vector<fs::u8path> root = { ctx.root_prefix / ".condarc",
|
||||
ctx.root_prefix / "condarc",
|
||||
ctx.root_prefix / "condarc.d",
|
||||
ctx.root_prefix / ".mambarc" };
|
||||
|
||||
std::vector<fs::path> home = { env::home_directory() / ".conda/.condarc",
|
||||
env::home_directory() / ".conda/condarc",
|
||||
env::home_directory() / ".conda/condarc.d",
|
||||
env::home_directory() / ".condarc",
|
||||
env::home_directory() / ".mambarc" };
|
||||
std::vector<fs::u8path> home = { env::home_directory() / ".conda/.condarc",
|
||||
env::home_directory() / ".conda/condarc",
|
||||
env::home_directory() / ".conda/condarc.d",
|
||||
env::home_directory() / ".condarc",
|
||||
env::home_directory() / ".mambarc" };
|
||||
|
||||
std::vector<fs::path> prefix = { ctx.target_prefix / ".condarc",
|
||||
ctx.target_prefix / "condarc",
|
||||
ctx.target_prefix / "condarc.d",
|
||||
ctx.target_prefix / ".mambarc" };
|
||||
std::vector<fs::u8path> prefix = { ctx.target_prefix / ".condarc",
|
||||
ctx.target_prefix / "condarc",
|
||||
ctx.target_prefix / "condarc.d",
|
||||
ctx.target_prefix / ".mambarc" };
|
||||
|
||||
std::vector<fs::path> sources;
|
||||
std::vector<fs::u8path> sources;
|
||||
|
||||
if (level >= RCConfigLevel::kSystemDir)
|
||||
sources.insert(sources.end(), system.begin(), system.end());
|
||||
|
@ -1777,12 +1776,12 @@ namespace mamba
|
|||
c.second.clear_cli_value();
|
||||
}
|
||||
|
||||
std::vector<fs::path> Configuration::sources()
|
||||
std::vector<fs::u8path> Configuration::sources()
|
||||
{
|
||||
return m_sources;
|
||||
}
|
||||
|
||||
std::vector<fs::path> Configuration::valid_sources()
|
||||
std::vector<fs::u8path> Configuration::valid_sources()
|
||||
{
|
||||
return m_valid_sources;
|
||||
}
|
||||
|
@ -1805,13 +1804,13 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
YAML::Node Configuration::load_rc_file(const fs::path& file)
|
||||
YAML::Node Configuration::load_rc_file(const fs::u8path& file)
|
||||
{
|
||||
YAML::Node config;
|
||||
try
|
||||
{
|
||||
std::ifstream inFile;
|
||||
inFile.open(file);
|
||||
inFile.open(file.std_path());
|
||||
std::stringstream strStream;
|
||||
strStream << inFile.rdbuf();
|
||||
std::string s = strStream.str();
|
||||
|
@ -1825,7 +1824,7 @@ namespace mamba
|
|||
return config;
|
||||
}
|
||||
|
||||
void Configuration::set_rc_values(std::vector<fs::path> possible_rc_paths,
|
||||
void Configuration::set_rc_values(std::vector<fs::u8path> possible_rc_paths,
|
||||
const RCConfigLevel& level)
|
||||
{
|
||||
LOG_TRACE << "Get RC files configuration from locations up to "
|
||||
|
@ -1872,12 +1871,12 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> Configuration::get_existing_rc_sources(
|
||||
const std::vector<fs::path>& possible_rc_paths)
|
||||
std::vector<fs::u8path> Configuration::get_existing_rc_sources(
|
||||
const std::vector<fs::u8path>& possible_rc_paths)
|
||||
{
|
||||
std::vector<fs::path> sources;
|
||||
std::vector<fs::u8path> sources;
|
||||
|
||||
for (const fs::path& l : possible_rc_paths)
|
||||
for (const fs::u8path& l : possible_rc_paths)
|
||||
{
|
||||
if (detail::is_config_file(l))
|
||||
{
|
||||
|
@ -1886,7 +1885,7 @@ namespace mamba
|
|||
}
|
||||
else if (fs::is_directory(l))
|
||||
{
|
||||
for (fs::path p : fs::directory_iterator(l))
|
||||
for (fs::u8path p : fs::directory_iterator(l))
|
||||
{
|
||||
if (detail::is_config_file(p))
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace mamba
|
|||
|
||||
namespace detail
|
||||
{
|
||||
void store_platform_config(const fs::path& prefix, const std::string& platform)
|
||||
void store_platform_config(const fs::u8path& prefix, const std::string& platform)
|
||||
{
|
||||
if (!fs::exists(prefix))
|
||||
fs::create_directories(prefix);
|
||||
|
|
|
@ -125,7 +125,8 @@ namespace mamba
|
|||
items.push_back({ "env location", location });
|
||||
|
||||
// items.insert( { "shell level", { 1 } });
|
||||
items.push_back({ "user config files", { (env::home_directory() / ".mambarc").string() } });
|
||||
items.push_back(
|
||||
{ "user config files", { (env::home_directory() / ".mambarc").string() } });
|
||||
|
||||
Configuration& config = Configuration::instance();
|
||||
std::vector<std::string> sources;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace mamba
|
|||
const std::string& name, const std::string& target_prefix, fs::path spec_file)
|
||||
{
|
||||
const auto get_python_path
|
||||
= [&] { return env::which("python", get_path_dirs(target_prefix)).u8string(); };
|
||||
= [&] { return env::which("python", get_path_dirs(target_prefix)).string(); };
|
||||
|
||||
const std::unordered_map<std::string, command_args> other_pkg_mgr_install_instructions{
|
||||
{ "pip",
|
||||
|
@ -178,7 +178,7 @@ namespace mamba
|
|||
return truthy_values()[expr];
|
||||
}
|
||||
|
||||
yaml_file_contents read_yaml_file(fs::path yaml_file)
|
||||
yaml_file_contents read_yaml_file(fs::u8path yaml_file)
|
||||
{
|
||||
auto file = fs::weakly_canonical(env::expand_user(yaml_file));
|
||||
if (!fs::exists(file))
|
||||
|
@ -549,7 +549,7 @@ namespace mamba
|
|||
}
|
||||
PrefixData& prefix_data = exp_prefix_data.value();
|
||||
|
||||
fs::path pkgs_dirs(Context::instance().root_prefix / "pkgs");
|
||||
fs::u8path pkgs_dirs(Context::instance().root_prefix / "pkgs");
|
||||
MultiPackageCache pkg_caches({ pkgs_dirs });
|
||||
|
||||
auto transaction = create_transaction(pool, pkg_caches);
|
||||
|
@ -578,7 +578,7 @@ namespace mamba
|
|||
create_env);
|
||||
}
|
||||
|
||||
void install_lockfile_specs(const fs::path& lockfile, bool create_env)
|
||||
void install_lockfile_specs(const fs::u8path& lockfile, bool create_env)
|
||||
{
|
||||
detail::install_explicit_with_transaction(
|
||||
[&](auto& pool, auto& pkg_caches)
|
||||
|
@ -588,16 +588,18 @@ namespace mamba
|
|||
|
||||
namespace detail
|
||||
{
|
||||
void create_empty_target(const fs::path& prefix)
|
||||
void create_empty_target(const fs::u8path& prefix)
|
||||
{
|
||||
detail::create_target_directory(prefix);
|
||||
|
||||
Console::instance().print(join(
|
||||
"", std::vector<std::string>({ "Empty environment created at prefix: ", prefix.string() })));
|
||||
Console::instance().print(
|
||||
join("",
|
||||
std::vector<std::string>(
|
||||
{ "Empty environment created at prefix: ", prefix.string() })));
|
||||
Console::instance().json_write({ { "success", true } });
|
||||
}
|
||||
|
||||
void create_target_directory(const fs::path prefix)
|
||||
void create_target_directory(const fs::u8path prefix)
|
||||
{
|
||||
path::touch(prefix / "conda-meta" / "history", true);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace mamba
|
|||
MPool pool;
|
||||
MRepo::create(pool, prefix_data);
|
||||
|
||||
const fs::path pkgs_dirs(ctx.root_prefix / "pkgs");
|
||||
const fs::u8path pkgs_dirs(ctx.root_prefix / "pkgs");
|
||||
MultiPackageCache package_caches({ pkgs_dirs });
|
||||
|
||||
auto execute_transaction = [&](MTransaction& transaction)
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace mamba
|
|||
{
|
||||
namespace
|
||||
{
|
||||
fs::path PREFIX_STATE_FILE = fs::path("conda-meta") / "state";
|
||||
fs::path PACKAGE_ENV_VARS_DIR = fs::path("etc") / "conda" / "env_vars.d";
|
||||
fs::u8path PREFIX_STATE_FILE = fs::u8path("conda-meta") / "state";
|
||||
fs::u8path PACKAGE_ENV_VARS_DIR = fs::u8path("etc") / "conda" / "env_vars.d";
|
||||
std::string CONDA_ENV_VARS_UNSET_VAR = "***unset***"; // NOLINT(runtime/string)
|
||||
} // namespace
|
||||
|
||||
|
@ -29,24 +29,24 @@ namespace mamba
|
|||
{
|
||||
}
|
||||
|
||||
std::vector<fs::path> Activator::get_activate_scripts(const fs::path& prefix)
|
||||
std::vector<fs::u8path> Activator::get_activate_scripts(const fs::u8path& prefix)
|
||||
{
|
||||
fs::path script_dir = prefix / "etc" / "conda" / "activate.d";
|
||||
std::vector<fs::path> result = filter_dir(script_dir, shell_extension());
|
||||
fs::u8path script_dir = prefix / "etc" / "conda" / "activate.d";
|
||||
std::vector<fs::u8path> result = filter_dir(script_dir, shell_extension());
|
||||
std::sort(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<fs::path> Activator::get_deactivate_scripts(const fs::path& prefix)
|
||||
std::vector<fs::u8path> Activator::get_deactivate_scripts(const fs::u8path& prefix)
|
||||
{
|
||||
fs::path script_dir = prefix / "etc" / "conda" / "deactivate.d";
|
||||
std::vector<fs::path> result = filter_dir(script_dir, shell_extension());
|
||||
fs::u8path script_dir = prefix / "etc" / "conda" / "deactivate.d";
|
||||
std::vector<fs::u8path> result = filter_dir(script_dir, shell_extension());
|
||||
// reverse sort!
|
||||
std::sort(result.begin(), result.end(), std::greater<fs::path>());
|
||||
std::sort(result.begin(), result.end(), std::greater<fs::u8path>());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Activator::get_default_env(const fs::path& prefix)
|
||||
std::string Activator::get_default_env(const fs::u8path& prefix)
|
||||
{
|
||||
if (paths_equal(prefix, Context::instance().root_prefix))
|
||||
{
|
||||
|
@ -64,10 +64,10 @@ namespace mamba
|
|||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> Activator::get_environment_vars(
|
||||
const fs::path& prefix)
|
||||
const fs::u8path& prefix)
|
||||
{
|
||||
fs::path env_vars_file = prefix / PREFIX_STATE_FILE;
|
||||
fs::path pkg_env_var_dir = prefix / PACKAGE_ENV_VARS_DIR;
|
||||
fs::u8path env_vars_file = prefix / PREFIX_STATE_FILE;
|
||||
fs::u8path pkg_env_var_dir = prefix / PACKAGE_ENV_VARS_DIR;
|
||||
std::vector<std::pair<std::string, std::string>> env_vars;
|
||||
|
||||
// # First get env vars from packages
|
||||
|
@ -101,7 +101,7 @@ namespace mamba
|
|||
return env_vars;
|
||||
}
|
||||
|
||||
std::string Activator::get_prompt_modifier(const fs::path& prefix,
|
||||
std::string Activator::get_prompt_modifier(const fs::u8path& prefix,
|
||||
const std::string& conda_default_env,
|
||||
int old_conda_shlvl)
|
||||
{
|
||||
|
@ -172,7 +172,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> get_path_dirs(const fs::path& prefix)
|
||||
std::vector<fs::u8path> get_path_dirs(const fs::u8path& prefix)
|
||||
{
|
||||
if (on_win)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> Activator::get_clean_dirs()
|
||||
std::vector<fs::u8path> Activator::get_clean_dirs()
|
||||
{
|
||||
// For isolation, running the conda test suite *without* env. var. inheritance
|
||||
// every so often is a good idea. We should probably make this a pytest
|
||||
|
@ -203,7 +203,7 @@ namespace mamba
|
|||
// 'C:\\Windows\\System32\\Wbem;'
|
||||
// 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\'
|
||||
// }
|
||||
std::vector<fs::path> path;
|
||||
std::vector<fs::u8path> path;
|
||||
if (m_env.find("PATH") != m_env.end())
|
||||
{
|
||||
auto strings = split(m_env["PATH"], env::pathsep());
|
||||
|
@ -254,7 +254,7 @@ namespace mamba
|
|||
return path;
|
||||
}
|
||||
|
||||
std::string Activator::add_prefix_to_path(const fs::path& prefix, int old_conda_shlvl)
|
||||
std::string Activator::add_prefix_to_path(const fs::u8path& prefix, int old_conda_shlvl)
|
||||
{
|
||||
// prefix = self.path_conversion(prefix)
|
||||
// path_list = list(self.path_conversion(self._get_starting_path_list()))
|
||||
|
@ -265,10 +265,10 @@ namespace mamba
|
|||
// never trigger.
|
||||
if (old_conda_shlvl == 0)
|
||||
{
|
||||
bool no_condabin
|
||||
= std::none_of(path_list.begin(),
|
||||
path_list.end(),
|
||||
[](const fs::path& s) { return ends_with(s.string(), "condabin"); });
|
||||
bool no_condabin = std::none_of(path_list.begin(),
|
||||
path_list.end(),
|
||||
[](const fs::u8path& s)
|
||||
{ return ends_with(s.string(), "condabin"); });
|
||||
if (no_condabin)
|
||||
{
|
||||
auto condabin_dir = Context::instance().root_prefix / "condabin";
|
||||
|
@ -278,7 +278,7 @@ namespace mamba
|
|||
|
||||
// TODO check if path_conversion does something useful here.
|
||||
// path_list[0:0] = list(self.path_conversion(self._get_path_dirs(prefix)))
|
||||
std::vector<fs::path> final_path = get_path_dirs(prefix);
|
||||
std::vector<fs::u8path> final_path = get_path_dirs(prefix);
|
||||
final_path.insert(final_path.end(), path_list.begin(), path_list.end());
|
||||
final_path.erase(std::unique(final_path.begin(), final_path.end()), final_path.end());
|
||||
|
||||
|
@ -286,17 +286,17 @@ namespace mamba
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string Activator::replace_prefix_in_path(const fs::path& old_prefix,
|
||||
const fs::path& new_prefix)
|
||||
std::string Activator::replace_prefix_in_path(const fs::u8path& old_prefix,
|
||||
const fs::u8path& new_prefix)
|
||||
{
|
||||
// TODO not done yet.
|
||||
std::vector<fs::path> current_path = get_clean_dirs();
|
||||
std::vector<fs::u8path> current_path = get_clean_dirs();
|
||||
assert(!old_prefix.empty());
|
||||
|
||||
std::vector<fs::path> old_prefix_dirs = get_path_dirs(old_prefix);
|
||||
std::vector<fs::u8path> old_prefix_dirs = get_path_dirs(old_prefix);
|
||||
|
||||
// remove all old paths
|
||||
std::vector<fs::path> cleaned_path;
|
||||
std::vector<fs::u8path> cleaned_path;
|
||||
for (auto& cp : current_path)
|
||||
{
|
||||
bool is_in = false;
|
||||
|
@ -317,7 +317,7 @@ namespace mamba
|
|||
|
||||
// TODO remove `sys.prefix\Library\bin` on Windows?!
|
||||
// Not sure if necessary as we don't fiddle with Python
|
||||
std::vector<fs::path> final_path;
|
||||
std::vector<fs::u8path> final_path;
|
||||
if (!new_prefix.empty())
|
||||
{
|
||||
final_path = get_path_dirs(new_prefix);
|
||||
|
@ -337,9 +337,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::string Activator::remove_prefix_from_path(const fs::path& prefix)
|
||||
std::string Activator::remove_prefix_from_path(const fs::u8path& prefix)
|
||||
{
|
||||
return replace_prefix_in_path(prefix, fs::path());
|
||||
return replace_prefix_in_path(prefix, fs::u8path());
|
||||
}
|
||||
|
||||
void Activator::get_export_unset_vars(
|
||||
|
@ -525,7 +525,7 @@ namespace mamba
|
|||
return envt;
|
||||
}
|
||||
|
||||
EnvironmentTransform Activator::build_activate(const fs::path& prefix)
|
||||
EnvironmentTransform Activator::build_activate(const fs::u8path& prefix)
|
||||
{
|
||||
EnvironmentTransform envt;
|
||||
|
||||
|
@ -654,7 +654,7 @@ namespace mamba
|
|||
return envt;
|
||||
}
|
||||
|
||||
std::string Activator::activate(const fs::path& prefix, bool stack)
|
||||
std::string Activator::activate(const fs::u8path& prefix, bool stack)
|
||||
{
|
||||
m_stack = stack;
|
||||
m_action = ActivationType::ACTIVATE;
|
||||
|
@ -732,7 +732,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
for (const fs::path& ds : env_transform.deactivate_scripts)
|
||||
for (const fs::u8path& ds : env_transform.deactivate_scripts)
|
||||
{
|
||||
out << ". " << ds << "\n";
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
for (const fs::path& p : env_transform.activate_scripts)
|
||||
for (const fs::u8path& p : env_transform.activate_scripts)
|
||||
{
|
||||
out << ". " << p << "\n";
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
fs::path PosixActivator::hook_source_path()
|
||||
fs::u8path PosixActivator::hook_source_path()
|
||||
{
|
||||
return Context::instance().root_prefix / "etc" / "profile.d" / "micromamba.sh";
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
fs::path CmdExeActivator::hook_source_path()
|
||||
fs::u8path CmdExeActivator::hook_source_path()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -871,7 +871,7 @@ namespace mamba
|
|||
out << "@SET \"PATH=" << env_transform.export_path << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& ds : env_transform.deactivate_scripts)
|
||||
for (const fs::u8path& ds : env_transform.deactivate_scripts)
|
||||
{
|
||||
out << "@CALL " << ds << "\n";
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ namespace mamba
|
|||
out << "@SET \"" << ekey << "=" << evar << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& p : env_transform.activate_scripts)
|
||||
for (const fs::u8path& p : env_transform.activate_scripts)
|
||||
{
|
||||
out << "@CALL " << p << "\n";
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
fs::path PowerShellActivator::hook_source_path()
|
||||
fs::u8path PowerShellActivator::hook_source_path()
|
||||
{
|
||||
return Context::instance().root_prefix / "condabin" / "mamba_hook.ps1";
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ namespace mamba
|
|||
out << "$Env:PATH =\"" << env_transform.export_path << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& ds : env_transform.deactivate_scripts)
|
||||
for (const fs::u8path& ds : env_transform.deactivate_scripts)
|
||||
{
|
||||
out << ". " << ds << "\n";
|
||||
}
|
||||
|
@ -967,7 +967,7 @@ namespace mamba
|
|||
out << "$Env:" << ekey << " = \"" << evar << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& p : env_transform.activate_scripts)
|
||||
for (const fs::u8path& p : env_transform.activate_scripts)
|
||||
{
|
||||
out << ". " << p << "\n";
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
fs::path XonshActivator::hook_source_path()
|
||||
fs::u8path XonshActivator::hook_source_path()
|
||||
{
|
||||
return Context::instance().root_prefix / "etc" / "profile.d" / "mamba.xsh";
|
||||
}
|
||||
|
@ -1015,7 +1015,7 @@ namespace mamba
|
|||
out << "$PATH=\"" << env_transform.export_path << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& ds : env_transform.deactivate_scripts)
|
||||
for (const fs::u8path& ds : env_transform.deactivate_scripts)
|
||||
{
|
||||
out << "source-bash " << ds << "\n";
|
||||
}
|
||||
|
@ -1035,7 +1035,7 @@ namespace mamba
|
|||
out << "$" << ekey << " = \"" << evar << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& p : env_transform.activate_scripts)
|
||||
for (const fs::u8path& p : env_transform.activate_scripts)
|
||||
{
|
||||
out << "source-bash " << p << "\n";
|
||||
}
|
||||
|
@ -1063,7 +1063,7 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
fs::path FishActivator::hook_source_path()
|
||||
fs::u8path FishActivator::hook_source_path()
|
||||
{
|
||||
return Context::instance().root_prefix / "etc" / "fish" / "conf.d" / "mamba.fish";
|
||||
}
|
||||
|
@ -1083,7 +1083,7 @@ namespace mamba
|
|||
out << "set -gx PATH \"" << env_transform.export_path << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& ds : env_transform.deactivate_scripts)
|
||||
for (const fs::u8path& ds : env_transform.deactivate_scripts)
|
||||
{
|
||||
out << "source " << ds << "\n";
|
||||
}
|
||||
|
@ -1103,7 +1103,7 @@ namespace mamba
|
|||
out << "set -gx " << ekey << " \"" << evar << "\"\n";
|
||||
}
|
||||
|
||||
for (const fs::path& p : env_transform.activate_scripts)
|
||||
for (const fs::u8path& p : env_transform.activate_scripts)
|
||||
{
|
||||
out << "source " << p << "\n";
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ namespace mamba
|
|||
|
||||
envs_dirs = { root_prefix / "envs" };
|
||||
pkgs_dirs = { root_prefix / "pkgs",
|
||||
fs::path("~") / ".mamba" / "pkgs"
|
||||
fs::u8path("~") / ".mamba" / "pkgs"
|
||||
#ifdef _WIN32
|
||||
,
|
||||
fs::path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs"
|
||||
fs::u8path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs"
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace mamba
|
|||
void Context::load_authentication_info()
|
||||
{
|
||||
auto& ctx = Context::instance();
|
||||
std::vector<fs::path> found_tokens;
|
||||
std::vector<fs::u8path> found_tokens;
|
||||
|
||||
for (const auto& loc : ctx.token_locations)
|
||||
{
|
||||
|
@ -194,7 +194,8 @@ namespace mamba
|
|||
}
|
||||
|
||||
std::map<std::string, AuthenticationInfo> res;
|
||||
fs::path auth_loc(mamba::env::home_directory() / ".mamba" / "auth" / "authentication.json");
|
||||
fs::u8path auth_loc(mamba::env::home_directory() / ".mamba" / "auth"
|
||||
/ "authentication.json");
|
||||
try
|
||||
{
|
||||
if (fs::exists(auth_loc))
|
||||
|
@ -247,7 +248,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
|
||||
std::string env_name(const fs::path& prefix)
|
||||
std::string env_name(const fs::u8path& prefix)
|
||||
{
|
||||
if (prefix.empty())
|
||||
{
|
||||
|
@ -257,7 +258,7 @@ namespace mamba
|
|||
{
|
||||
return ROOT_ENV_NAME;
|
||||
}
|
||||
fs::path maybe_env_dir = prefix.parent_path();
|
||||
fs::u8path maybe_env_dir = prefix.parent_path();
|
||||
for (const auto& d : Context::instance().envs_dirs)
|
||||
{
|
||||
if (paths_equal(d, maybe_env_dir))
|
||||
|
@ -270,7 +271,7 @@ namespace mamba
|
|||
|
||||
// Find the location of a prefix given a conda env name.
|
||||
// If the location does not exist, an error is raised.
|
||||
fs::path locate_prefix_by_name(const std::string& name)
|
||||
fs::u8path locate_prefix_by_name(const std::string& name)
|
||||
{
|
||||
assert(!name.empty());
|
||||
if (name == ROOT_ENV_NAME)
|
||||
|
@ -283,7 +284,7 @@ namespace mamba
|
|||
{
|
||||
continue;
|
||||
}
|
||||
fs::path prefix = d / name;
|
||||
fs::u8path prefix = d / name;
|
||||
if (fs::exists(prefix) && fs::is_directory(prefix))
|
||||
{
|
||||
return fs::absolute(prefix);
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
tl::expected<EnvironmentLockFile, mamba_error> read_environment_lockfile(
|
||||
const fs::path& lockfile_location)
|
||||
const fs::u8path& lockfile_location)
|
||||
{
|
||||
const auto file_path = fs::absolute(
|
||||
lockfile_location); // Having the complete path helps with logging and error reports.
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
fs::path which(const std::string& exe, const std::string& override_path)
|
||||
fs::u8path which(const std::string& exe, const std::string& override_path)
|
||||
{
|
||||
// TODO maybe add a cache?
|
||||
auto env_path = override_path == "" ? env::get("PATH") : override_path;
|
||||
|
@ -82,7 +82,7 @@ namespace mamba
|
|||
{
|
||||
std::string path = env_path.value();
|
||||
const auto parts = mamba::split(path, pathsep());
|
||||
const std::vector<fs::path> search_paths(parts.begin(), parts.end());
|
||||
const std::vector<fs::u8path> search_paths(parts.begin(), parts.end());
|
||||
return which(exe, search_paths);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ namespace mamba
|
|||
return ""; // empty path
|
||||
}
|
||||
|
||||
fs::path which(const std::string& exe, const std::vector<fs::path>& search_paths)
|
||||
fs::u8path which(const std::string& exe, const std::vector<fs::u8path>& search_paths)
|
||||
{
|
||||
for (auto& p : search_paths)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
fs::path home_directory()
|
||||
fs::u8path home_directory()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string maybe_home = env::get("USERPROFILE").value_or("");
|
||||
|
@ -223,7 +223,7 @@ namespace mamba
|
|||
return maybe_home;
|
||||
}
|
||||
|
||||
fs::path expand_user(const fs::path& path)
|
||||
fs::u8path expand_user(const fs::u8path& path)
|
||||
{
|
||||
auto p = path.string();
|
||||
if (p[0] == '~')
|
||||
|
@ -233,7 +233,7 @@ namespace mamba
|
|||
return p;
|
||||
}
|
||||
|
||||
fs::path shrink_user(const fs::path& path)
|
||||
fs::u8path shrink_user(const fs::u8path& path)
|
||||
{
|
||||
auto p = path.string();
|
||||
auto home = home_directory().string();
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
bool is_conda_environment(const fs::path& prefix)
|
||||
bool is_conda_environment(const fs::u8path& prefix)
|
||||
{
|
||||
return fs::exists(prefix / PREFIX_MAGIC_FILE);
|
||||
}
|
||||
|
||||
void EnvironmentsManager::register_env(const fs::path& location)
|
||||
void EnvironmentsManager::register_env(const fs::u8path& location)
|
||||
{
|
||||
fs::path env_txt_file = get_environments_txt_file(env::home_directory());
|
||||
fs::path final_location = fs::absolute(location);
|
||||
fs::path folder = final_location.parent_path();
|
||||
fs::u8path env_txt_file = get_environments_txt_file(env::home_directory());
|
||||
fs::u8path final_location = fs::absolute(location);
|
||||
fs::u8path folder = final_location.parent_path();
|
||||
|
||||
if (!fs::exists(env_txt_file))
|
||||
{
|
||||
|
@ -70,11 +70,11 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void EnvironmentsManager::unregister_env(const fs::path& location)
|
||||
void EnvironmentsManager::unregister_env(const fs::u8path& location)
|
||||
{
|
||||
if (fs::exists(location) && fs::is_directory(location))
|
||||
{
|
||||
fs::path meta_dir = location / "conda-meta";
|
||||
fs::u8path meta_dir = location / "conda-meta";
|
||||
if (fs::exists(meta_dir) && fs::is_directory(meta_dir))
|
||||
{
|
||||
std::size_t count = 0;
|
||||
|
@ -94,16 +94,16 @@ namespace mamba
|
|||
clean_environments_txt(get_environments_txt_file(env::home_directory()), location);
|
||||
}
|
||||
|
||||
std::set<fs::path> EnvironmentsManager::list_all_known_prefixes()
|
||||
std::set<fs::u8path> EnvironmentsManager::list_all_known_prefixes()
|
||||
{
|
||||
std::vector<fs::path> search_dirs;
|
||||
std::vector<fs::u8path> search_dirs;
|
||||
|
||||
// TODO
|
||||
// if (is_admin())
|
||||
// {
|
||||
// if (on_win)
|
||||
// {
|
||||
// fs::path home_dir_dir = env::home_directory().parent_path();
|
||||
// fs::u8path home_dir_dir = env::home_directory().parent_path();
|
||||
// search_dirs = tuple(join(home_dir_dir, d) for d in
|
||||
// listdir(home_dir_dir))
|
||||
// }
|
||||
|
@ -116,17 +116,17 @@ namespace mamba
|
|||
// }
|
||||
// else
|
||||
{
|
||||
search_dirs = std::vector<fs::path>{ env::home_directory() };
|
||||
search_dirs = std::vector<fs::u8path>{ env::home_directory() };
|
||||
}
|
||||
|
||||
std::set<fs::path> all_env_paths;
|
||||
std::set<fs::u8path> all_env_paths;
|
||||
|
||||
for (auto& d : search_dirs)
|
||||
{
|
||||
auto f = get_environments_txt_file(d);
|
||||
if (fs::exists(f))
|
||||
{
|
||||
for (auto& env_path : clean_environments_txt(f, fs::path()))
|
||||
for (auto& env_path : clean_environments_txt(f, fs::u8path()))
|
||||
{
|
||||
all_env_paths.insert(env_path);
|
||||
}
|
||||
|
@ -149,14 +149,14 @@ namespace mamba
|
|||
return all_env_paths;
|
||||
}
|
||||
|
||||
std::set<std::string> EnvironmentsManager::clean_environments_txt(const fs::path& env_txt_file,
|
||||
const fs::path& location)
|
||||
std::set<std::string> EnvironmentsManager::clean_environments_txt(
|
||||
const fs::u8path& env_txt_file, const fs::u8path& location)
|
||||
{
|
||||
if (!fs::exists(env_txt_file))
|
||||
return {};
|
||||
|
||||
std::error_code fsabs_error;
|
||||
fs::path abs_loc = fs::absolute(
|
||||
fs::u8path abs_loc = fs::absolute(
|
||||
location, fsabs_error); // If it fails we just get the defaultly constructed path.
|
||||
if (fsabs_error && !location.empty()) // Ignore cases where we got an empty location.
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ namespace mamba
|
|||
return p;
|
||||
}
|
||||
|
||||
fs::path EnvironmentsManager::get_environments_txt_file(const fs::path& home) const
|
||||
fs::u8path EnvironmentsManager::get_environments_txt_file(const fs::u8path& home) const
|
||||
{
|
||||
return home / ".conda" / "environments.txt";
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
History::History(const fs::path& prefix)
|
||||
History::History(const fs::u8path& prefix)
|
||||
: m_prefix(prefix)
|
||||
, m_history_file_path(fs::absolute(m_prefix / "conda-meta" / "history"))
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace mamba
|
|||
out << " os.execv(args[0], args)\n";
|
||||
}
|
||||
|
||||
fs::path pyc_path(const fs::path& py_path, const std::string& py_ver)
|
||||
fs::u8path pyc_path(const fs::u8path& py_path, const std::string& py_ver)
|
||||
{
|
||||
/*
|
||||
This must not return backslashes on Windows as that will break
|
||||
|
@ -77,7 +77,7 @@ namespace mamba
|
|||
auto py_file_stem = py_path.stem();
|
||||
std::string py_ver_nodot = py_ver;
|
||||
replace_all(py_ver_nodot, ".", "");
|
||||
return directory / fs::path("__pycache__")
|
||||
return directory / fs::u8path("__pycache__")
|
||||
/ concat(py_file_stem.string(), ".cpython-", py_ver_nodot, ".pyc");
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace mamba
|
|||
std::smatch match;
|
||||
if (std::regex_match(shebang, match, shebang_regex))
|
||||
{
|
||||
fs::path shebang_path = match[2].str();
|
||||
fs::u8path shebang_path = match[2].str();
|
||||
LOG_INFO << "New shebang path " << shebang_path;
|
||||
return concat("#!/usr/bin/env ", shebang_path.filename().string(), match[3].str());
|
||||
}
|
||||
|
@ -126,16 +126,16 @@ namespace mamba
|
|||
}
|
||||
|
||||
// for noarch python packages that have entry points
|
||||
auto LinkPackage::create_python_entry_point(const fs::path& path,
|
||||
auto LinkPackage::create_python_entry_point(const fs::u8path& path,
|
||||
const python_entry_point_parsed& entry_point)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// We add -script.py to WIN32, and link the conda.exe launcher which will
|
||||
// automatically find the correct script to launch
|
||||
std::string win_script = path.string() + "-script.py";
|
||||
fs::path script_path = m_context->target_prefix / win_script;
|
||||
fs::u8path script_path = m_context->target_prefix / win_script;
|
||||
#else
|
||||
fs::path script_path = m_context->target_prefix / path;
|
||||
fs::u8path script_path = m_context->target_prefix / path;
|
||||
#endif
|
||||
if (fs::exists(script_path))
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ namespace mamba
|
|||
}
|
||||
std::ofstream out_file = open_ofstream(script_path);
|
||||
|
||||
fs::path python_path;
|
||||
fs::u8path python_path;
|
||||
if (m_context->has_python)
|
||||
{
|
||||
python_path = m_context->target_prefix / m_context->python_path;
|
||||
|
@ -168,7 +168,7 @@ namespace mamba
|
|||
out_file.close();
|
||||
|
||||
#ifdef _WIN32
|
||||
fs::path script_exe = path;
|
||||
fs::u8path script_exe = path;
|
||||
script_exe.replace_extension("exe");
|
||||
|
||||
if (fs::exists(m_context->target_prefix / script_exe))
|
||||
|
@ -226,9 +226,9 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
void LinkPackage::create_application_entry_point(const fs::path& source_full_path,
|
||||
const fs::path& target_full_path,
|
||||
const fs::path& python_full_path)
|
||||
void LinkPackage::create_application_entry_point(const fs::u8path& source_full_path,
|
||||
const fs::u8path& target_full_path,
|
||||
const fs::u8path& python_full_path)
|
||||
{
|
||||
// source_full_path: where the entry point file points to
|
||||
// target_full_path: the location of the new entry point file being created
|
||||
|
@ -243,8 +243,9 @@ namespace mamba
|
|||
}
|
||||
|
||||
std::ofstream out_file = open_ofstream(target_full_path);
|
||||
out_file << "!#" << python_full_path.c_str() << "\n";
|
||||
application_entry_point_template(out_file, win_path_double_escape(source_full_path.string()));
|
||||
out_file << "!#" << python_full_path.string() << "\n";
|
||||
application_entry_point_template(out_file,
|
||||
win_path_double_escape(source_full_path.string()));
|
||||
out_file.close();
|
||||
|
||||
make_executable(target_full_path);
|
||||
|
@ -273,7 +274,7 @@ namespace mamba
|
|||
// fo.write(entry_point)
|
||||
// make_executable(target_full_path)
|
||||
|
||||
std::string get_prefix_messages(const fs::path& prefix)
|
||||
std::string get_prefix_messages(const fs::u8path& prefix)
|
||||
{
|
||||
auto messages_file = prefix / ".messages.txt";
|
||||
if (fs::exists(messages_file))
|
||||
|
@ -300,13 +301,13 @@ namespace mamba
|
|||
call the post-link or pre-unlink script and return true / false on success /
|
||||
failure
|
||||
*/
|
||||
bool run_script(const fs::path& prefix,
|
||||
bool run_script(const fs::u8path& prefix,
|
||||
const PackageInfo& pkg_info,
|
||||
const std::string& action = "post-link",
|
||||
const std::string& env_prefix = "",
|
||||
bool activate = false)
|
||||
{
|
||||
fs::path path;
|
||||
fs::u8path path;
|
||||
if (on_win)
|
||||
{
|
||||
path = prefix / get_bin_directory_short_path()
|
||||
|
@ -367,7 +368,7 @@ namespace mamba
|
|||
else
|
||||
{
|
||||
// shell_path = 'sh' if 'bsd' in sys.platform else 'bash'
|
||||
fs::path shell_path = env::which("bash");
|
||||
fs::u8path shell_path = env::which("bash");
|
||||
if (shell_path.empty())
|
||||
{
|
||||
shell_path = env::which("sh");
|
||||
|
@ -450,7 +451,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
UnlinkPackage::UnlinkPackage(const PackageInfo& pkg_info,
|
||||
const fs::path& cache_path,
|
||||
const fs::u8path& cache_path,
|
||||
TransactionContext* context)
|
||||
: m_pkg_info(pkg_info)
|
||||
, m_cache_path(cache_path)
|
||||
|
@ -462,7 +463,7 @@ namespace mamba
|
|||
bool UnlinkPackage::unlink_path(const nlohmann::json& path_data)
|
||||
{
|
||||
std::string subtarget = path_data["_path"].get<std::string>();
|
||||
fs::path dst = m_context->target_prefix / subtarget;
|
||||
fs::u8path dst = m_context->target_prefix / subtarget;
|
||||
|
||||
LOG_TRACE << "Unlinking '" << dst.string() << "'";
|
||||
std::error_code err;
|
||||
|
@ -504,7 +505,7 @@ namespace mamba
|
|||
bool UnlinkPackage::execute()
|
||||
{
|
||||
// find the recorded JSON file
|
||||
fs::path json = m_context->target_prefix / "conda-meta" / (m_specifier + ".json");
|
||||
fs::u8path json = m_context->target_prefix / "conda-meta" / (m_specifier + ".json");
|
||||
LOG_INFO << "Unlinking package '" << m_specifier << "'";
|
||||
LOG_DEBUG << "Use metadata found at '" << json.string() << "'";
|
||||
|
||||
|
@ -537,7 +538,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
LinkPackage::LinkPackage(const PackageInfo& pkg_info,
|
||||
const fs::path& cache_path,
|
||||
const fs::u8path& cache_path,
|
||||
TransactionContext* context)
|
||||
: m_pkg_info(pkg_info)
|
||||
, m_cache_path(cache_path)
|
||||
|
@ -551,7 +552,7 @@ namespace mamba
|
|||
{
|
||||
std::string subtarget = path_data.path;
|
||||
LOG_TRACE << "linking '" << subtarget << "'";
|
||||
fs::path dst, rel_dst;
|
||||
fs::u8path dst, rel_dst;
|
||||
if (noarch_python)
|
||||
{
|
||||
rel_dst = get_python_noarch_target_path(subtarget, m_context->site_packages_path);
|
||||
|
@ -563,7 +564,7 @@ namespace mamba
|
|||
dst = m_context->target_prefix / rel_dst;
|
||||
}
|
||||
|
||||
fs::path src = m_source / subtarget;
|
||||
fs::u8path src = m_source / subtarget;
|
||||
if (!fs::exists(dst.parent_path()))
|
||||
{
|
||||
fs::create_directories(dst.parent_path());
|
||||
|
@ -780,16 +781,17 @@ namespace mamba
|
|||
throw std::runtime_error(std::string("Path type not implemented: ")
|
||||
+ std::to_string(static_cast<int>(path_data.path_type)));
|
||||
}
|
||||
return std::make_tuple(
|
||||
path_data.sha256.empty() ? validate::sha256sum(dst) : path_data.sha256, rel_dst.string());
|
||||
return std::make_tuple(path_data.sha256.empty() ? validate::sha256sum(dst)
|
||||
: path_data.sha256,
|
||||
rel_dst.string());
|
||||
}
|
||||
|
||||
std::vector<fs::path> LinkPackage::compile_pyc_files(const std::vector<fs::path>& py_files)
|
||||
std::vector<fs::u8path> LinkPackage::compile_pyc_files(const std::vector<fs::u8path>& py_files)
|
||||
{
|
||||
if (py_files.size() == 0)
|
||||
return {};
|
||||
|
||||
std::vector<fs::path> pyc_files;
|
||||
std::vector<fs::u8path> pyc_files;
|
||||
for (auto& f : py_files)
|
||||
{
|
||||
pyc_files.push_back(pyc_path(f, m_context->short_python_version));
|
||||
|
@ -962,7 +964,7 @@ namespace mamba
|
|||
|
||||
if (noarch_type == NoarchType::PYTHON)
|
||||
{
|
||||
fs::path link_json_path = m_source / "info" / "link.json";
|
||||
fs::u8path link_json_path = m_source / "info" / "link.json";
|
||||
nlohmann::json link_json;
|
||||
if (fs::exists(link_json_path))
|
||||
{
|
||||
|
@ -970,7 +972,7 @@ namespace mamba
|
|||
link_json_file >> link_json;
|
||||
}
|
||||
|
||||
std::vector<fs::path> for_compilation;
|
||||
std::vector<fs::u8path> for_compilation;
|
||||
static std::regex py_file_re("^site-packages[/\\\\][^\\t\\n\\r\\f\\v]+\\.py$");
|
||||
for (auto& sub_path_json : paths_data)
|
||||
{
|
||||
|
@ -981,8 +983,8 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> pyc_files = compile_pyc_files(for_compilation);
|
||||
for (const fs::path& pyc_path : pyc_files)
|
||||
std::vector<fs::u8path> pyc_files = compile_pyc_files(for_compilation);
|
||||
for (const fs::u8path& pyc_path : pyc_files)
|
||||
{
|
||||
out_json["paths_data"]["paths"].push_back(
|
||||
{ { "_path", pyc_path.string() }, { "path_type", "pyc_file" } });
|
||||
|
@ -1035,7 +1037,7 @@ namespace mamba
|
|||
|
||||
run_script(m_context->target_prefix, m_pkg_info, "post-link", "", true);
|
||||
|
||||
fs::path prefix_meta = m_context->target_prefix / "conda-meta";
|
||||
fs::u8path prefix_meta = m_context->target_prefix / "conda-meta";
|
||||
if (!fs::exists(prefix_meta))
|
||||
{
|
||||
fs::create_directory(prefix_meta);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace mamba
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
std::string get_formatted_env_name(const fs::path& target_prefix)
|
||||
std::string get_formatted_env_name(const fs::u8path& target_prefix)
|
||||
{
|
||||
std::string name = env_name(target_prefix);
|
||||
if (name.find_first_of("\\/") != std::string::npos)
|
||||
|
@ -42,12 +42,12 @@ namespace mamba
|
|||
* icon_path: path to an .ico file
|
||||
* icon_index: index for icon
|
||||
*/
|
||||
void create_shortcut(const fs::path& path,
|
||||
void create_shortcut(const fs::u8path& path,
|
||||
const std::string& description,
|
||||
const fs::path& filename,
|
||||
const fs::u8path& filename,
|
||||
const std::string& arguments,
|
||||
const fs::path& work_dir,
|
||||
const fs::path& icon_path,
|
||||
const fs::u8path& work_dir,
|
||||
const fs::u8path& icon_path,
|
||||
int icon_index)
|
||||
{
|
||||
IShellLink* pShellLink = nullptr;
|
||||
|
@ -159,7 +159,7 @@ namespace mamba
|
|||
{ "documents", FOLDERID_Documents },
|
||||
};
|
||||
|
||||
fs::path get_folder(const std::string& id)
|
||||
fs::u8path get_folder(const std::string& id)
|
||||
{
|
||||
wchar_t* localAppData;
|
||||
HRESULT hres;
|
||||
|
@ -173,12 +173,12 @@ namespace mamba
|
|||
}
|
||||
|
||||
std::wstring tmp(localAppData);
|
||||
fs::path res(tmp);
|
||||
fs::u8path res(tmp);
|
||||
CoTaskMemFree(localAppData);
|
||||
return res;
|
||||
}
|
||||
|
||||
void remove_shortcut(const fs::path& filename)
|
||||
void remove_shortcut(const fs::u8path& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -203,9 +203,9 @@ namespace mamba
|
|||
void replace_variables(std::string& text, TransactionContext* transaction_context)
|
||||
{
|
||||
auto& ctx = mamba::Context::instance();
|
||||
fs::path root_prefix = ctx.root_prefix;
|
||||
fs::u8path root_prefix = ctx.root_prefix;
|
||||
|
||||
fs::path target_prefix;
|
||||
fs::u8path target_prefix;
|
||||
std::string py_ver;
|
||||
if (transaction_context)
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ namespace mamba
|
|||
distribution_name[0] = std::toupper(distribution_name[0]);
|
||||
}
|
||||
|
||||
auto to_forward_slash = [](const fs::path& p)
|
||||
auto to_forward_slash = [](const fs::u8path& p)
|
||||
{
|
||||
std::string ps = p.string();
|
||||
replace_all(ps, "\\", "/");
|
||||
|
@ -261,7 +261,7 @@ namespace mamba
|
|||
|
||||
namespace detail
|
||||
{
|
||||
void create_remove_shortcut_impl(const fs::path& json_file,
|
||||
void create_remove_shortcut_impl(const fs::u8path& json_file,
|
||||
TransactionContext* transaction_context,
|
||||
bool remove)
|
||||
{
|
||||
|
@ -295,20 +295,21 @@ namespace mamba
|
|||
// }
|
||||
|
||||
auto& ctx = mamba::Context::instance();
|
||||
const fs::path root_prefix = ctx.root_prefix;
|
||||
const fs::path target_prefix = ctx.target_prefix;
|
||||
const fs::u8path root_prefix = ctx.root_prefix;
|
||||
const fs::u8path target_prefix = ctx.target_prefix;
|
||||
|
||||
// using legacy stuff here
|
||||
const fs::path root_py = root_prefix / "python.exe";
|
||||
const fs::path root_pyw = root_prefix / "pythonw.exe";
|
||||
const fs::path env_py = target_prefix / "python.exe";
|
||||
const fs::path env_pyw = target_prefix / "pythonw.exe";
|
||||
const fs::u8path root_py = root_prefix / "python.exe";
|
||||
const fs::u8path root_pyw = root_prefix / "pythonw.exe";
|
||||
const fs::u8path env_py = target_prefix / "python.exe";
|
||||
const fs::u8path env_pyw = target_prefix / "pythonw.exe";
|
||||
const auto cwp_path = root_prefix / "cwp.py";
|
||||
std::vector<std::string> cwp_py_args(
|
||||
{ cwp_path.string(), target_prefix.string(), env_py.string() });
|
||||
std::vector<std::string> cwp_pyw_args({ cwp_path.string(), target_prefix.string(), env_pyw.string() });
|
||||
std::vector<std::string> cwp_pyw_args(
|
||||
{ cwp_path.string(), target_prefix.string(), env_pyw.string() });
|
||||
|
||||
fs::path target_dir = win::get_folder("programs") / menu_name;
|
||||
fs::u8path target_dir = win::get_folder("programs") / menu_name;
|
||||
if (!fs::exists(target_dir))
|
||||
{
|
||||
fs::create_directories(target_dir);
|
||||
|
@ -338,7 +339,7 @@ namespace mamba
|
|||
std::string full_name = concat(name, name_suffix);
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
fs::path script;
|
||||
fs::u8path script;
|
||||
if (item.contains("pywscript"))
|
||||
{
|
||||
script = root_pyw;
|
||||
|
@ -382,9 +383,9 @@ namespace mamba
|
|||
throw std::runtime_error("Unknown shortcut type.");
|
||||
}
|
||||
|
||||
fs::path dst = target_dir / (full_name + ".lnk");
|
||||
fs::path workdir = item.value("workdir", "");
|
||||
fs::path iconpath = item.value("icon", "");
|
||||
fs::u8path dst = target_dir / (full_name + ".lnk");
|
||||
fs::u8path workdir = item.value("workdir", "");
|
||||
fs::u8path iconpath = item.value("icon", "");
|
||||
if (remove == false)
|
||||
{
|
||||
std::string argstring;
|
||||
|
@ -438,7 +439,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void remove_menu_from_json(const fs::path& json_file, TransactionContext* context)
|
||||
void remove_menu_from_json(const fs::u8path& json_file, TransactionContext* context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -450,7 +451,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void create_menu_from_json(const fs::path& json_file, TransactionContext* context)
|
||||
void create_menu_from_json(const fs::u8path& json_file, TransactionContext* context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
PackageCacheData::PackageCacheData(const fs::path& path)
|
||||
PackageCacheData::PackageCacheData(const fs::u8path& path)
|
||||
: m_path(path)
|
||||
{
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace mamba
|
|||
return m_writable;
|
||||
}
|
||||
|
||||
fs::path PackageCacheData::path() const
|
||||
fs::u8path PackageCacheData::path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace mamba
|
|||
|
||||
void PackageCacheData::check_writable()
|
||||
{
|
||||
fs::path magic_file = m_path / PACKAGE_CACHE_MAGIC_FILE;
|
||||
fs::u8path magic_file = m_path / PACKAGE_CACHE_MAGIC_FILE;
|
||||
LOG_DEBUG << "Checking if '" << m_path.string() << "' is writable";
|
||||
|
||||
std::error_code ec;
|
||||
|
@ -118,7 +118,7 @@ namespace mamba
|
|||
bool valid = false;
|
||||
if (fs::exists(m_path / s.fn))
|
||||
{
|
||||
fs::path tarball_path = m_path / s.fn;
|
||||
fs::u8path tarball_path = m_path / s.fn;
|
||||
// validate that this tarball has the right size and MD5 sum
|
||||
// we handle the case where s.size == 0 (explicit packages) or md5 is unknown
|
||||
valid = s.size == 0 || validate::file_size(tarball_path, s.size);
|
||||
|
@ -172,7 +172,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
auto pkg_name = strip_package_extension(s.fn);
|
||||
fs::path extracted_dir = m_path / pkg_name;
|
||||
fs::u8path extracted_dir = m_path / pkg_name;
|
||||
LOG_DEBUG << "Verify cache '" << m_path.string() << "' for package extracted directory '"
|
||||
<< pkg_name.string() << "'";
|
||||
|
||||
|
@ -183,7 +183,7 @@ namespace mamba
|
|||
{
|
||||
try
|
||||
{
|
||||
std::ifstream repodata_record_f(repodata_record_path);
|
||||
std::ifstream repodata_record_f(repodata_record_path.std_path());
|
||||
nlohmann::json repodata_record;
|
||||
repodata_record_f >> repodata_record;
|
||||
|
||||
|
@ -323,7 +323,7 @@ namespace mamba
|
|||
return valid;
|
||||
}
|
||||
|
||||
MultiPackageCache::MultiPackageCache(const std::vector<fs::path>& cache_paths)
|
||||
MultiPackageCache::MultiPackageCache(const std::vector<fs::u8path>& cache_paths)
|
||||
{
|
||||
m_caches.reserve(cache_paths.size());
|
||||
for (auto& c : cache_paths)
|
||||
|
@ -369,16 +369,16 @@ namespace mamba
|
|||
return res;
|
||||
}
|
||||
|
||||
fs::path MultiPackageCache::first_writable_path()
|
||||
fs::u8path MultiPackageCache::first_writable_path()
|
||||
{
|
||||
for (auto& pc : m_caches)
|
||||
if (pc.is_writable() == Writable::WRITABLE)
|
||||
return pc.path();
|
||||
|
||||
return fs::path();
|
||||
return fs::u8path();
|
||||
}
|
||||
|
||||
fs::path MultiPackageCache::get_tarball_path(const PackageInfo& s, bool return_empty)
|
||||
fs::u8path MultiPackageCache::get_tarball_path(const PackageInfo& s, bool return_empty)
|
||||
{
|
||||
const std::string pkg(s.str());
|
||||
const auto cache_iter(m_cached_tarballs.find(pkg));
|
||||
|
@ -395,7 +395,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
if (return_empty)
|
||||
return fs::path();
|
||||
return fs::u8path();
|
||||
else
|
||||
{
|
||||
LOG_ERROR << "Cannot find tarball cache for '" << s.fn << "'";
|
||||
|
@ -404,7 +404,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
|
||||
fs::path MultiPackageCache::get_extracted_dir_path(const PackageInfo& s, bool return_empty)
|
||||
fs::u8path MultiPackageCache::get_extracted_dir_path(const PackageInfo& s, bool return_empty)
|
||||
{
|
||||
const std::string pkg(s.str());
|
||||
const auto cache_iter(m_cached_extracted_dirs.find(pkg));
|
||||
|
@ -421,7 +421,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
if (return_empty)
|
||||
return fs::path();
|
||||
return fs::u8path();
|
||||
else
|
||||
{
|
||||
LOG_ERROR << "Cannot find a valid extracted directory cache for '" << s.fn << "'";
|
||||
|
@ -429,9 +429,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<fs::path> MultiPackageCache::paths() const
|
||||
std::vector<fs::u8path> MultiPackageCache::paths() const
|
||||
{
|
||||
std::vector<fs::path> paths;
|
||||
std::vector<fs::u8path> paths;
|
||||
for (auto& c : m_caches)
|
||||
paths.push_back(c.path());
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace mamba
|
|||
class extraction_guard
|
||||
{
|
||||
public:
|
||||
explicit extraction_guard(const fs::path& file)
|
||||
explicit extraction_guard(const fs::u8path& file)
|
||||
: m_file(file)
|
||||
{
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace mamba
|
|||
extraction_guard& operator=(extraction_guard&&) = delete;
|
||||
|
||||
private:
|
||||
const fs::path& m_file;
|
||||
const fs::u8path& m_file;
|
||||
};
|
||||
|
||||
static int copy_data(archive* ar, archive* aw)
|
||||
|
@ -85,8 +85,8 @@ namespace mamba
|
|||
}
|
||||
|
||||
// Bundle up all files in directory and create destination archive
|
||||
void create_archive(const fs::path& directory,
|
||||
const fs::path& destination,
|
||||
void create_archive(const fs::u8path& directory,
|
||||
const fs::u8path& destination,
|
||||
compression_algorithm ca,
|
||||
int compression_level,
|
||||
bool (*filter)(const std::string&))
|
||||
|
@ -96,7 +96,7 @@ namespace mamba
|
|||
|
||||
extraction_guard g(destination);
|
||||
|
||||
fs::path abs_out_path = fs::absolute(destination);
|
||||
fs::u8path abs_out_path = fs::absolute(destination);
|
||||
a = archive_write_new();
|
||||
if (ca == compression_algorithm::bzip2)
|
||||
{
|
||||
|
@ -229,9 +229,11 @@ namespace mamba
|
|||
}
|
||||
|
||||
// note the info folder must have already been created!
|
||||
void create_package(const fs::path& directory, const fs::path& out_file, int compression_level)
|
||||
void create_package(const fs::u8path& directory,
|
||||
const fs::u8path& out_file,
|
||||
int compression_level)
|
||||
{
|
||||
fs::path out_file_abs = fs::absolute(out_file);
|
||||
fs::u8path out_file_abs = fs::absolute(out_file);
|
||||
if (ends_with(out_file.string(), ".tar.bz2"))
|
||||
{
|
||||
create_archive(directory,
|
||||
|
@ -256,7 +258,8 @@ namespace mamba
|
|||
|
||||
nlohmann::json pkg_metadata;
|
||||
pkg_metadata["conda_pkg_format_version"] = 2;
|
||||
std::ofstream metadata_file(tdir.path() / "metadata.json");
|
||||
const auto metadata_file_path = tdir.path() / "metadata.json";
|
||||
std::ofstream metadata_file(metadata_file_path.std_path());
|
||||
metadata_file << pkg_metadata;
|
||||
metadata_file.close();
|
||||
|
||||
|
@ -265,7 +268,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void extract_archive(const fs::path& file, const fs::path& destination)
|
||||
void extract_archive(const fs::u8path& file, const fs::u8path& destination)
|
||||
{
|
||||
LOG_INFO << "Extracting " << file << " to " << destination;
|
||||
extraction_guard g(destination);
|
||||
|
@ -367,8 +370,8 @@ namespace mamba
|
|||
fs::current_path(prev_path);
|
||||
}
|
||||
|
||||
void extract_conda(const fs::path& file,
|
||||
const fs::path& dest_dir,
|
||||
void extract_conda(const fs::u8path& file,
|
||||
const fs::u8path& dest_dir,
|
||||
const std::vector<std::string>& parts)
|
||||
{
|
||||
TemporaryDirectory tdir;
|
||||
|
@ -379,7 +382,8 @@ namespace mamba
|
|||
auto metadata_path = tdir.path() / "metadata.json";
|
||||
if (fs::exists(metadata_path) && fs::file_size(metadata_path) != 0)
|
||||
{
|
||||
std::ifstream condafile_meta(tdir.path() / "metadata.json");
|
||||
const auto condafile_path = tdir.path() / "metadata.json";
|
||||
std::ifstream condafile_meta(condafile_path.std_path());
|
||||
nlohmann::json j;
|
||||
condafile_meta >> j;
|
||||
|
||||
|
@ -395,12 +399,12 @@ namespace mamba
|
|||
for (auto& part : parts)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << part << "-" << fn.c_str() << ".tar.zst";
|
||||
ss << part << "-" << fn.string() << ".tar.zst";
|
||||
extract_archive(tdir.path() / ss.str(), dest_dir);
|
||||
}
|
||||
}
|
||||
|
||||
static fs::path extract_dest_dir(const fs::path& file)
|
||||
static fs::u8path extract_dest_dir(const fs::u8path& file)
|
||||
{
|
||||
if (ends_with(file.string(), ".tar.bz2"))
|
||||
{
|
||||
|
@ -414,7 +418,7 @@ namespace mamba
|
|||
throw std::runtime_error("Unknown package format.");
|
||||
}
|
||||
|
||||
void extract(const fs::path& file, const fs::path& dest)
|
||||
void extract(const fs::u8path& file, const fs::u8path& dest)
|
||||
{
|
||||
static std::mutex extract_mutex;
|
||||
std::lock_guard<std::mutex> lock(extract_mutex);
|
||||
|
@ -430,19 +434,21 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
fs::path extract(const fs::path& file)
|
||||
fs::u8path extract(const fs::u8path& file)
|
||||
{
|
||||
fs::path dest_dir = extract_dest_dir(file);
|
||||
fs::u8path dest_dir = extract_dest_dir(file);
|
||||
extract(file, dest_dir);
|
||||
return dest_dir;
|
||||
}
|
||||
|
||||
void extract_subproc(const fs::path& file, const fs::path& dest)
|
||||
void extract_subproc(const fs::u8path& file, const fs::u8path& dest)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
if (Context::instance().is_micromamba)
|
||||
{
|
||||
args = { get_self_exe_path().string(), "package", "extract", file.string(), dest.string() };
|
||||
args = {
|
||||
get_self_exe_path().string(), "package", "extract", file.string(), dest.string()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -463,7 +469,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
bool transmute(const fs::path& pkg_file, const fs::path& target, int compression_level)
|
||||
bool transmute(const fs::u8path& pkg_file, const fs::u8path& target, int compression_level)
|
||||
{
|
||||
TemporaryDirectory extract_dir;
|
||||
|
||||
|
@ -484,7 +490,7 @@ namespace mamba
|
|||
return true;
|
||||
}
|
||||
|
||||
bool validate(const fs::path& pkg_folder)
|
||||
bool validate(const fs::u8path& pkg_folder)
|
||||
{
|
||||
auto safety_checks = Context::instance().safety_checks;
|
||||
if (safety_checks == VerificationLevel::kDisabled)
|
||||
|
@ -501,7 +507,7 @@ namespace mamba
|
|||
auto paths_data = read_paths(pkg_folder);
|
||||
for (auto& p : paths_data)
|
||||
{
|
||||
fs::path full_path = pkg_folder / p.path;
|
||||
fs::u8path full_path = pkg_folder / p.path;
|
||||
// "exists" follows symlink so if the symlink doesn't link to existing target it
|
||||
// will return false. There is such symlink in _openmp_mutex package. So if the file
|
||||
// is a symlink we don't want to follow the symlink. The "paths_data" should include
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
std::map<std::string, PrefixFileParse> read_has_prefix(const fs::path& path)
|
||||
std::map<std::string, PrefixFileParse> read_has_prefix(const fs::u8path& path)
|
||||
{
|
||||
// reads `has_prefix` file and return dict mapping filepaths to
|
||||
// tuples(placeholder, FileMode) A line in `has_prefix` contains one of
|
||||
|
@ -24,7 +24,7 @@ namespace mamba
|
|||
// * binary
|
||||
//
|
||||
std::map<std::string, PrefixFileParse> res;
|
||||
fs::path file_path = path / "has_prefix";
|
||||
fs::u8path file_path = path / "has_prefix";
|
||||
if (!fs::exists(file_path))
|
||||
{
|
||||
return res;
|
||||
|
@ -52,7 +52,7 @@ namespace mamba
|
|||
return res;
|
||||
}
|
||||
|
||||
std::set<std::string> read_no_link(const fs::path& info_dir)
|
||||
std::set<std::string> read_no_link(const fs::u8path& info_dir)
|
||||
{
|
||||
std::vector<std::string> no_link_lines, no_softlink_lines;
|
||||
if (fs::exists(info_dir / "no_link"))
|
||||
|
@ -71,7 +71,7 @@ namespace mamba
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<PathData> read_paths(const fs::path& directory)
|
||||
std::vector<PathData> read_paths(const fs::u8path& directory)
|
||||
{
|
||||
auto info_dir = directory / "info";
|
||||
auto paths_json_path = info_dir / "paths.json";
|
||||
|
|
|
@ -43,13 +43,13 @@ namespace mamba
|
|||
return py_pin;
|
||||
}
|
||||
|
||||
std::vector<std::string> file_pins(const fs::path& file)
|
||||
std::vector<std::string> file_pins(const fs::u8path& file)
|
||||
{
|
||||
std::vector<std::string> pins;
|
||||
|
||||
if (fs::exists(file) && !fs::is_directory(file))
|
||||
{
|
||||
std::ifstream input_file(file);
|
||||
std::ifstream input_file(file.std_path());
|
||||
std::string line;
|
||||
while (std::getline(input_file, line))
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C"
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
auto PrefixData::create(const fs::path& prefix_path) -> expected_t<PrefixData>
|
||||
auto PrefixData::create(const fs::u8path& prefix_path) -> expected_t<PrefixData>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -31,12 +31,13 @@ namespace mamba
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
return tl::make_unexpected(mamba_error("Unkown error when trying to load prefix data " + prefix_path.string(),
|
||||
mamba_error_code::unknown));
|
||||
return tl::make_unexpected(
|
||||
mamba_error("Unkown error when trying to load prefix data " + prefix_path.string(),
|
||||
mamba_error_code::unknown));
|
||||
}
|
||||
}
|
||||
|
||||
PrefixData::PrefixData(const fs::path& prefix_path)
|
||||
PrefixData::PrefixData(const fs::u8path& prefix_path)
|
||||
: m_history(prefix_path)
|
||||
, m_prefix_path(prefix_path)
|
||||
{
|
||||
|
@ -129,12 +130,12 @@ namespace mamba
|
|||
return m_history;
|
||||
}
|
||||
|
||||
const fs::path& PrefixData::path() const
|
||||
const fs::u8path& PrefixData::path() const
|
||||
{
|
||||
return m_prefix_path;
|
||||
}
|
||||
|
||||
void PrefixData::load_single_record(const fs::path& path)
|
||||
void PrefixData::load_single_record(const fs::u8path& path)
|
||||
{
|
||||
LOG_INFO << "Loading single package record: " << path;
|
||||
auto infile = open_ifstream(path);
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace mamba
|
|||
|
||||
MRepo::MRepo(MPool& pool,
|
||||
const std::string& /*name*/,
|
||||
const fs::path& index,
|
||||
const fs::u8path& index,
|
||||
const RepoMetadata& metadata,
|
||||
const Channel& channel)
|
||||
: m_metadata(metadata)
|
||||
|
@ -236,7 +236,7 @@ namespace mamba
|
|||
return m_repo->nsolvables;
|
||||
}
|
||||
|
||||
const fs::path& MRepo::index_file()
|
||||
const fs::u8path& MRepo::index_file()
|
||||
{
|
||||
return m_json_file;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ namespace mamba
|
|||
|
||||
MRepo& MRepo::create(MPool& pool,
|
||||
const std::string& name,
|
||||
const fs::path& filename,
|
||||
const fs::u8path& filename,
|
||||
const RepoMetadata& meta,
|
||||
const Channel& channel)
|
||||
{
|
||||
|
@ -295,11 +295,11 @@ namespace mamba
|
|||
return pool.add_repo(MRepo(pool, name, uris));
|
||||
}
|
||||
|
||||
bool MRepo::read_file(const fs::path& filename)
|
||||
bool MRepo::read_file(const fs::u8path& filename)
|
||||
{
|
||||
bool is_solv = filename.extension() == ".solv";
|
||||
|
||||
fs::path filename_wo_extension;
|
||||
fs::u8path filename_wo_extension;
|
||||
if (is_solv)
|
||||
{
|
||||
m_solv_file = filename;
|
||||
|
@ -322,7 +322,7 @@ namespace mamba
|
|||
#ifdef _WIN32
|
||||
auto fp = _wfopen(m_solv_file.wstring().c_str(), L"rb");
|
||||
#else
|
||||
auto fp = fopen(m_solv_file.c_str(), "rb");
|
||||
auto fp = fopen(m_solv_file.string().c_str(), "rb");
|
||||
#endif
|
||||
if (!fp)
|
||||
{
|
||||
|
@ -398,7 +398,7 @@ namespace mamba
|
|||
#ifdef _WIN32
|
||||
auto fp = _wfopen(m_json_file.wstring().c_str(), L"r");
|
||||
#else
|
||||
auto fp = fopen(m_json_file.c_str(), "r");
|
||||
auto fp = fopen(m_json_file.string().c_str(), "r");
|
||||
#endif
|
||||
if (!fp)
|
||||
{
|
||||
|
@ -456,7 +456,7 @@ namespace mamba
|
|||
#ifdef _WIN32
|
||||
auto solv_f = _wfopen(m_solv_file.wstring().c_str(), L"wb");
|
||||
#else
|
||||
auto solv_f = fopen(m_solv_file.c_str(), "wb");
|
||||
auto solv_f = fopen(m_solv_file.string().c_str(), "wb");
|
||||
#endif
|
||||
if (!solv_f)
|
||||
{
|
||||
|
|
|
@ -106,14 +106,14 @@ namespace mamba
|
|||
key.SetStringValue(L"AutoRun", value);
|
||||
}
|
||||
|
||||
std::wstring get_hook_string(const fs::path& conda_prefix)
|
||||
std::wstring get_hook_string(const fs::u8path& conda_prefix)
|
||||
{
|
||||
// '"%s"' % join(conda_prefix, 'condabin', 'conda_hook.bat')
|
||||
return std::wstring(L"\"") + (conda_prefix / "condabin" / "mamba_hook.bat").wstring()
|
||||
+ std::wstring(L"\"");
|
||||
}
|
||||
|
||||
void init_cmd_exe_registry(const std::wstring& reg_path, const fs::path& conda_prefix)
|
||||
void init_cmd_exe_registry(const std::wstring& reg_path, const fs::u8path& conda_prefix)
|
||||
{
|
||||
std::wstring prev_value = get_autorun_registry_key(reg_path);
|
||||
std::wstring hook_string = get_hook_string(conda_prefix);
|
||||
|
@ -154,7 +154,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void deinit_cmd_exe_registry(const std::wstring& reg_path, const fs::path& conda_prefix)
|
||||
void deinit_cmd_exe_registry(const std::wstring& reg_path, const fs::u8path& conda_prefix)
|
||||
{
|
||||
std::wstring prev_value = get_autorun_registry_key(reg_path);
|
||||
std::wstring hook_string = get_hook_string(conda_prefix);
|
||||
|
@ -199,8 +199,8 @@ namespace mamba
|
|||
env will replace <prefix> or <prefix>/Library (Windows) by a POSIX root '/', breaking the
|
||||
PATH.
|
||||
*/
|
||||
fs::path bash;
|
||||
fs::path parent_process_name = get_process_name_by_pid(getppid());
|
||||
fs::u8path bash;
|
||||
fs::u8path parent_process_name = get_process_name_by_pid(getppid());
|
||||
if (contains(parent_process_name.filename().string(), "bash"))
|
||||
bash = parent_process_name;
|
||||
else
|
||||
|
@ -209,7 +209,8 @@ namespace mamba
|
|||
#else
|
||||
bash = env::which("bash");
|
||||
#endif
|
||||
const std::string command = bash.empty() ? "cygpath" : (bash.parent_path() / "cygpath").string();
|
||||
const std::string command
|
||||
= bash.empty() ? "cygpath" : (bash.parent_path() / "cygpath").string();
|
||||
std::string out, err;
|
||||
try
|
||||
{
|
||||
|
@ -232,9 +233,9 @@ namespace mamba
|
|||
}
|
||||
|
||||
|
||||
std::string rcfile_content(const fs::path& env_prefix,
|
||||
std::string rcfile_content(const fs::u8path& env_prefix,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe)
|
||||
const fs::u8path& mamba_exe)
|
||||
{
|
||||
std::stringstream content;
|
||||
|
||||
|
@ -253,7 +254,7 @@ namespace mamba
|
|||
|
||||
#else
|
||||
|
||||
fs::path env_bin = env_prefix / "bin";
|
||||
fs::u8path env_bin = env_prefix / "bin";
|
||||
|
||||
content << "\n# >>> mamba initialize >>>\n";
|
||||
content << "# !! Contents within this block are managed by 'mamba init' !!\n";
|
||||
|
@ -269,7 +270,7 @@ namespace mamba
|
|||
<< " ]; then\n";
|
||||
content << " . " << (env_prefix / "etc" / "profile.d" / "micromamba.sh") << "\n";
|
||||
content << " else\n";
|
||||
content << " export PATH=\"" << env_bin.c_str() << ":$PATH\""
|
||||
content << " export PATH=\"" << env_bin.string().c_str() << ":$PATH\""
|
||||
<< " # extra space after export prevents interference from conda init\n";
|
||||
content << " fi\n";
|
||||
content << "fi\n";
|
||||
|
@ -281,9 +282,9 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string xonsh_content(const fs::path& env_prefix,
|
||||
std::string xonsh_content(const fs::u8path& env_prefix,
|
||||
const std::string& /*shell*/,
|
||||
const fs::path& mamba_exe)
|
||||
const fs::u8path& mamba_exe)
|
||||
{
|
||||
std::stringstream content;
|
||||
std::string s_mamba_exe;
|
||||
|
@ -317,9 +318,9 @@ namespace mamba
|
|||
return content.str();
|
||||
}
|
||||
|
||||
std::string fish_content(const fs::path& env_prefix,
|
||||
std::string fish_content(const fs::u8path& env_prefix,
|
||||
const std::string& /*shell*/,
|
||||
const fs::path& mamba_exe)
|
||||
const fs::u8path& mamba_exe)
|
||||
{
|
||||
std::stringstream content;
|
||||
std::string s_mamba_exe;
|
||||
|
@ -343,10 +344,10 @@ namespace mamba
|
|||
return content.str();
|
||||
}
|
||||
|
||||
void modify_rc_file(const fs::path& file_path,
|
||||
const fs::path& conda_prefix,
|
||||
void modify_rc_file(const fs::u8path& file_path,
|
||||
const fs::u8path& conda_prefix,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe)
|
||||
const fs::u8path& mamba_exe)
|
||||
{
|
||||
Console::stream() << "Modifying RC file " << file_path
|
||||
<< "\nGenerating config for root prefix " << termcolor::bold
|
||||
|
@ -399,9 +400,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void reset_rc_file(const fs::path& file_path,
|
||||
void reset_rc_file(const fs::u8path& file_path,
|
||||
const std::string& shell,
|
||||
const fs::path& mamba_exe)
|
||||
const fs::u8path& mamba_exe)
|
||||
{
|
||||
Console::stream() << "Resetting RC file " << file_path
|
||||
<< "\nDeleting config for root prefix "
|
||||
|
@ -443,7 +444,7 @@ namespace mamba
|
|||
|
||||
std::string get_hook_contents(const std::string& shell)
|
||||
{
|
||||
fs::path exe = get_self_exe_path();
|
||||
fs::u8path exe = get_self_exe_path();
|
||||
|
||||
if (shell == "zsh" || shell == "bash" || shell == "posix")
|
||||
{
|
||||
|
@ -484,9 +485,9 @@ namespace mamba
|
|||
return "";
|
||||
}
|
||||
|
||||
void init_root_prefix_cmdexe(const fs::path& root_prefix)
|
||||
void init_root_prefix_cmdexe(const fs::u8path& root_prefix)
|
||||
{
|
||||
fs::path exe = get_self_exe_path();
|
||||
fs::u8path exe = get_self_exe_path();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -539,7 +540,7 @@ namespace mamba
|
|||
mamba_hook_bat_f << hook_content;
|
||||
}
|
||||
|
||||
void deinit_root_prefix_cmdexe(const fs::path& root_prefix)
|
||||
void deinit_root_prefix_cmdexe(const fs::u8path& root_prefix)
|
||||
{
|
||||
if (Context::instance().dry_run)
|
||||
{
|
||||
|
@ -582,7 +583,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void init_root_prefix(const std::string& shell, const fs::path& root_prefix)
|
||||
void init_root_prefix(const std::string& shell, const fs::u8path& root_prefix)
|
||||
{
|
||||
Context::instance().root_prefix = root_prefix;
|
||||
|
||||
|
@ -652,7 +653,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void deinit_root_prefix(const std::string& shell, const fs::path& root_prefix)
|
||||
void deinit_root_prefix(const std::string& shell, const fs::u8path& root_prefix)
|
||||
{
|
||||
if (Context::instance().dry_run)
|
||||
{
|
||||
|
@ -691,10 +692,10 @@ namespace mamba
|
|||
}
|
||||
else if (shell == "powershell")
|
||||
{
|
||||
fs::path mamba_hook_f = root_prefix / "condabin" / "mamba_hook.ps1";
|
||||
fs::u8path mamba_hook_f = root_prefix / "condabin" / "mamba_hook.ps1";
|
||||
fs::remove(mamba_hook_f);
|
||||
LOG_INFO << "Removed " << mamba_hook_f << " file.";
|
||||
fs::path mamba_psm1_f = root_prefix / "condabin" / "Mamba.psm1";
|
||||
fs::u8path mamba_psm1_f = root_prefix / "condabin" / "Mamba.psm1";
|
||||
fs::remove(mamba_psm1_f);
|
||||
LOG_INFO << "Removed " << mamba_psm1_f << " file.";
|
||||
|
||||
|
@ -707,9 +708,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::string powershell_contents(const fs::path& conda_prefix)
|
||||
std::string powershell_contents(const fs::u8path& conda_prefix)
|
||||
{
|
||||
fs::path self_exe = get_self_exe_path();
|
||||
fs::u8path self_exe = get_self_exe_path();
|
||||
|
||||
std::stringstream out;
|
||||
|
||||
|
@ -723,7 +724,7 @@ namespace mamba
|
|||
return out.str();
|
||||
}
|
||||
|
||||
void init_powershell(const fs::path& profile_path, const fs::path& conda_prefix)
|
||||
void init_powershell(const fs::u8path& profile_path, const fs::u8path& conda_prefix)
|
||||
{
|
||||
// NB: the user may not have created a profile. We need to check
|
||||
// if the file exists first.
|
||||
|
@ -785,7 +786,7 @@ namespace mamba
|
|||
return;
|
||||
}
|
||||
|
||||
void deinit_powershell(const fs::path& profile_path, const fs::path& conda_prefix)
|
||||
void deinit_powershell(const fs::u8path& profile_path, const fs::u8path& conda_prefix)
|
||||
{
|
||||
if (!fs::exists(profile_path))
|
||||
{
|
||||
|
@ -815,7 +816,7 @@ namespace mamba
|
|||
LOG_INFO << "Removed " << profile_path << " file because it's empty.";
|
||||
|
||||
// remove parent folder if it's empty
|
||||
fs::path parent_path = profile_path.parent_path();
|
||||
fs::u8path parent_path = profile_path.parent_path();
|
||||
if (fs::is_empty(parent_path))
|
||||
{
|
||||
fs::remove(parent_path);
|
||||
|
@ -862,29 +863,29 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
void init_shell(const std::string& shell, const fs::path& conda_prefix)
|
||||
void init_shell(const std::string& shell, const fs::u8path& conda_prefix)
|
||||
{
|
||||
init_root_prefix(shell, conda_prefix);
|
||||
auto mamba_exe = get_self_exe_path();
|
||||
fs::path home = env::home_directory();
|
||||
fs::u8path home = env::home_directory();
|
||||
if (shell == "bash")
|
||||
{
|
||||
fs::path bashrc_path = (on_mac || on_win) ? home / ".bash_profile" : home / ".bashrc";
|
||||
fs::u8path bashrc_path = (on_mac || on_win) ? home / ".bash_profile" : home / ".bashrc";
|
||||
modify_rc_file(bashrc_path, conda_prefix, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "zsh")
|
||||
{
|
||||
fs::path zshrc_path = home / ".zshrc";
|
||||
fs::u8path zshrc_path = home / ".zshrc";
|
||||
modify_rc_file(zshrc_path, conda_prefix, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "xonsh")
|
||||
{
|
||||
fs::path xonshrc_path = home / ".xonshrc";
|
||||
fs::u8path xonshrc_path = home / ".xonshrc";
|
||||
modify_rc_file(xonshrc_path, conda_prefix, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "fish")
|
||||
{
|
||||
fs::path fishrc_path = home / ".config" / "fish" / "config.fish";
|
||||
fs::u8path fishrc_path = home / ".config" / "fish" / "config.fish";
|
||||
modify_rc_file(fishrc_path, conda_prefix, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "cmd.exe")
|
||||
|
@ -925,28 +926,28 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
void deinit_shell(const std::string& shell, const fs::path& conda_prefix)
|
||||
void deinit_shell(const std::string& shell, const fs::u8path& conda_prefix)
|
||||
{
|
||||
auto mamba_exe = get_self_exe_path();
|
||||
fs::path home = env::home_directory();
|
||||
fs::u8path home = env::home_directory();
|
||||
if (shell == "bash")
|
||||
{
|
||||
fs::path bashrc_path = (on_mac || on_win) ? home / ".bash_profile" : home / ".bashrc";
|
||||
fs::u8path bashrc_path = (on_mac || on_win) ? home / ".bash_profile" : home / ".bashrc";
|
||||
reset_rc_file(bashrc_path, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "zsh")
|
||||
{
|
||||
fs::path zshrc_path = home / ".zshrc";
|
||||
fs::u8path zshrc_path = home / ".zshrc";
|
||||
reset_rc_file(zshrc_path, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "xonsh")
|
||||
{
|
||||
fs::path xonshrc_path = home / ".xonshrc";
|
||||
fs::u8path xonshrc_path = home / ".xonshrc";
|
||||
reset_rc_file(xonshrc_path, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "fish")
|
||||
{
|
||||
fs::path fishrc_path = home / ".config" / "fish" / "config.fish";
|
||||
fs::u8path fishrc_path = home / ".config" / "fish" / "config.fish";
|
||||
reset_rc_file(fishrc_path, shell, mamba_exe);
|
||||
}
|
||||
else if (shell == "cmd.exe")
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace mamba
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
nlohmann::json read_mod_and_etag(const fs::path& file)
|
||||
nlohmann::json read_mod_and_etag(const fs::u8path& file)
|
||||
{
|
||||
// parse json at the beginning of the stream such as
|
||||
// {"_url": "https://conda.anaconda.org/conda-forge/linux-64",
|
||||
|
@ -262,7 +262,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
fs::file_time_type::duration MSubdirData::check_cache(
|
||||
const fs::path& cache_file, const fs::file_time_type::clock::time_point& ref)
|
||||
const fs::u8path& cache_file, const fs::file_time_type::clock::time_point& ref)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ namespace mamba
|
|||
+ std::to_string(m_target->http_status));
|
||||
}
|
||||
|
||||
fs::path json_file, solv_file;
|
||||
fs::u8path json_file, solv_file;
|
||||
|
||||
if (m_target->http_status == 304)
|
||||
{
|
||||
|
@ -479,7 +479,7 @@ namespace mamba
|
|||
|
||||
LOG_DEBUG << "Copying repodata cache files from '" << m_expired_cache_path.string()
|
||||
<< "' to '" << m_writable_pkgs_dir.string() << "'";
|
||||
fs::path writable_cache_dir = create_cache_dir(m_writable_pkgs_dir);
|
||||
fs::u8path writable_cache_dir = create_cache_dir(m_writable_pkgs_dir);
|
||||
auto lock = LockFile(writable_cache_dir);
|
||||
|
||||
auto copied_json_file = writable_cache_dir / m_json_fn;
|
||||
|
@ -543,7 +543,7 @@ namespace mamba
|
|||
|
||||
LOG_DEBUG << "Finalized transfer of '" << m_repodata_url << "'";
|
||||
|
||||
fs::path writable_cache_dir = create_cache_dir(m_writable_pkgs_dir);
|
||||
fs::u8path writable_cache_dir = create_cache_dir(m_writable_pkgs_dir);
|
||||
json_file = writable_cache_dir / m_json_fn;
|
||||
auto lock = LockFile(writable_cache_dir);
|
||||
|
||||
|
@ -615,7 +615,8 @@ namespace mamba
|
|||
{
|
||||
LOG_INFO << "Decompressing metadata";
|
||||
auto json_temp_file = std::make_unique<TemporaryFile>();
|
||||
bool result = decompress::raw(m_temp_file->path().string(), json_temp_file->path().string());
|
||||
bool result
|
||||
= decompress::raw(m_temp_file->path().string(), json_temp_file->path().string());
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARNING << "Could not decompress " << m_temp_file->path();
|
||||
|
@ -628,7 +629,8 @@ namespace mamba
|
|||
{
|
||||
auto& ctx = Context::instance();
|
||||
m_temp_file = std::make_unique<TemporaryFile>();
|
||||
m_target = std::make_unique<DownloadTarget>(m_name, m_repodata_url, m_temp_file->path().string());
|
||||
m_target = std::make_unique<DownloadTarget>(
|
||||
m_name, m_repodata_url, m_temp_file->path().string());
|
||||
if (!(ctx.no_progress_bars || ctx.quiet || ctx.json))
|
||||
{
|
||||
m_progress_bar = Console::instance().add_progress_bar(m_name);
|
||||
|
@ -659,12 +661,12 @@ namespace mamba
|
|||
return cache_name_from_url(url) + ".json";
|
||||
}
|
||||
|
||||
std::string create_cache_dir(const fs::path& cache_path)
|
||||
std::string create_cache_dir(const fs::u8path& cache_path)
|
||||
{
|
||||
const auto cache_dir = cache_path / "cache";
|
||||
fs::create_directories(cache_dir);
|
||||
#ifndef _WIN32
|
||||
::chmod(cache_dir.c_str(), 02775);
|
||||
::chmod(cache_dir.string().c_str(), 02775);
|
||||
#endif
|
||||
return cache_dir.string();
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ namespace mamba
|
|||
m_has_progress_bars = !(ctx.no_progress_bars || ctx.quiet || ctx.json);
|
||||
}
|
||||
|
||||
void PackageDownloadExtractTarget::write_repodata_record(const fs::path& base_path)
|
||||
void PackageDownloadExtractTarget::write_repodata_record(const fs::u8path& base_path)
|
||||
{
|
||||
fs::path repodata_record_path = base_path / "info" / "repodata_record.json";
|
||||
fs::path index_path = base_path / "info" / "index.json";
|
||||
fs::u8path repodata_record_path = base_path / "info" / "repodata_record.json";
|
||||
fs::u8path index_path = base_path / "info" / "index.json";
|
||||
|
||||
nlohmann::json index, solvable_json;
|
||||
std::ifstream index_file = open_ifstream(index_path);
|
||||
|
@ -105,7 +105,7 @@ namespace mamba
|
|||
index["size"] = fs::file_size(m_tarball_path);
|
||||
}
|
||||
|
||||
std::ofstream repodata_record(repodata_record_path);
|
||||
std::ofstream repodata_record(repodata_record_path.std_path());
|
||||
repodata_record << index.dump(4);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,8 @@ namespace mamba
|
|||
void PackageDownloadExtractTarget::add_url()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(urls_txt_mutex);
|
||||
std::ofstream urls_txt(m_cache_path / "urls.txt", std::ios::app);
|
||||
const auto urls_file_path = m_cache_path / "urls.txt";
|
||||
std::ofstream urls_txt(urls_file_path.std_path(), std::ios::app);
|
||||
urls_txt << m_url << std::endl;
|
||||
}
|
||||
|
||||
|
@ -207,7 +208,7 @@ namespace mamba
|
|||
std::lock_guard<counting_semaphore> lock(DownloadExtractSemaphore::semaphore);
|
||||
interruption_point();
|
||||
LOG_DEBUG << "Decompressing '" << m_tarball_path.string() << "'";
|
||||
fs::path extract_path;
|
||||
fs::u8path extract_path;
|
||||
try
|
||||
{
|
||||
std::string fn = m_filename;
|
||||
|
@ -226,7 +227,7 @@ namespace mamba
|
|||
{
|
||||
LOG_DEBUG << "Removing '" << extract_path.string()
|
||||
<< "' before extracting it again";
|
||||
remove_all(extract_path);
|
||||
fs::remove_all(extract_path);
|
||||
}
|
||||
|
||||
// Use non-subproc version if concurrency is disabled to avoid
|
||||
|
@ -341,7 +342,7 @@ namespace mamba
|
|||
void PackageDownloadExtractTarget::clear_cache() const
|
||||
{
|
||||
fs::remove_all(m_tarball_path);
|
||||
fs::path dest_dir = strip_package_extension(m_tarball_path.string());
|
||||
fs::u8path dest_dir = strip_package_extension(m_tarball_path.string());
|
||||
if (fs::exists(dest_dir))
|
||||
{
|
||||
fs::remove_all(dest_dir);
|
||||
|
@ -366,11 +367,11 @@ namespace mamba
|
|||
// 2. If there is valid tarball, extract it, otherwise next.
|
||||
// 3. Run the full download pipeline.
|
||||
|
||||
fs::path extracted_cache = caches.get_extracted_dir_path(m_package_info);
|
||||
fs::u8path extracted_cache = caches.get_extracted_dir_path(m_package_info);
|
||||
|
||||
if (extracted_cache.empty())
|
||||
{
|
||||
fs::path tarball_cache = caches.get_tarball_path(m_package_info);
|
||||
fs::u8path tarball_cache = caches.get_tarball_path(m_package_info);
|
||||
// Compute the first writable cache and clean its status for the current package
|
||||
caches.first_writable_cache(true).clear_query_cache(m_package_info);
|
||||
m_cache_path = caches.first_writable_path();
|
||||
|
@ -533,7 +534,8 @@ namespace mamba
|
|||
if (!empty())
|
||||
{
|
||||
Console::instance().json_down("actions");
|
||||
Console::instance().json_write({ { "PREFIX", Context::instance().target_prefix.string() } });
|
||||
Console::instance().json_write(
|
||||
{ { "PREFIX", Context::instance().target_prefix.string() } });
|
||||
}
|
||||
|
||||
m_transaction_context = TransactionContext(
|
||||
|
@ -623,7 +625,8 @@ namespace mamba
|
|||
if (!empty())
|
||||
{
|
||||
Console::instance().json_down("actions");
|
||||
Console::instance().json_write({ { "PREFIX", Context::instance().target_prefix.string() } });
|
||||
Console::instance().json_write(
|
||||
{ { "PREFIX", Context::instance().target_prefix.string() } });
|
||||
}
|
||||
|
||||
m_transaction_context = TransactionContext(
|
||||
|
@ -954,11 +957,11 @@ namespace mamba
|
|||
<< "Changing " << PackageInfo(s).str() << " ==> " << PackageInfo(s2).str();
|
||||
|
||||
PackageInfo package_to_unlink(s);
|
||||
const fs::path ul_cache_path(
|
||||
const fs::u8path ul_cache_path(
|
||||
m_multi_cache.get_extracted_dir_path(package_to_unlink));
|
||||
|
||||
PackageInfo package_to_link(s2);
|
||||
const fs::path l_cache_path(
|
||||
const fs::u8path l_cache_path(
|
||||
m_multi_cache.get_extracted_dir_path(package_to_link, false));
|
||||
|
||||
UnlinkPackage up(package_to_unlink, ul_cache_path, &m_transaction_context);
|
||||
|
@ -978,7 +981,7 @@ namespace mamba
|
|||
{
|
||||
PackageInfo package_info(s);
|
||||
Console::stream() << "Unlinking " << package_info.str();
|
||||
const fs::path cache_path(m_multi_cache.get_extracted_dir_path(package_info));
|
||||
const fs::u8path cache_path(m_multi_cache.get_extracted_dir_path(package_info));
|
||||
UnlinkPackage up(package_info, cache_path, &m_transaction_context);
|
||||
up.execute();
|
||||
rollback.record(up);
|
||||
|
@ -987,14 +990,13 @@ namespace mamba
|
|||
}
|
||||
case SOLVER_TRANSACTION_INSTALL:
|
||||
{
|
||||
PackageInfo pacakge_info(s);
|
||||
Console::stream() << "Linking " << pacakge_info.str();
|
||||
const fs::path cache_path(
|
||||
m_multi_cache.get_extracted_dir_path(pacakge_info, false));
|
||||
LinkPackage lp(pacakge_info, cache_path, &m_transaction_context);
|
||||
PackageInfo package_info(s);
|
||||
Console::stream() << "Linking " << package_info.str();
|
||||
const fs::u8path cache_path(m_multi_cache.get_extracted_dir_path(package_info, false));
|
||||
LinkPackage lp(package_info, cache_path, &m_transaction_context);
|
||||
lp.execute();
|
||||
rollback.record(lp);
|
||||
m_history_entry.link_dists.push_back(pacakge_info.long_str());
|
||||
m_history_entry.link_dists.push_back(package_info.long_str());
|
||||
break;
|
||||
}
|
||||
case SOLVER_TRANSACTION_IGNORE:
|
||||
|
@ -1556,7 +1558,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
MTransaction create_explicit_transaction_from_lockfile(MPool& pool,
|
||||
const fs::path& env_lockfile_path,
|
||||
const fs::u8path& env_lockfile_path,
|
||||
MultiPackageCache& package_caches)
|
||||
{
|
||||
const auto maybe_lockfile = read_environment_lockfile(env_lockfile_path);
|
||||
|
|
|
@ -35,30 +35,30 @@ namespace mamba
|
|||
}
|
||||
|
||||
// supply short python version, e.g. 2.7, 3.5...
|
||||
fs::path get_python_short_path(const std::string& python_version [[maybe_unused]])
|
||||
fs::u8path get_python_short_path(const std::string& python_version [[maybe_unused]])
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return "python.exe";
|
||||
#else
|
||||
return fs::path("bin") / concat("python", python_version);
|
||||
return fs::u8path("bin") / concat("python", python_version);
|
||||
#endif
|
||||
}
|
||||
|
||||
fs::path get_python_site_packages_short_path(const std::string& python_version)
|
||||
fs::u8path get_python_site_packages_short_path(const std::string& python_version)
|
||||
{
|
||||
if (python_version.size() == 0)
|
||||
{
|
||||
return fs::path();
|
||||
return fs::u8path();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
return fs::path("Lib") / "site-packages";
|
||||
return fs::u8path("Lib") / "site-packages";
|
||||
#else
|
||||
return fs::path("lib") / concat("python", python_version) / "site-packages";
|
||||
return fs::u8path("lib") / concat("python", python_version) / "site-packages";
|
||||
#endif
|
||||
}
|
||||
|
||||
fs::path get_bin_directory_short_path()
|
||||
fs::u8path get_bin_directory_short_path()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return "Scripts";
|
||||
|
@ -67,8 +67,8 @@ namespace mamba
|
|||
#endif
|
||||
}
|
||||
|
||||
fs::path get_python_noarch_target_path(const std::string& source_short_path,
|
||||
const fs::path& target_site_packages_short_path)
|
||||
fs::u8path get_python_noarch_target_path(const std::string& source_short_path,
|
||||
const fs::u8path& target_site_packages_short_path)
|
||||
{
|
||||
if (starts_with(source_short_path, "site-packages/"))
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ namespace mamba
|
|||
compile_pyc = Context::instance().compile_pyc;
|
||||
}
|
||||
|
||||
TransactionContext::TransactionContext(const fs::path& target_prefix,
|
||||
TransactionContext::TransactionContext(const fs::u8path& target_prefix,
|
||||
const std::pair<std::string, std::string>& py_versions,
|
||||
const std::vector<MatchSpec>& requested_specs)
|
||||
: has_python(py_versions.first.size() != 0)
|
||||
|
@ -182,7 +182,8 @@ namespace mamba
|
|||
compile_python_sources(compileall_f);
|
||||
compileall_f.close();
|
||||
|
||||
command = { complete_python_path.string(), "-Wi", "-u", m_pyc_compileall->path().string()
|
||||
command = {
|
||||
complete_python_path.string(), "-Wi", "-u", m_pyc_compileall->path().string()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +239,7 @@ namespace mamba
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TransactionContext::try_pyc_compilation(const std::vector<fs::path>& py_files)
|
||||
bool TransactionContext::try_pyc_compilation(const std::vector<fs::u8path>& py_files)
|
||||
{
|
||||
static std::mutex pyc_compilation_mutex;
|
||||
std::lock_guard<std::mutex> lock(pyc_compilation_mutex);
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace mamba
|
|||
return path;
|
||||
}
|
||||
|
||||
fs::path tmp_path = fs::path(path);
|
||||
fs::u8path tmp_path = fs::u8path(path);
|
||||
std::string abs_path = fs::absolute(tmp_path).string();
|
||||
|
||||
// TODO: handle percent encoding
|
||||
|
|
|
@ -59,21 +59,21 @@ namespace mamba
|
|||
// ln -s abcdef emptylink
|
||||
// fs::exists(emptylink) == false
|
||||
// lexists(emptylink) == true
|
||||
bool lexists(const fs::path& path, std::error_code& ec)
|
||||
bool lexists(const fs::u8path& path, std::error_code& ec)
|
||||
{
|
||||
auto status = fs::symlink_status(path, ec);
|
||||
return status.type() != fs::file_type::not_found || status.type() == fs::file_type::symlink;
|
||||
}
|
||||
|
||||
bool lexists(const fs::path& path)
|
||||
bool lexists(const fs::u8path& path)
|
||||
{
|
||||
auto status = fs::symlink_status(path);
|
||||
return status.type() != fs::file_type::not_found || status.type() == fs::file_type::symlink;
|
||||
}
|
||||
|
||||
std::vector<fs::path> filter_dir(const fs::path& dir, const std::string& suffix)
|
||||
std::vector<fs::u8path> filter_dir(const fs::u8path& dir, const std::string& suffix)
|
||||
{
|
||||
std::vector<fs::path> result;
|
||||
std::vector<fs::u8path> result;
|
||||
if (fs::exists(dir) && fs::is_directory(dir))
|
||||
{
|
||||
for (const auto& entry : fs::directory_iterator(dir))
|
||||
|
@ -98,7 +98,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
// TODO expand variables, ~ and make absolute
|
||||
bool paths_equal(const fs::path& lhs, const fs::path& rhs)
|
||||
bool paths_equal(const fs::u8path& lhs, const fs::u8path& rhs)
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
fs::path& TemporaryDirectory::path()
|
||||
const fs::u8path& TemporaryDirectory::path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
TemporaryDirectory::operator fs::path()
|
||||
TemporaryDirectory::operator fs::u8path()
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ namespace mamba
|
|||
static std::mutex file_creation_mutex;
|
||||
|
||||
bool success = false;
|
||||
fs::path temp_path = fs::temp_directory_path(), final_path;
|
||||
fs::u8path temp_path = fs::temp_directory_path(), final_path;
|
||||
|
||||
std::lock_guard<std::mutex> file_creation_lock(file_creation_mutex);
|
||||
|
||||
|
@ -191,12 +191,12 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
fs::path& TemporaryFile::path()
|
||||
fs::u8path& TemporaryFile::path()
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
TemporaryFile::operator fs::path()
|
||||
TemporaryFile::operator fs::u8path()
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
@ -353,13 +353,10 @@ namespace mamba
|
|||
return string_transform(input, std::tolower);
|
||||
}
|
||||
|
||||
std::string read_contents(const fs::path& file_path, std::ios::openmode mode)
|
||||
std::string read_contents(const fs::u8path& file_path, std::ios::openmode mode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::ifstream in(file_path.wstring(), std::ios::in | mode);
|
||||
#else
|
||||
std::ifstream in(file_path, std::ios::in | mode);
|
||||
#endif
|
||||
std::ifstream in(file_path.std_path(), std::ios::in | mode);
|
||||
|
||||
if (in)
|
||||
{
|
||||
std::string contents;
|
||||
|
@ -377,9 +374,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> read_lines(const fs::path& file_path)
|
||||
std::vector<std::string> read_lines(const fs::u8path& file_path)
|
||||
{
|
||||
std::fstream file_stream(file_path, std::ios_base::in | std::ios_base::binary);
|
||||
std::fstream file_stream(file_path.std_path(), std::ios_base::in | std::ios_base::binary);
|
||||
if (file_stream.fail())
|
||||
{
|
||||
throw std::system_error(
|
||||
|
@ -425,7 +422,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
fs::path strip_package_extension(const std::string& file)
|
||||
fs::u8path strip_package_extension(const std::string& file)
|
||||
{
|
||||
std::string name, extension;
|
||||
split_package_extension(file, name, extension);
|
||||
|
@ -554,19 +551,19 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
std::size_t clean_trash_files(const fs::path& prefix, bool deep_clean)
|
||||
std::size_t clean_trash_files(const fs::u8path& prefix, bool deep_clean)
|
||||
{
|
||||
std::size_t deleted_files = 0;
|
||||
std::size_t remainig_trash = 0;
|
||||
std::error_code ec;
|
||||
std::vector<fs::path> remaining_files;
|
||||
std::vector<fs::u8path> remaining_files;
|
||||
auto trash_txt = prefix / "conda-meta" / "mamba_trash.txt";
|
||||
if (!deep_clean && fs::exists(trash_txt))
|
||||
{
|
||||
auto all_files = read_lines(trash_txt);
|
||||
for (auto& f : all_files)
|
||||
{
|
||||
fs::path full_path = prefix / f;
|
||||
fs::u8path full_path = prefix / f;
|
||||
LOG_INFO << "Trash: removing " << full_path;
|
||||
if (!fs::exists(full_path) || fs::remove(full_path, ec))
|
||||
{
|
||||
|
@ -585,7 +582,7 @@ namespace mamba
|
|||
if (deep_clean)
|
||||
{
|
||||
// recursive iterate over all files and delete `.mamba_trash` files
|
||||
std::vector<fs::path> f_to_rm;
|
||||
std::vector<fs::u8path> f_to_rm;
|
||||
for (auto& p : fs::recursive_directory_iterator(prefix))
|
||||
{
|
||||
if (p.path().extension() == ".mamba_trash")
|
||||
|
@ -628,7 +625,7 @@ namespace mamba
|
|||
return deleted_files;
|
||||
}
|
||||
|
||||
std::size_t remove_or_rename(const fs::path& path)
|
||||
std::size_t remove_or_rename(const fs::u8path& path)
|
||||
{
|
||||
std::error_code ec;
|
||||
std::size_t result = 0;
|
||||
|
@ -658,7 +655,7 @@ namespace mamba
|
|||
{
|
||||
LOG_INFO << "Caught a filesystem error for '" << path.string()
|
||||
<< "':" << ec.message() << " (File in use?)";
|
||||
fs::path trash_file = path;
|
||||
fs::u8path trash_file = path;
|
||||
std::size_t fcounter = 0;
|
||||
|
||||
trash_file.replace_extension(
|
||||
|
@ -747,7 +744,7 @@ namespace mamba
|
|||
return prepend(p.c_str(), start, newline);
|
||||
}
|
||||
|
||||
LockFile::LockFile(const fs::path& path, const std::chrono::seconds& timeout)
|
||||
LockFile::LockFile(const fs::u8path& path, const std::chrono::seconds& timeout)
|
||||
: m_path(path)
|
||||
, m_timeout(timeout)
|
||||
, m_locked(false)
|
||||
|
@ -774,7 +771,7 @@ namespace mamba
|
|||
#ifdef _WIN32
|
||||
m_fd = _wopen(m_lock.wstring().c_str(), O_RDWR | O_CREAT, 0666);
|
||||
#else
|
||||
m_fd = open(m_lock.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
m_fd = open(m_lock.string().c_str(), O_RDWR | O_CREAT, 0666);
|
||||
#endif
|
||||
if (m_fd <= 0)
|
||||
{
|
||||
|
@ -809,7 +806,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
LockFile::LockFile(const fs::path& path)
|
||||
LockFile::LockFile(const fs::u8path& path)
|
||||
: LockFile(path, std::chrono::seconds(Context::instance().lock_timeout))
|
||||
{
|
||||
}
|
||||
|
@ -905,7 +902,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
bool LockFile::is_locked(const fs::path& path)
|
||||
bool LockFile::is_locked(const fs::u8path& path)
|
||||
{
|
||||
// Windows locks are isolated between file descriptor
|
||||
// We can then test if locked by opening a new one
|
||||
|
@ -1118,17 +1115,17 @@ namespace mamba
|
|||
return lock(m_pid, false);
|
||||
}
|
||||
|
||||
fs::path LockFile::path() const
|
||||
fs::u8path LockFile::path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
fs::path LockFile::lockfile_path() const
|
||||
fs::u8path LockFile::lockfile_path() const
|
||||
{
|
||||
return m_lock;
|
||||
}
|
||||
|
||||
std::unique_ptr<LockFile> LockFile::try_lock(const fs::path& path) noexcept
|
||||
std::unique_ptr<LockFile> LockFile::try_lock(const fs::u8path& path) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1210,11 +1207,12 @@ namespace mamba
|
|||
std::string cmd_exe = env::get("COMSPEC").value_or("");
|
||||
if (!ends_with(to_lower(cmd_exe), "cmd.exe"))
|
||||
{
|
||||
cmd_exe
|
||||
= (fs::path(env::get("SystemRoot").value_or("")) / "System32" / "cmd.exe").string();
|
||||
cmd_exe = (fs::u8path(env::get("SystemRoot").value_or("")) / "System32" / "cmd.exe")
|
||||
.string();
|
||||
if (!fs::is_regular_file(cmd_exe))
|
||||
{
|
||||
cmd_exe = (fs::path(env::get("windir").value_or("")) / "System32" / "cmd.exe").string();
|
||||
cmd_exe = (fs::u8path(env::get("windir").value_or("")) / "System32" / "cmd.exe")
|
||||
.string();
|
||||
}
|
||||
if (!fs::is_regular_file(cmd_exe))
|
||||
{
|
||||
|
@ -1229,14 +1227,10 @@ namespace mamba
|
|||
return true;
|
||||
}
|
||||
|
||||
std::ofstream open_ofstream(const fs::path& path, std::ios::openmode mode)
|
||||
std::ofstream open_ofstream(const fs::u8path& path, std::ios::openmode mode)
|
||||
{
|
||||
std::ofstream outfile;
|
||||
#if _WIN32
|
||||
outfile.open(path.wstring(), mode);
|
||||
#else
|
||||
outfile.open(path, mode);
|
||||
#endif
|
||||
std::ofstream outfile(path.std_path(), mode);
|
||||
|
||||
if (!outfile.good())
|
||||
{
|
||||
LOG_ERROR << "Error opening for writing " << path << ": " << strerror(errno);
|
||||
|
@ -1245,14 +1239,9 @@ namespace mamba
|
|||
return outfile;
|
||||
}
|
||||
|
||||
std::ifstream open_ifstream(const fs::path& path, std::ios::openmode mode)
|
||||
std::ifstream open_ifstream(const fs::u8path& path, std::ios::openmode mode)
|
||||
{
|
||||
std::ifstream infile;
|
||||
#if _WIN32
|
||||
infile.open(path.wstring(), mode);
|
||||
#else
|
||||
infile.open(path, mode);
|
||||
#endif
|
||||
std::ifstream infile(path.std_path(), mode);
|
||||
if (!infile.good())
|
||||
{
|
||||
LOG_ERROR << "Error opening for reading " << path << ": " << strerror(errno);
|
||||
|
@ -1262,14 +1251,14 @@ namespace mamba
|
|||
}
|
||||
|
||||
|
||||
std::unique_ptr<TemporaryFile> wrap_call(const fs::path& root_prefix,
|
||||
const fs::path& prefix,
|
||||
std::unique_ptr<TemporaryFile> wrap_call(const fs::u8path& root_prefix,
|
||||
const fs::u8path& prefix,
|
||||
bool dev_mode,
|
||||
bool debug_wrapper_scripts,
|
||||
const std::vector<std::string>& arguments)
|
||||
{
|
||||
// todo add abspath here
|
||||
fs::path tmp_prefix = prefix / ".tmp";
|
||||
fs::u8path tmp_prefix = prefix / ".tmp";
|
||||
|
||||
#ifdef _WIN32
|
||||
ensure_comspec_set();
|
||||
|
@ -1282,12 +1271,13 @@ namespace mamba
|
|||
|
||||
if (dev_mode)
|
||||
{
|
||||
conda_bat = (fs::path(CONDA_PACKAGE_ROOT) / "shell" / "condabin" / "conda.bat").string();
|
||||
conda_bat
|
||||
= (fs::u8path(CONDA_PACKAGE_ROOT) / "shell" / "condabin" / "conda.bat").string();
|
||||
}
|
||||
else
|
||||
{
|
||||
conda_bat
|
||||
= env::get("CONDA_BAT").value_or((fs::absolute(root_prefix) / "condabin" / bat_name).string());
|
||||
conda_bat = env::get("CONDA_BAT")
|
||||
.value_or((fs::absolute(root_prefix) / "condabin" / bat_name).string());
|
||||
}
|
||||
if (!fs::exists(conda_bat) && Context::instance().is_micromamba)
|
||||
{
|
||||
|
@ -1414,7 +1404,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
std::tuple<std::vector<std::string>, std::unique_ptr<TemporaryFile>> prepare_wrapped_call(
|
||||
const fs::path& prefix, const std::vector<std::string>& cmd)
|
||||
const fs::u8path& prefix, const std::vector<std::string>& cmd)
|
||||
{
|
||||
std::vector<std::string> command_args;
|
||||
std::unique_ptr<TemporaryFile> script_file;
|
||||
|
@ -1437,7 +1427,7 @@ namespace mamba
|
|||
else
|
||||
{
|
||||
// shell_path = 'sh' if 'bsd' in sys.platform else 'bash'
|
||||
fs::path shell_path = env::which("bash");
|
||||
fs::u8path shell_path = env::which("bash");
|
||||
if (shell_path.empty())
|
||||
{
|
||||
shell_path = env::which("sh");
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace mamba
|
|||
{
|
||||
// Heavily inspired by https://github.com/gpakosz/whereami/
|
||||
// check their source to add support for other OS
|
||||
fs::path get_self_exe_path()
|
||||
fs::u8path get_self_exe_path()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD size;
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace validate
|
|||
{
|
||||
}
|
||||
|
||||
std::string sha256sum(const fs::path& path)
|
||||
std::string sha256sum(const fs::u8path& path)
|
||||
{
|
||||
unsigned char hash[MAMBA_SHA256_SIZE_BYTES];
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
|
||||
|
@ -167,7 +167,7 @@ namespace validate
|
|||
return ::mamba::hex_string(hash, MAMBA_SHA256_SIZE_BYTES);
|
||||
}
|
||||
|
||||
std::string md5sum(const fs::path& path)
|
||||
std::string md5sum(const fs::u8path& path)
|
||||
{
|
||||
unsigned char hash[MAMBA_MD5_SIZE_BYTES];
|
||||
|
||||
|
@ -194,17 +194,17 @@ namespace validate
|
|||
return ::mamba::hex_string(hash, MAMBA_MD5_SIZE_BYTES);
|
||||
}
|
||||
|
||||
bool sha256(const fs::path& path, const std::string& validation)
|
||||
bool sha256(const fs::u8path& path, const std::string& validation)
|
||||
{
|
||||
return sha256sum(path) == validation;
|
||||
}
|
||||
|
||||
bool md5(const fs::path& path, const std::string& validation)
|
||||
bool md5(const fs::u8path& path, const std::string& validation)
|
||||
{
|
||||
return md5sum(path) == validation;
|
||||
}
|
||||
|
||||
bool file_size(const fs::path& path, std::uintmax_t validation)
|
||||
bool file_size(const fs::u8path& path, std::uintmax_t validation)
|
||||
{
|
||||
return fs::file_size(path) == validation;
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ namespace validate
|
|||
}
|
||||
}
|
||||
|
||||
bool SpecBase::is_compatible(const fs::path& p) const
|
||||
bool SpecBase::is_compatible(const fs::u8path& p) const
|
||||
{
|
||||
std::regex name_re;
|
||||
std::smatch matches;
|
||||
|
@ -615,7 +615,7 @@ namespace validate
|
|||
}
|
||||
else
|
||||
{
|
||||
std::ifstream i(p);
|
||||
std::ifstream i(p.std_path());
|
||||
json j;
|
||||
i >> j;
|
||||
return is_compatible(j);
|
||||
|
@ -864,7 +864,7 @@ namespace validate
|
|||
m_expires = expires;
|
||||
}
|
||||
|
||||
json RoleBase::read_json_file(const fs::path& p, bool update) const
|
||||
json RoleBase::read_json_file(const fs::u8path& p, bool update) const
|
||||
{
|
||||
if (!fs::exists(p))
|
||||
{
|
||||
|
@ -969,7 +969,7 @@ namespace validate
|
|||
}
|
||||
}
|
||||
|
||||
std::ifstream i(p);
|
||||
std::ifstream i(p.std_path());
|
||||
json j;
|
||||
i >> j;
|
||||
|
||||
|
@ -1046,13 +1046,13 @@ namespace validate
|
|||
{
|
||||
}
|
||||
|
||||
std::vector<fs::path> RootRole::possible_update_files()
|
||||
std::vector<fs::u8path> RootRole::possible_update_files()
|
||||
{
|
||||
auto new_v = std::to_string(version() + 1);
|
||||
auto compat_spec = spec_impl()->compatible_prefix();
|
||||
auto upgrade_spec = spec_impl()->upgrade_prefix();
|
||||
|
||||
std::vector<fs::path> files;
|
||||
std::vector<fs::u8path> files;
|
||||
// upgrade first
|
||||
for (auto& s : upgrade_spec)
|
||||
{
|
||||
|
@ -1068,7 +1068,7 @@ namespace validate
|
|||
return files;
|
||||
}
|
||||
|
||||
std::unique_ptr<RootRole> RootRole::update(fs::path path)
|
||||
std::unique_ptr<RootRole> RootRole::update(fs::u8path path)
|
||||
{
|
||||
auto j = read_json_file(path, true);
|
||||
return update(j);
|
||||
|
@ -1076,7 +1076,7 @@ namespace validate
|
|||
|
||||
// `create_update` currently catch a possible spec version update by testing
|
||||
// and extracting spec version from JSON. It could be done upstream (in
|
||||
// `update(fs::path)`) if we decide to specify the spec version in the file name.
|
||||
// `update(fs::u8path)`) if we decide to specify the spec version in the file name.
|
||||
// The filename would take the form VERSION_NUMBER.SPECVERSION.FILENAME.EXT
|
||||
// To disambiguate version and spec version: 1.sv0.6.root.json or 1.sv1.root.json
|
||||
std::unique_ptr<RootRole> RootRole::update(json j)
|
||||
|
@ -1139,7 +1139,7 @@ namespace validate
|
|||
load_from_json(j);
|
||||
}
|
||||
|
||||
RootImpl::RootImpl(const fs::path& path)
|
||||
RootImpl::RootImpl(const fs::u8path& path)
|
||||
: RootRole(std::make_shared<SpecImpl>())
|
||||
{
|
||||
auto j = read_json_file(path);
|
||||
|
@ -1209,7 +1209,7 @@ namespace validate
|
|||
}
|
||||
|
||||
std::unique_ptr<RepoIndexChecker> RootImpl::build_index_checker(
|
||||
const std::string& /*url*/, const fs::path& /*cache_path*/) const
|
||||
const std::string& /*url*/, const fs::u8path& /*cache_path*/) const
|
||||
{
|
||||
std::unique_ptr<RepoIndexChecker> ptr;
|
||||
return ptr;
|
||||
|
@ -1315,7 +1315,7 @@ namespace validate
|
|||
return m_timestamp;
|
||||
}
|
||||
|
||||
RootImpl::RootImpl(const fs::path& path)
|
||||
RootImpl::RootImpl(const fs::u8path& path)
|
||||
: RootRole(std::make_shared<SpecImpl>())
|
||||
{
|
||||
auto j = read_json_file(path);
|
||||
|
@ -1423,9 +1423,9 @@ namespace validate
|
|||
}
|
||||
|
||||
std::unique_ptr<RepoIndexChecker> RootImpl::build_index_checker(
|
||||
const std::string& base_url, const fs::path& cache_path) const
|
||||
const std::string& base_url, const fs::u8path& cache_path) const
|
||||
{
|
||||
fs::path metadata_path = cache_path / "key_mgr.json";
|
||||
fs::u8path metadata_path = cache_path / "key_mgr.json";
|
||||
|
||||
auto tmp_dir = std::make_unique<mamba::TemporaryDirectory>();
|
||||
auto tmp_metadata_path = tmp_dir->path() / "key_mgr.json";
|
||||
|
@ -1477,7 +1477,7 @@ namespace validate
|
|||
throw fetching_error();
|
||||
}
|
||||
|
||||
KeyMgrRole RootImpl::create_key_mgr(const fs::path& p) const
|
||||
KeyMgrRole RootImpl::create_key_mgr(const fs::u8path& p) const
|
||||
{
|
||||
return KeyMgrRole(p, all_keys()["key_mgr"], spec_impl());
|
||||
}
|
||||
|
@ -1526,7 +1526,7 @@ namespace validate
|
|||
role.check_defined_roles();
|
||||
}
|
||||
|
||||
KeyMgrRole::KeyMgrRole(const fs::path& p,
|
||||
KeyMgrRole::KeyMgrRole(const fs::u8path& p,
|
||||
const RoleFullKeys& keys,
|
||||
const std::shared_ptr<SpecBase> spec)
|
||||
: RoleBase("key_mgr", spec)
|
||||
|
@ -1566,7 +1566,7 @@ namespace validate
|
|||
return m_keys;
|
||||
}
|
||||
|
||||
PkgMgrRole KeyMgrRole::create_pkg_mgr(const fs::path& p) const
|
||||
PkgMgrRole KeyMgrRole::create_pkg_mgr(const fs::u8path& p) const
|
||||
{
|
||||
return PkgMgrRole(p, all_keys()["pkg_mgr"], spec_impl());
|
||||
}
|
||||
|
@ -1577,9 +1577,9 @@ namespace validate
|
|||
}
|
||||
|
||||
std::unique_ptr<RepoIndexChecker> KeyMgrRole::build_index_checker(
|
||||
const std::string& base_url, const fs::path& cache_path) const
|
||||
const std::string& base_url, const fs::u8path& cache_path) const
|
||||
{
|
||||
fs::path metadata_path = cache_path / "pkg_mgr.json";
|
||||
fs::u8path metadata_path = cache_path / "pkg_mgr.json";
|
||||
|
||||
auto tmp_dir = std::make_unique<mamba::TemporaryDirectory>();
|
||||
auto tmp_metadata_path = tmp_dir->path() / "pkg_mgr.json";
|
||||
|
@ -1707,7 +1707,7 @@ namespace validate
|
|||
{
|
||||
}
|
||||
|
||||
PkgMgrRole::PkgMgrRole(const fs::path& p,
|
||||
PkgMgrRole::PkgMgrRole(const fs::u8path& p,
|
||||
const RoleFullKeys& keys,
|
||||
const std::shared_ptr<SpecBase> spec)
|
||||
: RoleBase("pkg_mgr", spec)
|
||||
|
@ -1867,7 +1867,7 @@ namespace validate
|
|||
}
|
||||
}
|
||||
|
||||
void PkgMgrRole::verify_index(const fs::path& p) const
|
||||
void PkgMgrRole::verify_index(const fs::u8path& p) const
|
||||
{
|
||||
if (!fs::exists(p))
|
||||
{
|
||||
|
@ -1875,7 +1875,7 @@ namespace validate
|
|||
throw index_error();
|
||||
}
|
||||
|
||||
std::ifstream i(p);
|
||||
std::ifstream i(p.std_path());
|
||||
json j;
|
||||
i >> j;
|
||||
|
||||
|
@ -1977,13 +1977,13 @@ namespace validate
|
|||
}
|
||||
|
||||
RepoChecker::RepoChecker(const std::string& base_url,
|
||||
const fs::path& ref_path,
|
||||
const fs::path& cache_path)
|
||||
const fs::u8path& ref_path,
|
||||
const fs::u8path& cache_path)
|
||||
: m_base_url(base_url)
|
||||
, m_ref_path(ref_path)
|
||||
, m_cache_path(cache_path){};
|
||||
|
||||
const fs::path& RepoChecker::cache_path()
|
||||
const fs::u8path& RepoChecker::cache_path()
|
||||
{
|
||||
return m_cache_path;
|
||||
}
|
||||
|
@ -2010,7 +2010,7 @@ namespace validate
|
|||
p_index_checker->verify_index(j);
|
||||
}
|
||||
|
||||
void RepoChecker::verify_index(const fs::path& p) const
|
||||
void RepoChecker::verify_index(const fs::u8path& p) const
|
||||
{
|
||||
p_index_checker->verify_index(p);
|
||||
}
|
||||
|
@ -2025,12 +2025,12 @@ namespace validate
|
|||
return m_root_version;
|
||||
}
|
||||
|
||||
fs::path RepoChecker::ref_root()
|
||||
fs::u8path RepoChecker::ref_root()
|
||||
{
|
||||
return m_ref_path / "root.json";
|
||||
}
|
||||
|
||||
fs::path RepoChecker::cached_root()
|
||||
fs::u8path RepoChecker::cached_root()
|
||||
{
|
||||
if (cache_path().empty())
|
||||
{
|
||||
|
@ -2042,7 +2042,7 @@ namespace validate
|
|||
}
|
||||
}
|
||||
|
||||
void RepoChecker::persist_file(const fs::path& file_path)
|
||||
void RepoChecker::persist_file(const fs::u8path& file_path)
|
||||
{
|
||||
if (fs::exists(cached_root()))
|
||||
fs::remove(cached_root());
|
||||
|
@ -2050,7 +2050,7 @@ namespace validate
|
|||
fs::copy(file_path, cached_root());
|
||||
}
|
||||
|
||||
fs::path RepoChecker::initial_trusted_root()
|
||||
fs::u8path RepoChecker::initial_trusted_root()
|
||||
{
|
||||
if (fs::exists(cached_root()))
|
||||
{
|
||||
|
@ -2106,7 +2106,7 @@ namespace validate
|
|||
LOG_DEBUG << "Starting updates of 'root' metadata";
|
||||
do
|
||||
{
|
||||
fs::path tmp_file_path;
|
||||
fs::u8path tmp_file_path;
|
||||
|
||||
// Update from the most recent spec supported by this client
|
||||
for (auto& f : update_files)
|
||||
|
@ -2114,8 +2114,8 @@ namespace validate
|
|||
auto url = mamba::concat(m_base_url, "/", f.string());
|
||||
tmp_file_path = tmp_dir_path / f;
|
||||
|
||||
auto dl_target
|
||||
= std::make_unique<mamba::DownloadTarget>(f.string(), url, tmp_file_path.string());
|
||||
auto dl_target = std::make_unique<mamba::DownloadTarget>(
|
||||
f.string(), url, tmp_file_path.string());
|
||||
|
||||
if (dl_target->resource_exists())
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace mamba
|
|||
|
||||
for (auto& p : paths)
|
||||
{
|
||||
if (fs::exists(fs::path(p) / "nvcuda.dll"))
|
||||
if (fs::exists(fs::u8path(p) / "nvcuda.dll"))
|
||||
{
|
||||
may_exist = true;
|
||||
break;
|
||||
|
|
|
@ -402,7 +402,7 @@ namespace mamba
|
|||
const Channel& c4 = make_channel(value4);
|
||||
EXPECT_EQ(c4.scheme(), "file");
|
||||
#ifdef _WIN32
|
||||
std::string driveletter = fs::absolute(fs::path("/")).string().substr(0, 1);
|
||||
std::string driveletter = fs::absolute(fs::u8path("/")).string().substr(0, 1);
|
||||
EXPECT_EQ(c4.location(), driveletter + ":/home/mamba/test");
|
||||
#else
|
||||
EXPECT_EQ(c4.location(), "/home/mamba/test");
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace mamba
|
|||
{
|
||||
bool has_config_name(const std::string& file);
|
||||
|
||||
bool is_config_file(const fs::path& path);
|
||||
bool is_config_file(const fs::u8path& path);
|
||||
|
||||
void print_scalar_node(YAML::Emitter&,
|
||||
YAML::Node value,
|
||||
|
@ -34,14 +34,15 @@ namespace mamba
|
|||
void load_test_config(std::string rc)
|
||||
{
|
||||
const auto unique_location = tempfile_ptr->path();
|
||||
std::ofstream out_file(unique_location, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(unique_location.std_path(),
|
||||
std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << rc;
|
||||
out_file.close();
|
||||
|
||||
mamba::Configuration::instance().reset_configurables();
|
||||
mamba::Configuration::instance()
|
||||
.at("rc_files")
|
||||
.set_value<std::vector<fs::path>>({ unique_location });
|
||||
.set_value<std::vector<fs::u8path>>({ unique_location });
|
||||
mamba::Configuration::instance().at("show_banner").set_default_value(false);
|
||||
mamba::Configuration::instance().load();
|
||||
}
|
||||
|
@ -49,14 +50,14 @@ namespace mamba
|
|||
void load_test_config(std::vector<std::string> rcs)
|
||||
{
|
||||
std::vector<std::unique_ptr<TemporaryFile>> tempfiles;
|
||||
std::vector<fs::path> sources;
|
||||
std::vector<fs::u8path> sources;
|
||||
|
||||
for (auto rc : rcs)
|
||||
{
|
||||
tempfiles.push_back(std::make_unique<TemporaryFile>("mambarc", ".yaml"));
|
||||
fs::path loc = tempfiles.back()->path();
|
||||
fs::u8path loc = tempfiles.back()->path();
|
||||
|
||||
std::ofstream out_file(loc);
|
||||
std::ofstream out_file(loc.std_path());
|
||||
out_file << rc;
|
||||
out_file.close();
|
||||
|
||||
|
@ -491,23 +492,24 @@ namespace mamba
|
|||
#ifdef _WIN32
|
||||
std::string extra_cache
|
||||
= "\n - "
|
||||
+ (fs::path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs").string()
|
||||
+ (fs::u8path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs").string()
|
||||
+ " # 'fallback'";
|
||||
#else
|
||||
std::string extra_cache = "";
|
||||
#endif
|
||||
EXPECT_EQ(config.dump(MAMBA_SHOW_CONFIG_VALUES | MAMBA_SHOW_CONFIG_SRCS
|
||||
| MAMBA_SHOW_ALL_CONFIGS,
|
||||
{ "pkgs_dirs" }),
|
||||
unindent((R"(
|
||||
EXPECT_EQ(
|
||||
config.dump(MAMBA_SHOW_CONFIG_VALUES | MAMBA_SHOW_CONFIG_SRCS
|
||||
| MAMBA_SHOW_ALL_CONFIGS,
|
||||
{ "pkgs_dirs" }),
|
||||
unindent((R"(
|
||||
pkgs_dirs:
|
||||
- )"
|
||||
+ (fs::path(root_prefix_str) / "pkgs").string() + R"( # 'fallback'
|
||||
+ (fs::u8path(root_prefix_str) / "pkgs").string() + R"( # 'fallback'
|
||||
- )"
|
||||
+ (env::home_directory() / ".mamba" / "pkgs").string()
|
||||
+ R"( # 'fallback')" + extra_cache)
|
||||
.c_str()));
|
||||
EXPECT_EQ(ctx.pkgs_dirs, config.at("pkgs_dirs").value<std::vector<fs::path>>());
|
||||
+ (env::home_directory() / ".mamba" / "pkgs").string()
|
||||
+ R"( # 'fallback')" + extra_cache)
|
||||
.c_str()));
|
||||
EXPECT_EQ(ctx.pkgs_dirs, config.at("pkgs_dirs").value<std::vector<fs::u8path>>());
|
||||
|
||||
std::string cache4 = (env::home_directory() / "babaz").string();
|
||||
env::set("CONDA_PKGS_DIRS", cache4);
|
||||
|
@ -962,15 +964,15 @@ namespace mamba
|
|||
{
|
||||
using namespace detail;
|
||||
|
||||
fs::path p = "config_test/.condarc";
|
||||
fs::u8path p = "config_test/.condarc";
|
||||
|
||||
std::vector<fs::path> wrong_paths = {
|
||||
std::vector<fs::u8path> wrong_paths = {
|
||||
"config_test", "conf_test", "config_test/condarc", "history_test/conda-meta/history"
|
||||
};
|
||||
|
||||
EXPECT_TRUE(is_config_file(p));
|
||||
|
||||
for (fs::path wp : wrong_paths)
|
||||
for (const fs::u8path& wp : wrong_paths)
|
||||
{
|
||||
EXPECT_FALSE(is_config_file(wp));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace mamba
|
|||
// {
|
||||
// Context::instance().verbosity = 3;
|
||||
// PackageInfo pkg("wheel", "0.34.2", "py_1", 1);
|
||||
// fs::path prefix = "C:\\Users\\wolfv\\miniconda3\\";
|
||||
// fs::u8path prefix = "C:\\Users\\wolfv\\miniconda3\\";
|
||||
// TransactionContext tc(prefix, "3.8.x");
|
||||
// // try {
|
||||
// UnlinkPackage up(pkg, &tc);
|
||||
|
@ -149,7 +149,7 @@ namespace mamba
|
|||
EXPECT_EQ(ms.version, "0.1");
|
||||
EXPECT_EQ(ms.build, "conda_forge");
|
||||
#ifdef _WIN32
|
||||
std::string driveletter = fs::absolute(fs::path("/")).string().substr(0, 1);
|
||||
std::string driveletter = fs::absolute(fs::u8path("/")).string().substr(0, 1);
|
||||
EXPECT_EQ(
|
||||
ms.url,
|
||||
std::string("file://") + driveletter
|
||||
|
@ -300,7 +300,7 @@ namespace mamba
|
|||
auto& ctx = Context::instance();
|
||||
ctx.root_prefix = "/home/user/micromamba/";
|
||||
ctx.envs_dirs = { ctx.root_prefix / "envs" };
|
||||
fs::path prefix = "/home/user/micromamba/envs/testprefix";
|
||||
fs::u8path prefix = "/home/user/micromamba/envs/testprefix";
|
||||
|
||||
EXPECT_EQ(env_name(prefix), "testprefix");
|
||||
prefix = "/home/user/micromamba/envs/a.txt";
|
||||
|
@ -334,8 +334,8 @@ namespace mamba
|
|||
|
||||
TEST(fsutil, expand_user)
|
||||
{
|
||||
fs::path pbefore = "/tmp/test/xyz.txt";
|
||||
fs::path p = env::expand_user(pbefore);
|
||||
fs::u8path pbefore = "/tmp/test/xyz.txt";
|
||||
fs::u8path p = env::expand_user(pbefore);
|
||||
EXPECT_EQ(p, pbefore);
|
||||
}
|
||||
|
||||
|
@ -492,12 +492,12 @@ namespace mamba
|
|||
namespace detail
|
||||
{
|
||||
// read the header that contains json like {"_mod": "...", ...}
|
||||
nlohmann::json read_mod_and_etag(const fs::path& file);
|
||||
nlohmann::json read_mod_and_etag(const fs::u8path& file);
|
||||
}
|
||||
|
||||
TEST(subdirdata, parse_mod_etag)
|
||||
{
|
||||
fs::path cache_folder = fs::path("repodata_json_cache");
|
||||
fs::u8path cache_folder = fs::u8path("repodata_json_cache");
|
||||
auto j = detail::read_mod_and_etag(cache_folder / "test_1.json");
|
||||
EXPECT_EQ(j["_mod"], "Fri, 11 Feb 2022 13:52:44 GMT");
|
||||
EXPECT_EQ(
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, invalid_version_fails)
|
||||
{
|
||||
const fs::path invalid_version_lockfile_path{ "env_lockfile_test/bad_version-lock.yaml" };
|
||||
const fs::u8path invalid_version_lockfile_path{ "env_lockfile_test/bad_version-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(invalid_version_lockfile_path);
|
||||
ASSERT_FALSE(maybe_lockfile);
|
||||
const auto error = maybe_lockfile.error();
|
||||
|
@ -39,7 +39,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, valid_no_package_succeed)
|
||||
{
|
||||
const fs::path lockfile_path{ "env_lockfile_test/good_no_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ "env_lockfile_test/good_no_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -48,7 +48,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, invalid_package_fails)
|
||||
{
|
||||
const fs::path lockfile_path{ "env_lockfile_test/bad_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ "env_lockfile_test/bad_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_FALSE(maybe_lockfile);
|
||||
const auto error = maybe_lockfile.error();
|
||||
|
@ -59,7 +59,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, valid_one_package_succeed)
|
||||
{
|
||||
const fs::path lockfile_path{ "env_lockfile_test/good_one_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ "env_lockfile_test/good_one_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -68,7 +68,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, valid_multiple_packages_succeed)
|
||||
{
|
||||
const fs::path lockfile_path{ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -77,7 +77,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, get_specific_packages)
|
||||
{
|
||||
const fs::path lockfile_path{ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
const auto lockfile = read_environment_lockfile(lockfile_path).value();
|
||||
EXPECT_TRUE(lockfile.get_packages_for("", "", "").empty());
|
||||
{
|
||||
|
@ -97,13 +97,14 @@ namespace mamba
|
|||
EXPECT_TRUE(is_env_lockfile_name("../../some/dir/something-lock.yaml"));
|
||||
EXPECT_TRUE(is_env_lockfile_name("../../some/dir/something-lock.yml"));
|
||||
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::path{ "something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::path{ "something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::path{ "/some/dir/something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::path{ "/some/dir/something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::u8path{ "something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::u8path{ "something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::u8path{ "/some/dir/something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::u8path{ "/some/dir/something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(
|
||||
is_env_lockfile_name(fs::path{ "../../some/dir/something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_env_lockfile_name(fs::path{ "../../some/dir/something-lock.yml" }.string()));
|
||||
is_env_lockfile_name(fs::u8path{ "../../some/dir/something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(
|
||||
is_env_lockfile_name(fs::u8path{ "../../some/dir/something-lock.yml" }.string()));
|
||||
|
||||
EXPECT_FALSE(is_env_lockfile_name("something"));
|
||||
EXPECT_FALSE(is_env_lockfile_name("something-lock"));
|
||||
|
@ -117,10 +118,10 @@ namespace mamba
|
|||
EXPECT_FALSE(is_env_lockfile_name("../../some/dir/something.yaml"));
|
||||
EXPECT_FALSE(is_env_lockfile_name("../../some/dir/something.yml"));
|
||||
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::path{ "something" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::path{ "something-lock" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::path{ "/some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::path{ "../../some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::u8path{ "something" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::u8path{ "something-lock" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::u8path{ "/some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_env_lockfile_name(fs::u8path{ "../../some/dir/something" }.string()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace mamba
|
|||
{
|
||||
protected:
|
||||
std::unique_ptr<TemporaryDirectory> p_tempdir;
|
||||
fs::path tempdir_path;
|
||||
fs::u8path tempdir_path;
|
||||
|
||||
LockDirTest()
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ namespace mamba
|
|||
EXPECT_EQ(mamba::LockFile::read_pid(lock.fd()), pid);
|
||||
}
|
||||
|
||||
fs::path lock_path = tempdir_path / (tempdir_path.filename().string() + ".lock");
|
||||
fs::u8path lock_path = tempdir_path / (tempdir_path.filename().string() + ".lock");
|
||||
EXPECT_FALSE(fs::exists(lock_path));
|
||||
|
||||
args = { lock_cli, "is-locked", lock_path.string() };
|
||||
|
@ -150,7 +150,7 @@ namespace mamba
|
|||
{
|
||||
protected:
|
||||
std::unique_ptr<TemporaryFile> p_tempfile;
|
||||
fs::path tempfile_path;
|
||||
fs::u8path tempfile_path;
|
||||
|
||||
LockFileTest()
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ namespace mamba
|
|||
EXPECT_EQ(mamba::LockFile::read_pid(lock.fd()), pid);
|
||||
}
|
||||
|
||||
fs::path lock_path = tempfile_path.string() + ".lock";
|
||||
fs::u8path lock_path = tempfile_path.string() + ".lock";
|
||||
EXPECT_FALSE(fs::exists(lock_path));
|
||||
|
||||
args = { lock_cli, "is-locked", lock_path.string() };
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace mamba
|
|||
|
||||
auto tempfile = std::make_unique<TemporaryFile>("pinned", "");
|
||||
const auto path = tempfile->path();
|
||||
std::ofstream out_file(path);
|
||||
std::ofstream out_file(path.std_path());
|
||||
out_file << "numpy=1.13\njupyterlab=3";
|
||||
out_file.close();
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace mamba
|
|||
EXPECT_EQ(pins[0], "numpy=1.13");
|
||||
EXPECT_EQ(pins[1], "jupyterlab=3");
|
||||
|
||||
out_file.open(path, std::ofstream::out | std::ofstream::trunc);
|
||||
out_file.open(path.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << "numpy=1.13\npython=3.7.5";
|
||||
out_file.close();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace mamba
|
|||
#ifndef _WIN32
|
||||
EXPECT_EQ(url, "file:///users/test/miniconda3");
|
||||
#else
|
||||
std::string driveletter = fs::absolute(fs::path("/")).string().substr(0, 1);
|
||||
std::string driveletter = fs::absolute(fs::u8path("/")).string().substr(0, 1);
|
||||
EXPECT_EQ(url, std::string("file://") + driveletter + ":/users/test/miniconda3");
|
||||
auto url2 = path_to_url("D:\\users\\test\\miniconda3");
|
||||
EXPECT_EQ(url2, "file://D:/users/test/miniconda3");
|
||||
|
|
|
@ -69,24 +69,24 @@ namespace mamba
|
|||
EXPECT_TRUE(is_yaml_file_name("../../some/dir/something.yml"));
|
||||
EXPECT_TRUE(is_yaml_file_name("../../some/dir/something.yml"));
|
||||
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "something.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "/some/dir/something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "/some/dir/something.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "../../some/dir/something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::path{ "../../some/dir/something.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "something.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "something-lock.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "something-lock.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "/some/dir/something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "/some/dir/something.yml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "../../some/dir/something.yaml" }.string()));
|
||||
EXPECT_TRUE(is_yaml_file_name(fs::u8path{ "../../some/dir/something.yml" }.string()));
|
||||
|
||||
EXPECT_FALSE(is_yaml_file_name("something"));
|
||||
EXPECT_FALSE(is_yaml_file_name("something-lock"));
|
||||
EXPECT_FALSE(is_yaml_file_name("/some/dir/something"));
|
||||
EXPECT_FALSE(is_yaml_file_name("../../some/dir/something"));
|
||||
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::path{ "something" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::path{ "something-lock" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::path{ "/some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::path{ "../../some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::u8path{ "something" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::u8path{ "something-lock" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::u8path{ "/some/dir/something" }.string()));
|
||||
EXPECT_FALSE(is_yaml_file_name(fs::u8path{ "../../some/dir/something" }.string()));
|
||||
}
|
||||
|
||||
TEST(utils, encode_decode_base64)
|
||||
|
|
|
@ -209,23 +209,23 @@ namespace validate
|
|||
sign_root();
|
||||
}
|
||||
|
||||
fs::path trusted_root_file(const json& j)
|
||||
fs::u8path trusted_root_file(const json& j)
|
||||
{
|
||||
fs::path p = channel_dir->path() / "root.json";
|
||||
fs::u8path p = channel_dir->path() / "root.json";
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << j;
|
||||
out_file.close();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
fs::path trusted_root_file_raw_key()
|
||||
fs::u8path trusted_root_file_raw_key()
|
||||
{
|
||||
return trusted_root_file(root1_json);
|
||||
}
|
||||
|
||||
fs::path trusted_root_file_pgp()
|
||||
fs::u8path trusted_root_file_pgp()
|
||||
{
|
||||
return trusted_root_file(root1_pgp_json);
|
||||
}
|
||||
|
@ -245,10 +245,10 @@ namespace validate
|
|||
return new_root.patch(sig_patch);
|
||||
}
|
||||
|
||||
fs::path create_root_update(const fs::path& name, const json& patch = json())
|
||||
fs::u8path create_root_update(const fs::u8path& name, const json& patch = json())
|
||||
{
|
||||
fs::path p = channel_dir->path() / name;
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
fs::u8path p = channel_dir->path() / name;
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << create_root_update_json(patch);
|
||||
out_file.close();
|
||||
return p;
|
||||
|
@ -282,7 +282,7 @@ namespace validate
|
|||
root1_json["signed"]["expiration"] = timestamp(utc_time_now() + 3600);
|
||||
root1_json["signatures"] = sign_root_meta(root1_json["signed"]);
|
||||
|
||||
std::ifstream i(root1_pgp);
|
||||
std::ifstream i(root1_pgp.std_path());
|
||||
i >> root1_pgp_json;
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ namespace validate
|
|||
}
|
||||
|
||||
protected:
|
||||
fs::path root1_pgp = "validation_data/1.sv0.6.root.json";
|
||||
fs::u8path root1_pgp = "validation_data/1.sv0.6.root.json";
|
||||
json root1_json, root1_pgp_json;
|
||||
|
||||
secrets_type secrets;
|
||||
|
@ -403,9 +403,9 @@ namespace validate
|
|||
|
||||
TEST_F(RootImplT_v06, ctor_wrong_filename_spec_version)
|
||||
{
|
||||
fs::path p = channel_dir->path() / "2.sv1.root.json";
|
||||
fs::u8path p = channel_dir->path() / "2.sv1.root.json";
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << root1_json;
|
||||
out_file.close();
|
||||
|
||||
|
@ -915,12 +915,12 @@ namespace validate
|
|||
return update_key_mgr.patch(sig_patch);
|
||||
}
|
||||
|
||||
fs::path write_key_mgr_file(const json& j,
|
||||
const std::string& filename = "key_mgr.json")
|
||||
fs::u8path write_key_mgr_file(const json& j,
|
||||
const std::string& filename = "key_mgr.json")
|
||||
{
|
||||
fs::path p = channel_dir->path() / filename;
|
||||
fs::u8path p = channel_dir->path() / filename;
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << j;
|
||||
out_file.close();
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ namespace validate
|
|||
EXPECT_EQ(key_mgr.version(), 1);
|
||||
|
||||
|
||||
EXPECT_THROW(root.create_key_mgr(fs::path("not_existing")), role_file_error);
|
||||
EXPECT_THROW(root.create_key_mgr(fs::u8path("not_existing")), role_file_error);
|
||||
|
||||
EXPECT_THROW(root.create_key_mgr(write_key_mgr_file(key_mgr_json, "wrong.json")),
|
||||
role_file_error);
|
||||
|
@ -1169,12 +1169,12 @@ namespace validate
|
|||
return update_pkg_mgr.patch(sig_patch);
|
||||
}
|
||||
|
||||
fs::path write_pkg_mgr_file(const json& j,
|
||||
const std::string& filename = "pkg_mgr.json")
|
||||
fs::u8path write_pkg_mgr_file(const json& j,
|
||||
const std::string& filename = "pkg_mgr.json")
|
||||
{
|
||||
fs::path p = channel_dir->path() / filename;
|
||||
fs::u8path p = channel_dir->path() / filename;
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << j;
|
||||
out_file.close();
|
||||
|
||||
|
@ -1315,11 +1315,12 @@ namespace validate
|
|||
protected:
|
||||
std::string m_ref_path, m_repo_base_url;
|
||||
|
||||
void write_role(const json& j, const fs::path& p)
|
||||
void write_role(const json& j, const fs::u8path& p)
|
||||
{
|
||||
fs::path expanded_p = env::expand_user(p);
|
||||
fs::u8path expanded_p = env::expand_user(p);
|
||||
path::touch(expanded_p, true);
|
||||
std::ofstream out_file(expanded_p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(expanded_p.std_path(),
|
||||
std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << j.dump(2);
|
||||
out_file.close();
|
||||
}
|
||||
|
@ -1416,22 +1417,22 @@ namespace validate
|
|||
sign_root();
|
||||
}
|
||||
|
||||
fs::path trusted_root_file()
|
||||
fs::u8path trusted_root_file()
|
||||
{
|
||||
fs::path p = channel_dir->path() / "root.json";
|
||||
fs::u8path p = channel_dir->path() / "root.json";
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << root1_json;
|
||||
out_file.close();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
fs::path create_root_update(const fs::path& name, const json& patch = json())
|
||||
fs::u8path create_root_update(const fs::u8path& name, const json& patch = json())
|
||||
{
|
||||
fs::path p = channel_dir->path() / name;
|
||||
fs::u8path p = channel_dir->path() / name;
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
json new_root = root1_json;
|
||||
|
||||
|
@ -1462,7 +1463,7 @@ namespace validate
|
|||
|
||||
void sign_root()
|
||||
{
|
||||
std::ifstream i(root1);
|
||||
std::ifstream i(root1.std_path());
|
||||
i >> root1_json;
|
||||
|
||||
std::map<std::string, RoleKeys> all_roles;
|
||||
|
@ -1503,7 +1504,7 @@ namespace validate
|
|||
}
|
||||
|
||||
protected:
|
||||
fs::path root1 = "validation_data/root.json";
|
||||
fs::u8path root1 = "validation_data/root.json";
|
||||
json root1_json;
|
||||
|
||||
std::unique_ptr<TemporaryDirectory> channel_dir;
|
||||
|
@ -1570,9 +1571,9 @@ namespace validate
|
|||
|
||||
TEST_F(RootImplT_v1, ctor_wrong_filename_spec_version)
|
||||
{
|
||||
fs::path p = channel_dir->path() / "2.sv0.6.root.json";
|
||||
fs::u8path p = channel_dir->path() / "2.sv0.6.root.json";
|
||||
|
||||
std::ofstream out_file(p, std::ofstream::out | std::ofstream::trunc);
|
||||
std::ofstream out_file(p.std_path(), std::ofstream::out | std::ofstream::trunc);
|
||||
out_file << root1_json;
|
||||
out_file.close();
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
#endif
|
||||
|
||||
bool
|
||||
is_locked(const fs::path& path)
|
||||
is_locked(const fs::u8path& path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return mamba::LockFile::is_locked(path);
|
||||
#else
|
||||
// From another process than the lockfile one, we can open/close
|
||||
// a new file descriptor without risk to clear locks
|
||||
int fd = open(path.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
int fd = open(path.string().c_str(), O_RDWR | O_CREAT, 0666);
|
||||
bool is_locked = mamba::LockFile::is_locked(fd);
|
||||
close(fd);
|
||||
return is_locked;
|
||||
|
@ -30,7 +30,7 @@ int
|
|||
main(int argc, char** argv)
|
||||
{
|
||||
CLI::App app{};
|
||||
fs::path path;
|
||||
fs::u8path path;
|
||||
int timeout = 1;
|
||||
|
||||
CLI::App* lock_com = app.add_subcommand("lock", "Lock a path");
|
||||
|
|
|
@ -50,15 +50,15 @@ PYBIND11_MODULE(bindings, m)
|
|||
{
|
||||
using namespace mamba;
|
||||
|
||||
py::class_<fs::path>(m, "Path")
|
||||
py::class_<fs::u8path>(m, "Path")
|
||||
.def(py::init<std::string>())
|
||||
.def("__str__", [](fs::path& self) -> std::string { return self.string(); })
|
||||
.def("__str__", [](fs::u8path& self) -> std::string { return self.string(); })
|
||||
.def("__repr__",
|
||||
[](fs::path& self) -> std::string
|
||||
{ return fmt::format("fs::path[{}]", self.string()); });
|
||||
py::implicitly_convertible<std::string, fs::path>();
|
||||
[](fs::u8path& self) -> std::string
|
||||
{ return fmt::format("fs::u8path[{}]", self.string()); });
|
||||
py::implicitly_convertible<std::string, fs::u8path>();
|
||||
|
||||
py::class_<mamba::LockFile>(m, "LockFile").def(py::init<fs::path>());
|
||||
py::class_<mamba::LockFile>(m, "LockFile").def(py::init<fs::u8path>());
|
||||
|
||||
py::register_exception<mamba_error>(m, "MambaNativeException");
|
||||
|
||||
|
@ -73,7 +73,7 @@ PYBIND11_MODULE(bindings, m)
|
|||
.def("id2pkginfo", &MPool::id2pkginfo, py::arg("id"));
|
||||
|
||||
py::class_<MultiPackageCache>(m, "MultiPackageCache")
|
||||
.def(py::init<std::vector<fs::path>>())
|
||||
.def(py::init<std::vector<fs::u8path>>())
|
||||
.def("get_tarball_path", &MultiPackageCache::get_tarball_path)
|
||||
.def_property_readonly("first_writable_path", &MultiPackageCache::first_writable_path);
|
||||
|
||||
|
@ -165,7 +165,7 @@ PYBIND11_MODULE(bindings, m)
|
|||
.def("dep", &MSolverProblem::dep);
|
||||
|
||||
py::class_<History>(m, "History")
|
||||
.def(py::init<const fs::path&>())
|
||||
.def(py::init<const fs::u8path&>())
|
||||
.def("get_requested_specs_map", &History::get_requested_specs_map);
|
||||
|
||||
py::class_<MatchSpec>(m, "MatchSpec")
|
||||
|
@ -341,7 +341,7 @@ PYBIND11_MODULE(bindings, m)
|
|||
|
||||
py::class_<PrefixData>(m, "PrefixData")
|
||||
.def(py::init(
|
||||
[](const fs::path& prefix_path) -> PrefixData
|
||||
[](const fs::u8path& prefix_path) -> PrefixData
|
||||
{
|
||||
auto sres = PrefixData::create(prefix_path);
|
||||
if (sres.has_value())
|
||||
|
|
|
@ -20,7 +20,7 @@ init_rc_options(CLI::App* subcom)
|
|||
auto& rc_files = config.at("rc_files");
|
||||
subcom
|
||||
->add_option(
|
||||
"--rc-file", rc_files.get_cli_config<std::vector<fs::path>>(), rc_files.description())
|
||||
"--rc-file", rc_files.get_cli_config<std::vector<fs::u8path>>(), rc_files.description())
|
||||
->group(cli_group);
|
||||
|
||||
auto& no_rc = config.at("no_rc");
|
||||
|
@ -110,11 +110,11 @@ init_prefix_options(CLI::App* subcom)
|
|||
std::string cli_group = "Prefix options";
|
||||
|
||||
auto& root = config.at("root_prefix");
|
||||
subcom->add_option("-r,--root-prefix", root.get_cli_config<fs::path>(), root.description())
|
||||
subcom->add_option("-r,--root-prefix", root.get_cli_config<fs::u8path>(), root.description())
|
||||
->group(cli_group);
|
||||
|
||||
auto& prefix = config.at("target_prefix");
|
||||
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::path>(), prefix.description())
|
||||
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::u8path>(), prefix.description())
|
||||
->group(cli_group);
|
||||
|
||||
auto& name = config.at("env_name");
|
||||
|
|
|
@ -21,7 +21,7 @@ complete_options(CLI::App* app, const std::vector<std::string>& last_args, bool&
|
|||
config.at("show_banner").set_value(false);
|
||||
config.load();
|
||||
|
||||
auto root_prefix = config.at("root_prefix").value<fs::path>();
|
||||
auto root_prefix = config.at("root_prefix").value<fs::u8path>();
|
||||
auto& name_start = last_args.back();
|
||||
|
||||
if (fs::exists(root_prefix / "envs"))
|
||||
|
|
|
@ -45,14 +45,14 @@ is_valid_rc_sequence(const std::string& key, const std::string& value)
|
|||
}
|
||||
}
|
||||
|
||||
fs::path
|
||||
fs::u8path
|
||||
get_system_path()
|
||||
{
|
||||
return (on_mac || on_linux) ? fs::path("/etc/conda/.condarc")
|
||||
: fs::path("C:\\ProgramData\\conda\\.condarc");
|
||||
return (on_mac || on_linux) ? fs::u8path("/etc/conda/.condarc")
|
||||
: fs::u8path("C:\\ProgramData\\conda\\.condarc");
|
||||
}
|
||||
|
||||
fs::path
|
||||
fs::u8path
|
||||
compute_config_path(bool touch_if_not_exists)
|
||||
{
|
||||
auto& config = Configuration::instance();
|
||||
|
@ -62,15 +62,15 @@ compute_config_path(bool touch_if_not_exists)
|
|||
auto& env_path = config.at("config_set_env_path");
|
||||
auto& system_path = config.at("config_set_system_path");
|
||||
|
||||
fs::path rc_source = env::expand_user(env::home_directory() / ".condarc");
|
||||
fs::u8path rc_source = env::expand_user(env::home_directory() / ".condarc");
|
||||
|
||||
if (file_path.configured())
|
||||
{
|
||||
rc_source = env::expand_user(file_path.value<fs::path>()).string();
|
||||
rc_source = env::expand_user(file_path.value<fs::u8path>()).string();
|
||||
}
|
||||
else if (env_path.configured())
|
||||
{
|
||||
rc_source = fs::path(ctx.target_prefix / ".condarc");
|
||||
rc_source = fs::u8path(ctx.target_prefix / ".condarc");
|
||||
}
|
||||
else if (system_path.configured())
|
||||
{
|
||||
|
@ -193,11 +193,11 @@ set_config_path_command(CLI::App* subcom)
|
|||
= subcom->add_flag("--env", env_path.get_cli_config<bool>(), env_path.description())
|
||||
->excludes(system_flag);
|
||||
|
||||
auto& file_path = config.insert(Configurable("config_set_file_path", fs::path())
|
||||
auto& file_path = config.insert(Configurable("config_set_file_path", fs::u8path())
|
||||
.group("cli")
|
||||
.description("Set configuration on system's rc file"),
|
||||
true);
|
||||
subcom->add_option("--file", file_path.get_cli_config<fs::path>(), file_path.description())
|
||||
subcom->add_option("--file", file_path.get_cli_config<fs::u8path>(), file_path.description())
|
||||
->excludes(system_flag)
|
||||
->excludes(env_flag);
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ set_sequence_to_rc(const SequenceAddType& opt)
|
|||
auto specs = config.at("config_set_sequence_spec")
|
||||
.value<std::vector<std::pair<std::string, std::string>>>();
|
||||
|
||||
fs::path rc_source = compute_config_path(true);
|
||||
fs::u8path rc_source = compute_config_path(true);
|
||||
|
||||
YAML::Node node = YAML::LoadFile(rc_source.string());
|
||||
for (auto& pair : specs)
|
||||
|
@ -337,7 +337,7 @@ set_config_remove_key_command(CLI::App* subcom)
|
|||
| MAMBA_ALLOW_NOT_ENV_PREFIX | MAMBA_NOT_EXPECT_EXISTING_PREFIX);
|
||||
config.load();
|
||||
|
||||
const fs::path rc_source = compute_config_path(false);
|
||||
const fs::u8path rc_source = compute_config_path(false);
|
||||
|
||||
bool key_removed = false;
|
||||
// convert rc file to YAML::Node
|
||||
|
@ -396,7 +396,7 @@ set_config_remove_command(CLI::App* subcom)
|
|||
| MAMBA_ALLOW_NOT_ENV_PREFIX | MAMBA_NOT_EXPECT_EXISTING_PREFIX);
|
||||
config.load();
|
||||
|
||||
const fs::path rc_source = compute_config_path(false);
|
||||
const fs::u8path rc_source = compute_config_path(false);
|
||||
bool key_removed = false;
|
||||
|
||||
const string_list& rvm = remove_vec_map.value<string_list>();
|
||||
|
@ -476,7 +476,7 @@ set_config_set_command(CLI::App* subcom)
|
|||
| MAMBA_ALLOW_NOT_ENV_PREFIX | MAMBA_NOT_EXPECT_EXISTING_PREFIX);
|
||||
config.load();
|
||||
|
||||
const fs::path rc_source = compute_config_path(true);
|
||||
const fs::u8path rc_source = compute_config_path(true);
|
||||
|
||||
YAML::Node rc_YAML = YAML::LoadFile(rc_source.string());
|
||||
|
||||
|
@ -523,7 +523,7 @@ set_config_get_command(CLI::App* subcom)
|
|||
| MAMBA_ALLOW_NOT_ENV_PREFIX | MAMBA_NOT_EXPECT_EXISTING_PREFIX);
|
||||
config.load();
|
||||
|
||||
fs::path rc_source = compute_config_path(false);
|
||||
fs::u8path rc_source = compute_config_path(false);
|
||||
|
||||
bool value_found = false;
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ init_constructor_parser(CLI::App* subcom)
|
|||
{
|
||||
auto& config = Configuration::instance();
|
||||
|
||||
auto& prefix = config.insert(Configurable("constructor_prefix", fs::path(""))
|
||||
auto& prefix = config.insert(Configurable("constructor_prefix", fs::u8path(""))
|
||||
.group("cli")
|
||||
.description("Extract the conda pkgs in <prefix>/pkgs"));
|
||||
|
||||
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::path>(), prefix.description());
|
||||
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::u8path>(), prefix.description());
|
||||
|
||||
auto& extract_conda_pkgs
|
||||
= config.insert(Configurable("constructor_extract_conda_pkgs", false)
|
||||
|
@ -54,7 +54,7 @@ set_constructor_command(CLI::App* subcom)
|
|||
{
|
||||
auto& c = Configuration::instance();
|
||||
|
||||
auto& prefix = c.at("constructor_prefix").compute().value<fs::path>();
|
||||
auto& prefix = c.at("constructor_prefix").compute().value<fs::u8path>();
|
||||
auto& extract_conda_pkgs
|
||||
= c.at("constructor_extract_conda_pkgs").compute().value<bool>();
|
||||
auto& extract_tarball = c.at("constructor_extract_tarball").compute().value<bool>();
|
||||
|
@ -65,7 +65,7 @@ set_constructor_command(CLI::App* subcom)
|
|||
|
||||
|
||||
void
|
||||
construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
||||
construct(const fs::u8path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
||||
{
|
||||
auto& config = Configuration::instance();
|
||||
|
||||
|
@ -99,22 +99,21 @@ construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
|||
LOG_WARNING << "Could not find entry in repodata cache for " << fn;
|
||||
return {};
|
||||
};
|
||||
|
||||
fs::path pkgs_dir = prefix / "pkgs";
|
||||
fs::path urls_file = pkgs_dir / "urls";
|
||||
fs::u8path pkgs_dir = prefix / "pkgs";
|
||||
fs::u8path urls_file = pkgs_dir / "urls";
|
||||
|
||||
auto [package_details, _] = detail::parse_urls_to_package_info(read_lines(urls_file));
|
||||
|
||||
for (const auto& pkg_info : package_details)
|
||||
{
|
||||
fs::path entry = pkgs_dir / pkg_info.fn;
|
||||
fs::u8path entry = pkgs_dir / pkg_info.fn;
|
||||
LOG_TRACE << "Extracting " << pkg_info.fn << std::endl;
|
||||
std::cout << "Extracting " << pkg_info.fn << std::endl;
|
||||
|
||||
fs::path base_path = extract(entry);
|
||||
fs::u8path base_path = extract(entry);
|
||||
|
||||
fs::path repodata_record_path = base_path / "info" / "repodata_record.json";
|
||||
fs::path index_path = base_path / "info" / "index.json";
|
||||
fs::u8path repodata_record_path = base_path / "info" / "repodata_record.json";
|
||||
fs::u8path index_path = base_path / "info" / "index.json";
|
||||
|
||||
std::string channel_url;
|
||||
if (pkg_info.url.size() > pkg_info.fn.size())
|
||||
|
@ -122,7 +121,7 @@ construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
|||
channel_url = pkg_info.url.substr(0, pkg_info.url.size() - pkg_info.fn.size());
|
||||
}
|
||||
std::string repodata_cache_name = concat(cache_name_from_url(channel_url), ".json");
|
||||
fs::path repodata_location = pkgs_dir / "cache" / repodata_cache_name;
|
||||
fs::u8path repodata_location = pkgs_dir / "cache" / repodata_cache_name;
|
||||
|
||||
nlohmann::json repodata_record;
|
||||
if (fs::exists(repodata_location))
|
||||
|
@ -139,7 +138,7 @@ construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
|||
}
|
||||
|
||||
nlohmann::json index;
|
||||
std::ifstream index_file(index_path);
|
||||
std::ifstream index_file{ index_path.std_path() };
|
||||
index_file >> index;
|
||||
|
||||
if (!repodata_record.is_null())
|
||||
|
@ -175,14 +174,14 @@ construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
|||
}
|
||||
|
||||
LOG_TRACE << "Writing " << repodata_record_path;
|
||||
std::ofstream repodata_record_of(repodata_record_path);
|
||||
std::ofstream repodata_record_of{ repodata_record_path.std_path() };
|
||||
repodata_record_of << repodata_record.dump(4);
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_tarball)
|
||||
{
|
||||
fs::path extract_tarball_path = prefix / "_tmp.tar.bz2";
|
||||
fs::u8path extract_tarball_path = prefix / "_tmp.tar.bz2";
|
||||
read_binary_from_stdin_and_write_to_file(extract_tarball_path);
|
||||
extract_archive(extract_tarball_path, prefix);
|
||||
fs::remove(extract_tarball_path);
|
||||
|
@ -191,7 +190,7 @@ construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball)
|
|||
|
||||
|
||||
void
|
||||
read_binary_from_stdin_and_write_to_file(fs::path& filename)
|
||||
read_binary_from_stdin_and_write_to_file(fs::u8path& filename)
|
||||
{
|
||||
std::ofstream out_stream = open_ofstream(filename, std::ofstream::binary);
|
||||
// Need to reopen stdin as binary
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
|
||||
void
|
||||
construct(const fs::path& prefix, bool extract_conda_pkgs, bool extract_tarball);
|
||||
construct(const fs::u8path& prefix, bool extract_conda_pkgs, bool extract_tarball);
|
||||
|
||||
void
|
||||
read_binary_from_stdin_and_write_to_file(fs::path& filename);
|
||||
read_binary_from_stdin_and_write_to_file(fs::u8path& filename);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
using namespace mamba; // NOLINT(build/namespaces)
|
||||
|
||||
std::string
|
||||
get_env_name(const fs::path& px)
|
||||
get_env_name(const fs::u8path& px)
|
||||
{
|
||||
const auto& ctx = Context::instance();
|
||||
auto& ed = ctx.envs_dirs[0];
|
||||
|
@ -143,7 +143,7 @@ set_env_command(CLI::App* com)
|
|||
std::transform(pfxs.begin(),
|
||||
pfxs.end(),
|
||||
envs.begin(),
|
||||
[](const fs::path& path) { return path.string(); });
|
||||
[](const fs::u8path& path) { return path.string(); });
|
||||
res["envs"] = envs;
|
||||
std::cout << res.dump(4) << std::endl;
|
||||
return;
|
||||
|
|
|
@ -62,7 +62,7 @@ set_logout_command(CLI::App* subcom)
|
|||
[]()
|
||||
{
|
||||
static auto path = mamba::env::home_directory() / ".mamba" / "auth";
|
||||
fs::path auth_file = path / "authentication.json";
|
||||
fs::u8path auth_file = path / "authentication.json";
|
||||
|
||||
if (all)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ set_login_command(CLI::App* subcom)
|
|||
|
||||
|
||||
nlohmann::json auth_info;
|
||||
fs::path auth_file = path / "authentication.json";
|
||||
fs::u8path auth_file = path / "authentication.json";
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
const fs::path& proc_dir()
|
||||
const fs::u8path& proc_dir()
|
||||
{
|
||||
static auto path = env::home_directory() / ".mamba" / "proc";
|
||||
return path;
|
||||
|
@ -153,7 +153,7 @@ namespace mamba
|
|||
|
||||
class ScopedProcFile
|
||||
{
|
||||
const fs::path location;
|
||||
const fs::u8path location;
|
||||
|
||||
public:
|
||||
ScopedProcFile(const std::string& name,
|
||||
|
@ -164,7 +164,7 @@ namespace mamba
|
|||
assert(proc_dir_lock); // Lock must be hold for the duraction of this constructor.
|
||||
|
||||
const auto open_mode = std::ios::binary | std::ios::trunc | std::ios::out;
|
||||
std::ofstream pid_file{ location, open_mode };
|
||||
std::ofstream pid_file(location.std_path(), open_mode);
|
||||
if (!pid_file.is_open())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace mamba
|
|||
{
|
||||
bool is_process_name_running(const std::string& name);
|
||||
std::string generate_unique_process_name(std::string_view program_name);
|
||||
const fs::path& proc_dir();
|
||||
const fs::u8path& proc_dir();
|
||||
std::unique_ptr<LockFile> lock_proc_dir();
|
||||
|
||||
nlohmann::json get_all_running_processes_info(
|
||||
|
|
Loading…
Reference in New Issue