kcfile.h | kcfile.h | |||
---|---|---|---|---|
skipping to change at line 157 | skipping to change at line 157 | |||
*/ | */ | |||
bool read(int64_t off, void* buf, size_t size); | bool read(int64_t off, void* buf, size_t size); | |||
/** | /** | |||
* Read data. | * Read data. | |||
* @note Equal to the original File::read method except that the sigunatu re is different. | * @note Equal to the original File::read method except that the sigunatu re is different. | |||
*/ | */ | |||
bool read(int64_t off, std::string* buf, size_t size) { | bool read(int64_t off, std::string* buf, size_t size) { | |||
_assert_(off >= 0 && buf); | _assert_(off >= 0 && buf); | |||
char* tbuf = new char[size]; | char* tbuf = new char[size]; | |||
if (!read(off, tbuf, size)) { | if (!read(off, tbuf, size)) { | |||
delete tbuf; | delete[] tbuf; | |||
return false; | return false; | |||
} | } | |||
buf->append(std::string(tbuf, size)); | buf->append(std::string(tbuf, size)); | |||
delete tbuf; | delete[] tbuf; | |||
return true; | return true; | |||
} | } | |||
/** | /** | |||
* Read data with assuring the region does not spill from the file size. | * Read data with assuring the region does not spill from the file size. | |||
* @param off the offset of the source. | * @param off the offset of the source. | |||
* @param buf the pointer to the destination region. | * @param buf the pointer to the destination region. | |||
* @param size the size of the data to be read. | * @param size the size of the data to be read. | |||
* @return true on success, or false on failure. | * @return true on success, or false on failure. | |||
*/ | */ | |||
bool read_fast(int64_t off, void* buf, size_t size); | bool read_fast(int64_t off, void* buf, size_t size); | |||
/** | /** | |||
* Read data. | * Read data. | |||
* @note Equal to the original File::read method except that the sigunatu re is different. | * @note Equal to the original File::read method except that the sigunatu re is different. | |||
*/ | */ | |||
bool read_fast(int64_t off, std::string* buf, size_t size) { | bool read_fast(int64_t off, std::string* buf, size_t size) { | |||
_assert_(off >= 0 && buf); | _assert_(off >= 0 && buf); | |||
char* tbuf = new char[size]; | char* tbuf = new char[size]; | |||
if (!read_fast(off, tbuf, size)) { | if (!read_fast(off, tbuf, size)) { | |||
delete tbuf; | delete[] tbuf; | |||
return false; | return false; | |||
} | } | |||
buf->append(std::string(tbuf, size)); | buf->append(std::string(tbuf, size)); | |||
delete tbuf; | delete[] tbuf; | |||
return true; | return true; | |||
} | } | |||
/** | /** | |||
* Truncate the file. | * Truncate the file. | |||
* @param size the new size of the file. | * @param size the new size of the file. | |||
* @return true on success, or false on failure. | * @return true on success, or false on failure. | |||
*/ | */ | |||
bool truncate(int64_t size); | bool truncate(int64_t size); | |||
/** | /** | |||
* Synchronize updated contents with the file and the device. | * Synchronize updated contents with the file and the device. | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added | |||