Added bool_to_string() and check_size_error().

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5548 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2003-12-03 08:42:47 +00:00
parent 2cc6b97a1d
commit af44f8e659
2 changed files with 26 additions and 0 deletions
@@ -128,4 +128,26 @@ Udf::get_block_shift(uint32 blockSize, uint32 &blockShift)
return B_OK;
}
/*! \brief Returns "true" if \a value is true, "false" otherwise.
*/
const char*
Udf::bool_to_string(bool value)
{
return value ? "true" : "false";
}
/*! \brief Takes an overloaded ssize_t return value like those returned
by BFile::Read() and friends, as well as an expected number of bytes,
and returns B_OK if the byte counts match, or the appropriate error
code otherwise.
*/
status_t
Udf::check_size_error(ssize_t bytesReturned, ssize_t bytesExpected)
{
return bytesReturned == bytesExpected
? B_OK
: (bytesReturned >= 0 ? B_ERROR : status_t(bytesReturned));
}
} // namespace Udf
@@ -32,6 +32,10 @@ time_t make_time(timestamp &timestamp);
status_t get_block_shift(uint32 blockSize, uint32 &blockShift);
const char* bool_to_string(bool value);
status_t check_size_error(ssize_t bytesReturned, ssize_t bytesExpected);
} // namespace Udf
#endif // _UDF_UTILS_H