Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit264e598

Browse files
committed
fix bugs
1 parentc52ad2f commit264e598

File tree

1 file changed

+3
-72
lines changed

1 file changed

+3
-72
lines changed

‎vm/src/stdlib/nt.rs

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,8 @@ pub(crate) mod module {
448448
#[pyfunction]
449449
fnlistvolumes(vm:&VirtualMachine) ->PyResult<PyListRef>{
450450
letmut volumes =vec![];
451-
let find;
452451
letmut buffer =[0u16;257];
453-
find =unsafe{
454-
FileSystem::FindFirstVolumeW(
455-
buffer.as_mut_ptr(),
456-
buffer.len()as_,
457-
)
458-
};
452+
let find =unsafe{FileSystem::FindFirstVolumeW(buffer.as_mut_ptr(), buffer.len()as_)};
459453
if find == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE{
460454
returnErr(errno_err(vm));
461455
}
@@ -468,11 +462,7 @@ pub(crate) mod module {
468462
}
469463
volumes.push(s.to_string());
470464
let ret =unsafe{
471-
FileSystem::FindNextVolumeW(
472-
find,
473-
buffer.as_mut_ptr(),
474-
buffer.len()as_,
475-
)
465+
FileSystem::FindNextVolumeW(find, buffer.as_mut_ptr(), buffer.len()as_)
476466
};
477467
if ret ==0{
478468
err = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
@@ -484,69 +474,10 @@ pub(crate) mod module {
484474
if err !=0 && err != windows_sys::Win32::Foundation::ERROR_NO_MORE_FILESasi32{
485475
returnErr(std::io::Error::from_raw_os_error(err).to_pyexception(vm));
486476
}
487-
let volumes:Vec<_> = volumes
488-
.into_iter()
489-
.map(|v| vm.new_pyobj(v))
490-
.collect();
477+
let volumes:Vec<_> = volumes.into_iter().map(|v| vm.new_pyobj(v)).collect();
491478
Ok(vm.ctx.new_list(volumes))
492479
}
493480

494-
// TOOD: these functions are not fully compataible with CPython
495-
// they exist for some compatibility
496-
#[pyfunction]
497-
fn_path_exists(path:OsPath,vm:&VirtualMachine) ->PyResult<bool>{
498-
let path = path.as_ref();
499-
if path.exists(){
500-
returnOk(true);
501-
}
502-
if path.is_dir(){
503-
returnOk(false);
504-
}
505-
let metadata = fs::metadata(path).map_err(|err| err.to_pyexception(vm))?;
506-
Ok(metadata.is_file())
507-
}
508-
509-
#[pyfunction]
510-
fn_path_isdir(path:OsPath,vm:&VirtualMachine) ->PyResult<bool>{
511-
let path = path.as_ref();
512-
if path.is_dir(){
513-
returnOk(true);
514-
}
515-
if path.exists(){
516-
returnOk(false);
517-
}
518-
let metadata = fs::metadata(path).map_err(|err| err.to_pyexception(vm))?;
519-
Ok(metadata.is_dir())
520-
}
521-
522-
#[pyfunction]
523-
fn_path_isfile(path:OsPath,vm:&VirtualMachine) ->PyResult<bool>{
524-
let path = path.as_ref();
525-
if path.is_file(){
526-
returnOk(true);
527-
}
528-
if path.exists(){
529-
returnOk(false);
530-
}
531-
let metadata = fs::metadata(path).map_err(|err| err.to_pyexception(vm))?;
532-
Ok(metadata.is_file())
533-
}
534-
535-
#[pyfunction]
536-
fn_path_islink(path:OsPath,vm:&VirtualMachine) ->PyResult<bool>{
537-
let path = path.as_ref();
538-
if path.is_symlink(){
539-
returnOk(true);
540-
}
541-
if path.exists(){
542-
returnOk(false);
543-
}
544-
let metadata = fs::symlink_metadata(path).map_err(|err| err.to_pyexception(vm))?;
545-
Ok(metadata.file_type().is_symlink())
546-
}
547-
548-
// End of functions that are not fully compatible with CPython
549-
550481
#[pyfunction]
551482
fnset_handle_inheritable(
552483
handle:intptr_t,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp