File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2291,6 +2291,27 @@ mod nt {
2291
2291
get_stats ( ) . map_err ( |e| convert_io_error ( vm, e) )
2292
2292
}
2293
2293
2294
+ #[ pyfunction]
2295
+ fn chmod (
2296
+ path : PyPathLike ,
2297
+ dir_fd : DirFd ,
2298
+ mode : u32 ,
2299
+ follow_symlinks : FollowSymlinks ,
2300
+ vm : & VirtualMachine ,
2301
+ ) -> PyResult < ( ) > {
2302
+ const S_IWRITE : u32 = 128 ;
2303
+ let path = make_path ( vm, & path, & dir_fd) ;
2304
+ let metadata = if follow_symlinks. follow_symlinks {
2305
+ fs:: metadata ( path)
2306
+ } else {
2307
+ fs:: symlink_metadata ( path)
2308
+ } ;
2309
+ let meta = metadata. map_err ( |err| convert_io_error ( vm, err) ) ?;
2310
+ let mut permissions = meta. permissions ( ) ;
2311
+ permissions. set_readonly ( mode & S_IWRITE != 0 ) ;
2312
+ fs:: set_permissions ( path, permissions) . map_err ( |err| convert_io_error ( vm, err) )
2313
+ }
2314
+
2294
2315
// cwait is available on MSVC only (according to CPython)
2295
2316
#[ cfg( target_env = "msvc" ) ]
2296
2317
extern "C" {
You can’t perform that action at this time.
0 commit comments