MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_dir

Function check_dir

crates/vm/src/stdlib/nt.rs:160–185  ·  view source on GitHub ↗
(src: &OsPath, dst: &OsPath)

Source from the content-addressed store, hash-verified

158 static HAS_UNPRIVILEGED_FLAG: AtomicBool = AtomicBool::new(true);
159
160 fn check_dir(src: &OsPath, dst: &OsPath) -> bool {
161 use windows_sys::Win32::Storage::FileSystem::GetFileExInfoStandard;
162
163 let dst_parent = dst.as_path().parent();
164 let Some(dst_parent) = dst_parent else {
165 return false;
166 };
167 let resolved = if src.as_path().is_absolute() {
168 src.as_path().to_path_buf()
169 } else {
170 dst_parent.join(src.as_path())
171 };
172 let wide = match widestring::WideCString::from_os_str(&resolved) {
173 Ok(wide) => wide,
174 Err(_) => return false,
175 };
176 let mut info: WIN32_FILE_ATTRIBUTE_DATA = unsafe { core::mem::zeroed() };
177 let ok = unsafe {
178 GetFileAttributesExW(
179 wide.as_ptr(),
180 GetFileExInfoStandard,
181 &mut info as *mut _ as *mut _,
182 )
183 };
184 ok != 0 && (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0
185 }
186
187 let mut flags = 0u32;
188 if HAS_UNPRIVILEGED_FLAG.load(Ordering::Relaxed) {

Callers 1

symlinkFunction · 0.85

Calls 6

as_pathMethod · 0.80
is_absoluteMethod · 0.80
to_path_bufMethod · 0.80
parentMethod · 0.45
joinMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected