2001-12-21 17:58 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>
This commit is contained in:
@@ -8,6 +8,19 @@
|
||||
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2001-12-22 11:30 UTC+0100 Antonio Linares <alinares@fivetech.com>
|
||||
* source/vm/dynlibhb.c
|
||||
+ New function hb_StartApp() added
|
||||
|
||||
* source/vm/hvm.c
|
||||
! Fixed hb_fsRename() and hb_fsDelete() to return BOOL
|
||||
|
||||
! All low-level functions returning BOOL now check
|
||||
for valid API call return value inside the platform
|
||||
* Some alingment of the text on edit mode.
|
||||
! hb_fsLock() fixed to not return TRUE when the mode
|
||||
* Getsourcefiles() function speed optimized(thanks Victor)
|
||||
|
||||
2001-12-22 03:30 UTC+0700 Andi Jahja <harbour@cbn.net.id>
|
||||
* source/rtl/filesys.c
|
||||
* add required C casts
|
||||
|
||||
@@ -107,7 +107,7 @@ extern FHANDLE hb_fsCreateTemp ( const BYTE * pszDir, const BYTE * pszPrefix, U
|
||||
extern BYTE * hb_fsCurDir ( USHORT uiDrive ); /* retrieve a static pointer containing current directory for specified drive */
|
||||
extern USHORT hb_fsCurDirBuff ( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ); /* copy current directory for given drive into a buffer */
|
||||
extern BYTE hb_fsCurDrv ( void ); /* retrieve current drive number */
|
||||
extern int hb_fsDelete ( BYTE * pszFileName ); /* delete a file */
|
||||
extern BOOL hb_fsDelete ( BYTE * pszFileName ); /* delete a file */
|
||||
extern BOOL hb_fsEof ( FHANDLE hFileHandle ); /* determine if an open file is position at end-of-file */
|
||||
extern USHORT hb_fsError ( void ); /* retrieve file system error */
|
||||
extern BOOL hb_fsFile ( BYTE * pszFileName ); /* determine if a file exists */
|
||||
@@ -123,7 +123,7 @@ extern FHANDLE hb_fsOpen ( BYTE * pszFileName, USHORT uiFlags ); /* open
|
||||
extern USHORT hb_fsRead ( FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount ); /* read contents of a file into a buffer (<=64K) */
|
||||
extern ULONG hb_fsReadLarge ( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ); /* read contents of a file into a buffer (>64K) */
|
||||
extern BOOL hb_fsRmDir ( BYTE * pszDirName ); /* remove a directory */
|
||||
extern int hb_fsRename ( BYTE * pszOldName, BYTE * pszNewName ); /* rename a file */
|
||||
extern BOOL hb_fsRename ( BYTE * pszOldName, BYTE * pszNewName ); /* rename a file */
|
||||
extern ULONG hb_fsSeek ( FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); /* reposition an open file */
|
||||
extern ULONG hb_fsTell ( FHANDLE hFileHandle ); /* retrieve the current position of a file */
|
||||
extern void hb_fsSetDevMode ( FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */
|
||||
|
||||
@@ -1022,70 +1022,70 @@ void hb_fsSetError( USHORT uiError )
|
||||
s_uiErrorLast = uiError;
|
||||
}
|
||||
|
||||
int hb_fsDelete( BYTE * pFilename )
|
||||
BOOL hb_fsDelete( BYTE * pFilename )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsDelete(%s)", (char*) pFilename));
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
iResult = DeleteFile( ( char * ) pFilename );
|
||||
bResult = ( DeleteFile( ( char * ) pFilename ) == 0 );
|
||||
s_uiErrorLast = GetLastError();
|
||||
|
||||
#elif defined(HAVE_POSIX_IO)
|
||||
|
||||
errno = 0;
|
||||
iResult = unlink( ( char * ) pFilename );
|
||||
bResult = ( unlink( ( char * ) pFilename ) == 0 );
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#elif defined(_MSC_VER) || defined(__MINGW32__)
|
||||
|
||||
errno = 0;
|
||||
iResult = remove( ( char * ) pFilename );
|
||||
bResult = ( remove( ( char * ) pFilename ) == 0 );
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = FS_ERROR;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
int hb_fsRename( BYTE * pOldName, BYTE * pNewName )
|
||||
BOOL hb_fsRename( BYTE * pOldName, BYTE * pNewName )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsRename(%s, %s)", (char*) pOldName, (char*) pNewName));
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
iResult = MoveFile( ( char * ) pOldName, ( char * ) pNewName );
|
||||
bResult = ( MoveFile( ( char * ) pOldName, ( char * ) pNewName ) == 0 );
|
||||
s_uiErrorLast = GetLastError();
|
||||
|
||||
#elif defined(HB_FS_FILE_IO)
|
||||
|
||||
errno = 0;
|
||||
iResult = rename( ( char * ) pOldName, ( char * ) pNewName );
|
||||
bResult = ( rename( ( char * ) pOldName, ( char * ) pNewName ) == 0 );
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = FS_ERROR;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
ULONG ulLength, USHORT uiMode )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsLock(%p, %lu, %lu, %hu)", hFileHandle, ulStart, ulLength, uiMode));
|
||||
|
||||
@@ -1106,7 +1106,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
ful.lRange = 0;
|
||||
|
||||
/* lock region, 2 seconds timeout, exclusive access - no atomic */
|
||||
iResult = ( int ) DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L );
|
||||
bResult = ( DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ) == 0 );
|
||||
break;
|
||||
|
||||
case FL_UNLOCK:
|
||||
@@ -1117,11 +1117,11 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
ful.lRange = ulLength;
|
||||
|
||||
/* unlock region, 2 seconds timeout, exclusive access - no atomic */
|
||||
iResult = ( int ) DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L );
|
||||
bResult = ( DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ) == 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
iResult = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
|
||||
s_uiErrorLast = errno;
|
||||
@@ -1136,15 +1136,15 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
switch( uiMode )
|
||||
{
|
||||
case FL_LOCK:
|
||||
iResult = locking( hFileHandle, _LK_LOCK, ulLength );
|
||||
bResult = ( locking( hFileHandle, _LK_LOCK, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
case FL_UNLOCK:
|
||||
iResult = locking( hFileHandle, _LK_UNLCK, ulLength );
|
||||
bResult = ( locking( hFileHandle, _LK_UNLCK, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
iResult = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
@@ -1160,15 +1160,15 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
switch( uiMode )
|
||||
{
|
||||
case FL_LOCK:
|
||||
iResult = _locking( hFileHandle, _LK_LOCK, ulLength );
|
||||
bResult = ( _locking( hFileHandle, _LK_LOCK, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
case FL_UNLOCK:
|
||||
iResult = _locking( hFileHandle, _LK_UNLOCK, ulLength );
|
||||
bResult = ( _locking( hFileHandle, _LK_UNLOCK, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
iResult = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
@@ -1187,39 +1187,29 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
switch( uiMode )
|
||||
{
|
||||
case FL_LOCK:
|
||||
{
|
||||
lock_info.l_type = F_WRLCK;
|
||||
lock_info.l_start = ulStart;
|
||||
lock_info.l_len = ulLength;
|
||||
lock_info.l_whence = SEEK_SET; /* start from the beginning of the file */
|
||||
lock_info.l_pid = getpid();
|
||||
|
||||
iResult = fcntl( hFileHandle, F_SETLK, &lock_info );
|
||||
lock_info.l_type = F_WRLCK;
|
||||
lock_info.l_start = ulStart;
|
||||
lock_info.l_len = ulLength;
|
||||
lock_info.l_whence = SEEK_SET; /* start from the beginning of the file */
|
||||
lock_info.l_pid = getpid();
|
||||
|
||||
if( iResult < 0 )
|
||||
iResult = 1; /* lock failed */
|
||||
else
|
||||
iResult = 0; /* lock was successful */
|
||||
}
|
||||
bResult = ( fcntl( hFileHandle, F_SETLK, &lock_info ) >= 0 );
|
||||
break;
|
||||
|
||||
case FL_UNLOCK:
|
||||
{
|
||||
lock_info.l_type = F_UNLCK; /* unlock */
|
||||
lock_info.l_start = ulStart;
|
||||
lock_info.l_len = ulLength;
|
||||
lock_info.l_whence = SEEK_SET;
|
||||
lock_info.l_pid = getpid();
|
||||
|
||||
iResult = fcntl( hFileHandle, F_SETLK, &lock_info );
|
||||
lock_info.l_type = F_UNLCK; /* unlock */
|
||||
lock_info.l_start = ulStart;
|
||||
lock_info.l_len = ulLength;
|
||||
lock_info.l_whence = SEEK_SET;
|
||||
lock_info.l_pid = getpid();
|
||||
|
||||
if( iResult < 0 )
|
||||
iResult = 0; /* lock failed */
|
||||
}
|
||||
bResult = ( fcntl( hFileHandle, F_SETLK, &lock_info ) >= 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
iResult = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
|
||||
s_uiErrorLast = errno;
|
||||
@@ -1231,26 +1221,26 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
switch( uiMode )
|
||||
{
|
||||
case FL_LOCK:
|
||||
iResult = lock( hFileHandle, ulStart, ulLength );
|
||||
bResult = ( lock( hFileHandle, ulStart, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
case FL_UNLOCK:
|
||||
iResult = unlock( hFileHandle, ulStart, ulLength );
|
||||
bResult = ( unlock( hFileHandle, ulStart, ulLength ) == 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
iResult = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = 1;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult == 0;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void hb_fsCommit( FHANDLE hFileHandle )
|
||||
@@ -1310,13 +1300,13 @@ void hb_fsCommit( FHANDLE hFileHandle )
|
||||
|
||||
BOOL hb_fsMkDir( BYTE * pDirname )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", (char*) pDirname));
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
iResult = CreateDirectory( ( char * ) pDirname, NULL );
|
||||
bResult = ( CreateDirectory( ( char * ) pDirname, NULL ) == 0 );
|
||||
s_uiErrorLast = GetLastError();
|
||||
|
||||
#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)
|
||||
@@ -1324,75 +1314,75 @@ BOOL hb_fsMkDir( BYTE * pDirname )
|
||||
errno = 0;
|
||||
|
||||
#if !defined(__WATCOMC__) && !defined(__BORLANDC__) && !defined(__IBMCPP__) && !defined(__MINGW32__)
|
||||
iResult = mkdir( ( char * ) pDirname, S_IWUSR | S_IRUSR | S_IXUSR );
|
||||
bResult = ( mkdir( ( char * ) pDirname, S_IWUSR | S_IRUSR | S_IXUSR ) == 0 );
|
||||
#else
|
||||
iResult = mkdir( ( char * ) pDirname );
|
||||
bResult = ( mkdir( ( char * ) pDirname ) == 0 );
|
||||
#endif
|
||||
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = 1;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult == 0;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
BOOL hb_fsChDir( BYTE * pDirname )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsChDir(%s)", (char*) pDirname));
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
iResult = SetCurrentDirectory( ( char * ) pDirname );
|
||||
bResult = ( SetCurrentDirectory( ( char * ) pDirname ) == 0 );
|
||||
s_uiErrorLast = GetLastError();
|
||||
|
||||
#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)
|
||||
|
||||
errno = 0;
|
||||
iResult = chdir( ( char * ) pDirname );
|
||||
bResult = ( chdir( ( char * ) pDirname ) == 0 );
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = 1;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult == 0;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
BOOL hb_fsRmDir( BYTE * pDirname )
|
||||
{
|
||||
int iResult;
|
||||
BOOL bResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsRmDir(%s)", (char*) pDirname));
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
iResult = RemoveDirectory( ( char * ) pDirname );
|
||||
bResult = ( RemoveDirectory( ( char * ) pDirname ) == 0 );
|
||||
s_uiErrorLast = GetLastError();
|
||||
|
||||
#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)
|
||||
|
||||
errno = 0;
|
||||
iResult = rmdir( ( char * ) pDirname );
|
||||
bResult = ( rmdir( ( char * ) pDirname ) == 0 );
|
||||
s_uiErrorLast = errno;
|
||||
|
||||
#else
|
||||
|
||||
iResult = 1;
|
||||
bResult = FALSE;
|
||||
s_uiErrorLast = FS_ERROR;
|
||||
|
||||
#endif
|
||||
|
||||
return iResult == 0;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/* NOTE: This is not thread safe function, it's there for compatibility. */
|
||||
|
||||
@@ -146,20 +146,16 @@ HB_FUNC( FERASE )
|
||||
{
|
||||
hb_fsSetError( 3 );
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
hb_retni( hb_fsDelete( ( BYTE * ) hb_parc( 1 ) ) );
|
||||
else
|
||||
hb_retni( -1 );
|
||||
hb_retni( ( ISCHAR( 1 ) &&
|
||||
hb_fsDelete( ( BYTE * ) hb_parc( 1 ) ) ) ? 0 : -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( FRENAME )
|
||||
{
|
||||
hb_fsSetError( 2 );
|
||||
|
||||
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
|
||||
hb_retni( hb_fsRename( ( BYTE * ) hb_parc( 1 ), ( BYTE * ) hb_parc( 2 ) ) );
|
||||
else
|
||||
hb_retni( -1 );
|
||||
hb_retni( ( ISCHAR( 1 ) && ISCHAR( 2 ) &&
|
||||
hb_fsRename( ( BYTE * ) hb_parc( 1 ), ( BYTE * ) hb_parc( 2 ) ) ) ? 0 : -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( FSEEK )
|
||||
|
||||
Reference in New Issue
Block a user