Skip to content

Conversation

peace-maker
Copy link
Member

The _flags and _flags2 bitmasks are decoded to a readable string when printing the struct. Next to setting the flags as an integer like before, you can set individual bits now and check set bits.

fileStr = FileStructure(null=0xdeadbeeef)
fileStr.flags = 0xfbad1807
# or
fileStr.flags = IO_flags._IO_MAGIC | IO_flags._IO_USER_BUF | IO_flags._IO_UNBUFFERED
# or
fileStr.flags._IO_USER_BUF = 1

Printing the FileStructure shows the flags in human readable form too

{ flags: 0xfbad0401 (_IO_USER_BUF | _IO_UNBUFFERED | _IO_MAGIC)
_IO_read_ptr: 0x0
...

The unknown2 field is split up into the correct field names to modify easily too.

The `_flags` and `_flags2` bitmasks are decoded to a readable string when printing the struct.
Next to setting the flags as an integer like before, you can set individual bits now and check set bits.

```
fileStr = FileStructure(null=0xdeadbeeef)
fileStr.flags = 0xfbad1807
fileStr.flags = IO_flags._IO_MAGIC | IO_flags._IO_USER_BUF | IO_flags._IO_UNBUFFERED
fileStr.flags._IO_USER_BUF = 1
```

Printing the FileStructure shows the flags in human readable form too

```
{ flags: 0xfbad0401 (_IO_USER_BUF | _IO_UNBUFFERED | _IO_MAGIC)
_IO_read_ptr: 0x0
...
```
@RocketMaDev
Copy link
Contributor

Should these flags be put under constants?

@peace-maker
Copy link
Member Author

Probably, but the constants are generated and these ones are targeted towards the FileStructure class. I don't have a preference where they should live. We can move them later and leave an alias in the old place if it's confusing.

@peace-maker peace-maker changed the title Decode _IO_* flags in FileStructure member Decode and pretty print _IO_* flags in FileStructure member Aug 5, 2025
@peace-maker peace-maker merged commit 00f707d into Gallopsled:dev Aug 6, 2025
15 checks passed
@peace-maker peace-maker deleted the file_flags branch August 6, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants