20000408-11:05 GMT+2 Maurilio Longo <maurilio.longo@libero.it>

This commit is contained in:
Maurilio Longo
2000-04-08 09:07:37 +00:00
parent b4f6d1a8d6
commit 7972eefee6
2 changed files with 58 additions and 3 deletions

View File

@@ -1,3 +1,9 @@
20000408-11:05 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
* source/rtl/filesys.c
+ Added file locking to OS/2 (both GCC and icc)
! fixed file committing under OS/2 (no need to duplicate a file handle)
20000407-15:25 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
* source/rtl/diskspac.c

View File

@@ -75,7 +75,7 @@
#include <fcntl.h>
#include <errno.h>
#if !defined(OS_UNIX_COMPATIBLE)
#if !defined(OS_UNIX_COMPATIBLE)
#include <io.h>
#endif
#if defined(__DJGPP__)
@@ -833,7 +833,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
HB_TRACE(HB_TR_DEBUG, ("hb_fsLock(%p, %lu, %lu, %hu)", hFileHandle, ulStart, ulLength, uiMode));
#if defined(HAVE_POSIX_IO) && !defined(__GNUC__) && !defined(__IBMCPP__)
#if defined(HAVE_POSIX_IO) && !defined(__GNUC__) && !defined(__IBMCPP__) && !defined(HB_OS_OS2)
errno = 0;
switch( uiMode )
@@ -851,6 +851,43 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
}
s_uiErrorLast = errno;
#elif defined(HB_OS_OS2)
{
/* 08/04/2000 - maurilio.longo@libero.it */
struct _FILELOCK fl, ful;
errno = 0;
switch(uiMode) {
case FL_LOCK:
fl.lOffset = ulStart;
fl.lRange = ulLength;
ful.lOffset = 0;
ful.lRange = 0;
/* lock region, 2 seconds timeout, exclusive access - no atomic */
iResult = (int) DosSetFileLocks(hFileHandle, &ful, &fl, 2000L, 0L);
break;
case FL_UNLOCK:
fl.lOffset = 0;
fl.lRange = 0;
ful.lOffset = ulStart;
ful.lRange = ulLength;
/* unlock region, 2 seconds timeout, exclusive access - no atomic */
iResult = (int) DosSetFileLocks(hFileHandle, &ful, &fl, 2000L, 0L);
break;
default:
iResult = 0;
}
s_uiErrorLast = errno;
}
#elif defined(_MSC_VER)
{
@@ -913,7 +950,7 @@ void hb_fsCommit( FHANDLE hFileHandle )
{
HB_TRACE(HB_TR_DEBUG, ("hb_fsCommit(%p)", hFileHandle));
#if defined(HB_FS_FILE_IO)
#if defined(HB_FS_FILE_IO) && !defined(HB_OS_OS2)
{
int dup_handle;
@@ -927,6 +964,18 @@ void hb_fsCommit( FHANDLE hFileHandle )
s_uiErrorLast = errno;
}
#elif defined(HB_OS_OS2)
{
errno = 0;
/* 08/04/2000 - maurilio.longo@libero.it
TODO: what about error code from DosResetBuffer() call? */
DosResetBuffer(hFileHandle);
s_uiErrorLast = errno;
}
#else
s_uiErrorLast = FS_ERROR;