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

Function attributes_to_mode

crates/vm/src/windows.rs:118–134  ·  view source on GitHub ↗

Ported from attributes_to_mode (fileutils.c)

(attr: u32)

Source from the content-addressed store, hash-verified

116
117/// Ported from attributes_to_mode (fileutils.c)
118fn attributes_to_mode(attr: u32) -> u16 {
119 use windows_sys::Win32::Storage::FileSystem::{
120 FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_READONLY,
121 };
122 let mut m: u16 = 0;
123 if attr & FILE_ATTRIBUTE_DIRECTORY != 0 {
124 m |= S_IFDIR | 0o111; // IFEXEC for user,group,other
125 } else {
126 m |= S_IFREG;
127 }
128 if attr & FILE_ATTRIBUTE_READONLY != 0 {
129 m |= 0o444;
130 } else {
131 m |= 0o666;
132 }
133 m
134}
135
136/// Ported from _Py_attribute_data_to_stat (fileutils.c)
137/// Converts BY_HANDLE_FILE_INFORMATION to StatStruct

Callers 1

attribute_data_to_statFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected