IsWritable / IsReadable methods do not currently check Write/Read mode bits.
|Reported by:||ver||Owned by:||axeld|
|Keywords:||IsWritable IsReadable BFile||Cc:||ver@…|
In BeBook, it says IsReadable and IsWritable methods on BFile: "Note that these functions don't query the actual file to check permissions, they only tell you what the access request was when the BFile object was initialized." which makes me ask.. "Why not?"
The developer is aware of the flag they used when they instantiate a BFile, so these methods seem redundant.
An application (Pe, for example,) must fstat the file (GetStat()), and then sift through mode flags to decipher if the read or write bits are set, which is several lines of code which would likely require a lot of reimplementing.
This patch implements mode checking in IsWritable and IsReadable.
Please note that the file is statted once for each time either of these methods are called. This is done because the mode of the file may change AFTER opening. (Eg, a read-only flagged text file is opened in StyledEdit, the user attempts to save, a warning dialogue appears to inform the user of the read-only setting of the file. The user cancels, updates the mode of the file, and selects Save again. If the stat is done only when the file is initially opened, the mode continue to indicate a read-only status.)
Change History (12)
by , 11 years ago