mirror of https://github.com/ARMmbed/mbed-os.git
Add `is_blocking()` method to FileHandle
There was no way to check current blocking state, so no way to modify and restore status. Also have default FileHandle::set_blocking() used by real files return a correct error code when asked for non-blocking, and success when asked for blocking. These were minor omissions that are required to implement POSIX fcntl properly. fixup! Add `is_blocking()` method to FileHandlepull/6791/head
parent
c8d72c524d
commit
59f49e2b96
|
@ -142,6 +142,15 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Check current blocking or non-blocking mode for file operations.
|
||||
*
|
||||
* @return true for blocking mode, false for non-blocking mode.
|
||||
*/
|
||||
virtual bool is_blocking() const
|
||||
{
|
||||
return _blocking;
|
||||
}
|
||||
|
||||
/** Register a callback on state change of the file.
|
||||
*
|
||||
* The specified callback will be called on state changes such as when
|
||||
|
|
|
@ -192,7 +192,16 @@ public:
|
|||
*/
|
||||
virtual int set_blocking(bool blocking)
|
||||
{
|
||||
return -1;
|
||||
return blocking ? 0 : -ENOTTY;
|
||||
}
|
||||
|
||||
/** Check current blocking or non-blocking mode for file operations.
|
||||
*
|
||||
* @return true for blocking mode, false for non-blocking mode.
|
||||
*/
|
||||
virtual bool is_blocking() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check for poll event flags
|
||||
|
|
Loading…
Reference in New Issue