From 79e7015a32bdfe3ef8217e020a7bbac66bd60e82 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Wed, 17 Apr 2024 03:39:14 +0900 Subject: [PATCH] CreateJunction --- Cargo.lock | 1 + Cargo.toml | 1 + stdlib/Cargo.toml | 1 + vm/Cargo.toml | 2 +- vm/src/stdlib/winapi.rs | 12 ++++++++++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ab03881fc..60a1d67ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2242,6 +2242,7 @@ dependencies = [ "gethostname", "hex", "itertools 0.11.0", + "junction", "libc", "libsqlite3-sys", "libz-sys", diff --git a/Cargo.toml b/Cargo.toml index 2255a827f..e58a3da91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ indexmap = { version = "2.2.6", features = ["std"] } insta = "1.38.0" itertools = "0.11.0" is-macro = "0.3.0" +junction = "1.0.0" libc = "0.2.153" log = "0.4.16" nix = { version = "0.27", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] } diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml index 4e77b9f72..ad36d109e 100644 --- a/stdlib/Cargo.toml +++ b/stdlib/Cargo.toml @@ -105,6 +105,7 @@ foreign-types-shared = { version = "0.1.1", optional = true } libsqlite3-sys = { version = "0.25", features = ["min_sqlite_version_3_7_16", "bundled"] } [target.'cfg(windows)'.dependencies] +junction = { workspace = true } paste = { workspace = true } schannel = { workspace = true } widestring = { workspace = true } diff --git a/vm/Cargo.toml b/vm/Cargo.toml index dc248a166..fee7dcbb9 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -107,7 +107,7 @@ widestring = { workspace = true } winreg = "0.10.1" [target.'cfg(windows)'.dependencies.junction] -version = "1.0.0" +workspace = true [target.'cfg(windows)'.dependencies.windows] version = "0.52.0" diff --git a/vm/src/stdlib/winapi.rs b/vm/src/stdlib/winapi.rs index 8fce91be4..429ce479d 100644 --- a/vm/src/stdlib/winapi.rs +++ b/vm/src/stdlib/winapi.rs @@ -257,6 +257,18 @@ mod _winapi { return_value != 0 } + #[pyfunction] + fn CreateJunction( + src_path: PyStrRef, + dest_path: PyStrRef, + vm: &VirtualMachine, + ) -> PyResult<()> { + let src_path = std::path::Path::new(src_path.as_str()); + let dest_path = std::path::Path::new(dest_path.as_str()); + + junction::create(dest_path, src_path).map_err(|e| e.to_pyexception(vm)) + } + fn getenvironment(env: ArgMapping, vm: &VirtualMachine) -> PyResult> { let keys = env.mapping().keys(vm)?; let values = env.mapping().values(vm)?;