8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 00:03:02 +01:00

Simplification

This commit is contained in:
Dmitry Yemanov 2020-04-17 20:57:28 +03:00
parent 9921988470
commit f6321fa2e5
3 changed files with 11 additions and 18 deletions

View File

@ -91,21 +91,24 @@ namespace os_utils
void getUniqueFileId(const char* name, Firebird::UCharBuffer& id);
#endif
inline off_t lseek(int fd, off_t offset, int whence)
inline SINT64 lseek(int fd, SINT64 offset, int origin)
{
#ifdef WIN_NT
return _lseeki64(fd, offset, origin);
#else
off_t rc;
do
{
#ifdef LSB_BUILD
rc = lseek64(fd, offset, whence);
rc = lseek64(fd, offset, origin);
#else
rc = ::lseek(fd, offset, whence);
rc = ::lseek(fd, offset, origin);
#endif
} while (rc == (off_t) -1 && SYSCALL_INTERRUPTED(errno));
return rc;
#endif
}
inline int stat(const char* path, struct STAT* buf)
@ -346,6 +349,7 @@ namespace os_utils
return rc;
}
#endif // WIN_NT
class CtrlCHandler
@ -371,6 +375,7 @@ namespace os_utils
bool procTerm;
#endif
};
} // namespace os_utils
#endif // INCLUDE_OS_FILE_UTILS_H

View File

@ -168,11 +168,7 @@ bool ChangeLog::Segment::validate(const Guid& guid) const
void ChangeLog::Segment::copyTo(const PathName& filename) const
{
#ifdef WIN_NT
if (_lseeki64(m_handle, 0, SEEK_SET) != 0)
#else
if (os_utils::lseek(m_handle, 0, SEEK_SET) != 0)
#endif
raiseIOError("seek", m_filename.c_str());
const auto totalLength = m_header->hdr_length;
@ -213,13 +209,9 @@ void ChangeLog::Segment::append(ULONG length, const UCHAR* data)
fb_assert(m_header->hdr_state == SEGMENT_STATE_USED);
fb_assert(length);
const auto currentLength = m_header->hdr_length;
const auto currentLength = (SINT64) m_header->hdr_length;
#ifdef WIN_NT
if (_lseeki64(m_handle, currentLength, SEEK_SET) != currentLength)
#else
if (os_utils::lseek(m_handle, currentLength, SEEK_SET) != currentLength)
#endif
raiseError("Log file %s seek failed (error %d)", m_filename.c_str(), ERRNO);
if (::write(m_handle, data, length) != length)

View File

@ -79,11 +79,7 @@ PluginLogWriter::~PluginLogWriter()
SINT64 PluginLogWriter::seekToEnd()
{
#ifdef WIN_NT
SINT64 nFileLen = _lseeki64(m_fileHandle, 0, SEEK_END);
#else
off_t nFileLen = os_utils::lseek(m_fileHandle, 0, SEEK_END);
#endif
const SINT64 nFileLen = os_utils::lseek(m_fileHandle, 0, SEEK_END);
if (nFileLen < 0)
checkErrno("lseek");