Revert "os2: Don't try to translate Windows file attributes to Unix mode flags"

This reverts commit 95923c2059.
It'll be updated later.
This commit is contained in:
Jeroen van Rijn
2025-05-12 23:34:12 +02:00
parent 4d7876bdb0
commit d7a83a7a1f
2 changed files with 20 additions and 36 deletions
+6 -9
View File
@@ -212,15 +212,11 @@ _file_type_from_create_file :: proc(wname: win32.wstring, create_file_attributes
}
_file_type_mode_from_file_attributes :: proc(file_attributes: win32.DWORD, h: win32.HANDLE, ReparseTag: win32.DWORD) -> (type: File_Type, mode: int) {
// NOTE(Jeroen): We don't translate mode flags for Linux when given to `chmod`.
// Let's not do so for Windows for `chmod` or `read_directory_iterator` either.
// They're *not* portable between Windows and non-Windows platforms.
//
// It also leads to information loss as flags like Archive, Hidden and System have no equivalent there.
// We can of course parse them so we can set the `.Symlink` and `.Directory` type, but we shouldn't pretend
// that 0o644 is meaningful when returned as a mode.
// `C:\bootmgr` as an example has attributes read only, hidden, system, archive. In no way is it sensible to replace that with 0o444.
mode = int(file_attributes)
if file_attributes & win32.FILE_ATTRIBUTE_READONLY != 0 {
mode |= 0o444
} else {
mode |= 0o666
}
is_sym := false
if file_attributes & win32.FILE_ATTRIBUTE_REPARSE_POINT == 0 {
@@ -233,6 +229,7 @@ _file_type_mode_from_file_attributes :: proc(file_attributes: win32.DWORD, h: wi
type = .Symlink
} else if file_attributes & win32.FILE_ATTRIBUTE_DIRECTORY != 0 {
type = .Directory
mode |= 0o111
} else if h != nil {
type = file_type(h)
}