1
0

refactor: move env outside from rust namespace

This commit is contained in:
2025-10-07 18:03:40 +08:00
parent 64045b1d48
commit eda801d3c7
6 changed files with 21 additions and 21 deletions

View File

@ -16,7 +16,7 @@ PRIVATE
yycc/patch/fopen.cpp yycc/patch/fopen.cpp
yycc/patch/stream.cpp yycc/patch/stream.cpp
yycc/rust/panic.cpp yycc/rust/panic.cpp
yycc/rust/env.cpp yycc/env.cpp
yycc/windows/com.cpp yycc/windows/com.cpp
yycc/windows/dialog.cpp yycc/windows/dialog.cpp
yycc/windows/winfct.cpp yycc/windows/winfct.cpp
@ -69,7 +69,7 @@ FILES
yycc/rust/panic.hpp yycc/rust/panic.hpp
yycc/rust/option.hpp yycc/rust/option.hpp
yycc/rust/result.hpp yycc/rust/result.hpp
yycc/rust/env.hpp yycc/env.hpp
yycc/windows/import_guard_head.hpp yycc/windows/import_guard_head.hpp
yycc/windows/import_guard_tail.hpp yycc/windows/import_guard_tail.hpp
yycc/windows/com.hpp yycc/windows/com.hpp

View File

@ -3,7 +3,7 @@
#include "../../patch/stream.hpp" #include "../../patch/stream.hpp"
#include "../../patch/format.hpp" #include "../../patch/format.hpp"
#include "../../string/op.hpp" #include "../../string/op.hpp"
#include "../../rust/env.hpp" #include "../../env.hpp"
#include <ranges> #include <ranges>
#define CLAP ::yycc::carton::clap #define CLAP ::yycc::carton::clap
@ -11,7 +11,7 @@
#define TERMCOLOR ::yycc::carton::termcolor #define TERMCOLOR ::yycc::carton::termcolor
#define OP ::yycc::string::op #define OP ::yycc::string::op
#define FORMAT ::yycc::patch::format #define FORMAT ::yycc::patch::format
#define ENV ::yycc::rust::env #define ENV ::yycc::env
using namespace ::yycc::patch::stream; using namespace ::yycc::patch::stream;

View File

@ -1,15 +1,15 @@
#include "env.hpp" #include "env.hpp"
#include "../macro/os_detector.hpp" #include "macro/os_detector.hpp"
// Environment variable required // Environment variable required
#if defined(YYCC_OS_WINDOWS) #if defined(YYCC_OS_WINDOWS)
#include "../encoding/windows.hpp" #include "encoding/windows.hpp"
#include "../num/safe_op.hpp" #include "num/safe_op.hpp"
#include "../num/safe_cast.hpp" #include "num/safe_cast.hpp"
#include <Windows.h> #include <Windows.h>
#include <winbase.h> #include <winbase.h>
#else #else
#include "../string/reinterpret.hpp" #include "string/reinterpret.hpp"
#include <cstdlib> #include <cstdlib>
#include <cerrno> #include <cerrno>
#include <stdexcept> #include <stdexcept>
@ -17,7 +17,7 @@
// Path related functions required // Path related functions required
#if defined(YYCC_OS_WINDOWS) #if defined(YYCC_OS_WINDOWS)
#include "../windows/winfct.hpp" #include "windows/winfct.hpp"
#else #else
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -29,7 +29,7 @@
#define REINTERPRET ::yycc::string::reinterpret #define REINTERPRET ::yycc::string::reinterpret
#define WINFCT ::yycc::windows::winfct #define WINFCT ::yycc::windows::winfct
namespace yycc::rust::env { namespace yycc::env {
#pragma region Environment Variable #pragma region Environment Variable
@ -207,4 +207,4 @@ namespace yycc::rust::env {
#pragma endregion #pragma endregion
} // namespace yycc::rust::env } // namespace yycc::env

View File

@ -14,7 +14,7 @@
* I create this namespace inspired from Rust standard library * I create this namespace inspired from Rust standard library
* to glue all these things up and make a uniform interface. * to glue all these things up and make a uniform interface.
*/ */
namespace yycc::rust::env { namespace yycc::env {
#pragma region Environment Variable #pragma region Environment Variable
@ -86,4 +86,4 @@ namespace yycc::rust::env {
#pragma endregion #pragma endregion
} // namespace yycc::rust::env } // namespace yycc::env

View File

@ -20,7 +20,7 @@ PRIVATE
yycc/patch/fopen.cpp yycc/patch/fopen.cpp
yycc/patch/stream.cpp yycc/patch/stream.cpp
yycc/patch/format.cpp yycc/patch/format.cpp
yycc/rust/env.cpp yycc/env.cpp
yycc/string/reinterpret.cpp yycc/string/reinterpret.cpp
yycc/string/op.cpp yycc/string/op.cpp
yycc/num/parse.cpp yycc/num/parse.cpp

View File

@ -1,17 +1,17 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yycc.hpp> #include <yycc.hpp>
#include <yycc/rust/env.hpp> #include <yycc/env.hpp>
#include <yycc/macro/os_detector.hpp> #include <yycc/macro/os_detector.hpp>
#include <filesystem> #include <filesystem>
#define ENV ::yycc::rust::env #define ENV ::yycc::env
namespace yycctest::rust::env { namespace yycctest::env {
constexpr char8_t VAR_NAME[] = u8"HOMER"; constexpr char8_t VAR_NAME[] = u8"HOMER";
constexpr char8_t VAR_VALUE[] = u8"doh"; constexpr char8_t VAR_VALUE[] = u8"doh";
TEST(RustEnv, EnvVar) { TEST(Env, EnvVar) {
// Write a new variable should okey // Write a new variable should okey
{ {
auto rv = ENV::set_var(VAR_NAME, VAR_VALUE); auto rv = ENV::set_var(VAR_NAME, VAR_VALUE);
@ -44,7 +44,7 @@ namespace yycctest::rust::env {
} }
} }
TEST(RustEnv, CurrentExe) { TEST(Env, CurrentExe) {
auto rv = ENV::current_exe(); auto rv = ENV::current_exe();
ASSERT_TRUE(rv.has_value()); ASSERT_TRUE(rv.has_value());
@ -59,4 +59,4 @@ namespace yycctest::rust::env {
#endif #endif
} }
} // namespace yycctest::rust::env } // namespace yycctest::env