mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 03:23:04 +01:00
Simplification
This commit is contained in:
parent
9921988470
commit
f6321fa2e5
@ -91,21 +91,24 @@ namespace os_utils
|
|||||||
void getUniqueFileId(const char* name, Firebird::UCharBuffer& id);
|
void getUniqueFileId(const char* name, Firebird::UCharBuffer& id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline SINT64 lseek(int fd, SINT64 offset, int origin)
|
||||||
inline off_t lseek(int fd, off_t offset, int whence)
|
|
||||||
{
|
{
|
||||||
|
#ifdef WIN_NT
|
||||||
|
return _lseeki64(fd, offset, origin);
|
||||||
|
#else
|
||||||
off_t rc;
|
off_t rc;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef LSB_BUILD
|
#ifdef LSB_BUILD
|
||||||
rc = lseek64(fd, offset, whence);
|
rc = lseek64(fd, offset, origin);
|
||||||
#else
|
#else
|
||||||
rc = ::lseek(fd, offset, whence);
|
rc = ::lseek(fd, offset, origin);
|
||||||
#endif
|
#endif
|
||||||
} while (rc == (off_t) -1 && SYSCALL_INTERRUPTED(errno));
|
} while (rc == (off_t) -1 && SYSCALL_INTERRUPTED(errno));
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int stat(const char* path, struct STAT* buf)
|
inline int stat(const char* path, struct STAT* buf)
|
||||||
@ -346,6 +349,7 @@ namespace os_utils
|
|||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WIN_NT
|
#endif // WIN_NT
|
||||||
|
|
||||||
class CtrlCHandler
|
class CtrlCHandler
|
||||||
@ -371,6 +375,7 @@ namespace os_utils
|
|||||||
bool procTerm;
|
bool procTerm;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace os_utils
|
} // namespace os_utils
|
||||||
|
|
||||||
#endif // INCLUDE_OS_FILE_UTILS_H
|
#endif // INCLUDE_OS_FILE_UTILS_H
|
||||||
|
@ -168,11 +168,7 @@ bool ChangeLog::Segment::validate(const Guid& guid) const
|
|||||||
|
|
||||||
void ChangeLog::Segment::copyTo(const PathName& filename) 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)
|
if (os_utils::lseek(m_handle, 0, SEEK_SET) != 0)
|
||||||
#endif
|
|
||||||
raiseIOError("seek", m_filename.c_str());
|
raiseIOError("seek", m_filename.c_str());
|
||||||
|
|
||||||
const auto totalLength = m_header->hdr_length;
|
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(m_header->hdr_state == SEGMENT_STATE_USED);
|
||||||
fb_assert(length);
|
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)
|
if (os_utils::lseek(m_handle, currentLength, SEEK_SET) != currentLength)
|
||||||
#endif
|
|
||||||
raiseError("Log file %s seek failed (error %d)", m_filename.c_str(), ERRNO);
|
raiseError("Log file %s seek failed (error %d)", m_filename.c_str(), ERRNO);
|
||||||
|
|
||||||
if (::write(m_handle, data, length) != length)
|
if (::write(m_handle, data, length) != length)
|
||||||
|
@ -79,11 +79,7 @@ PluginLogWriter::~PluginLogWriter()
|
|||||||
|
|
||||||
SINT64 PluginLogWriter::seekToEnd()
|
SINT64 PluginLogWriter::seekToEnd()
|
||||||
{
|
{
|
||||||
#ifdef WIN_NT
|
const SINT64 nFileLen = os_utils::lseek(m_fileHandle, 0, SEEK_END);
|
||||||
SINT64 nFileLen = _lseeki64(m_fileHandle, 0, SEEK_END);
|
|
||||||
#else
|
|
||||||
off_t nFileLen = os_utils::lseek(m_fileHandle, 0, SEEK_END);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (nFileLen < 0)
|
if (nFileLen < 0)
|
||||||
checkErrno("lseek");
|
checkErrno("lseek");
|
||||||
|
Loading…
Reference in New Issue
Block a user