-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
fix: from FIXME(#24570) added more info #148156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
68ab2c1
98a7209
33fbf38
5a42b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1022,12 +1022,25 @@ impl FromRawHandle for File { | |
|
|
||
| impl fmt::Debug for File { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| // FIXME(#24570): add more info here (e.g., mode) | ||
| let mut b = f.debug_struct("File"); | ||
| b.field("handle", &self.handle.as_raw_handle()); | ||
| if let Ok(path) = get_path(self) { | ||
| b.field("path", &path); | ||
| } | ||
|
|
||
| if let Ok(file_attr) = self.file_attr() { | ||
| b.field("read", &true); | ||
| if file_attr.perm().readonly() { | ||
| b.field("write", &false); | ||
| } else { | ||
| b.field("write", &true); | ||
| } | ||
|
|
||
| // Getting analogue of file mode (unix) using file attributes | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File attributes aren't really an analogue of file mode because they don't have much to do with permissions. That would be ACLs. In any case, what we care most about is how the opened file handle can be used, rather than what the on-disk file has set. E.g. can I
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In windows files readable as default, if attrs set to the readonly of course you cannot write to them and use file handler for writing, i don't get the point about examples part, for debugging this infromation useful, than just check you opened the file in write or read mode i think so
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the |
||
| // See https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants | ||
| b.field("attrs", &file_attr.attributes); | ||
| } | ||
|
|
||
| b.finish() | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.