2021-04-14 22:25 UTC+0200 Aleksander Czajczynski (hb fki.pl)
+ src/rtl/vfilehi.prg
* src/rtl/Makefile
* src/harbour.def
* include/harbour.hbx
+ added FILE API counterparts to hb_DirBuild() and hb_FNameExists()
hb_vfDirBuild( <cDir> ) -> <lSuccess>
hb_vfDirUnbuild( <cDir> ) -> <lSuccess>
hb_vfNameExists( <cName> ) -> <lExists>
; their implementations are imported from 3.4
https://github.com/vszakats/hb/blob/master/src/rtl/hbfilehi.prg
but were renamed to fit in the hb_vf* namespace
* src/rtl/hbfilehi.prg
* use hb_LeftEq() instead of Left() ==
; partial merge of 3.4
2015-07-27 14:26 UTC+0200 Viktor Szakats
! fix several sloppy checks where Empty() were
used on strings while in fact a zero length
check would have been correct.
; Empty() is a "weasel-word" when used on strings,
should be used carefully and sparingly.
* ChangeLog.txt
% avoid spaces before EOLs
This commit is contained in:
@@ -7,6 +7,32 @@
|
||||
Entries may not always be in chronological/commit order.
|
||||
See license at the end of file. */
|
||||
|
||||
2021-04-14 22:25 UTC+0200 Aleksander Czajczynski (hb fki.pl)
|
||||
+ src/rtl/vfilehi.prg
|
||||
* src/rtl/Makefile
|
||||
* src/harbour.def
|
||||
* include/harbour.hbx
|
||||
+ added FILE API counterparts to hb_DirBuild() and hb_FNameExists()
|
||||
hb_vfDirBuild( <cDir> ) -> <lSuccess>
|
||||
hb_vfDirUnbuild( <cDir> ) -> <lSuccess>
|
||||
hb_vfNameExists( <cName> ) -> <lExists>
|
||||
; their implementations are imported from 3.4
|
||||
https://github.com/vszakats/hb/blob/master/src/rtl/hbfilehi.prg
|
||||
but were renamed to fit in the hb_vf* namespace
|
||||
|
||||
* src/rtl/hbfilehi.prg
|
||||
* use hb_LeftEq() instead of Left() ==
|
||||
; partial merge of 3.4
|
||||
2015-07-27 14:26 UTC+0200 Viktor Szakats
|
||||
! fix several sloppy checks where Empty() were
|
||||
used on strings while in fact a zero length
|
||||
check would have been correct.
|
||||
; Empty() is a "weasel-word" when used on strings,
|
||||
should be used carefully and sparingly.
|
||||
|
||||
* ChangeLog.txt
|
||||
% avoid spaces before EOLs
|
||||
|
||||
2021-04-12 21:18 UTC+0200 Aleksander Czajczynski (hb fki.pl)
|
||||
* src/rtl/hbfilehi.prg
|
||||
* hb_DirBuild() will now honor UNC "\\server\share\dir\tree" parameter
|
||||
@@ -16,7 +42,7 @@
|
||||
folder was created on current drive, as if the UNC specifier was
|
||||
omitted. It was more or less consistent with other platforms but
|
||||
not expected for this platform. Spotted by Maurizio la Cecilia (#233)
|
||||
[INCOMPATIBLE]
|
||||
[INCOMPATIBLE]
|
||||
|
||||
* contrib/hbdoc/hbdoc.prg
|
||||
* contrib/hbformat/utils/hbformat.prg
|
||||
@@ -27,7 +53,7 @@
|
||||
* utils/hbi18n/hbi18n.prg
|
||||
* utils/hbtest/hbtest.prg
|
||||
* bumped copyright year to 2021
|
||||
|
||||
|
||||
2021-04-10 23:32 UTC+0200 Aleksander Czajczynski (hb fki.pl)
|
||||
* contrib/hbfbird/firebird.c
|
||||
+ added optional <cCollate> as 7-th parameter of FBCREATEDB( <cDB>,
|
||||
|
||||
@@ -941,10 +941,12 @@ DYNAMIC hb_vfCommit
|
||||
DYNAMIC hb_vfConfig
|
||||
DYNAMIC hb_vfCopyFile
|
||||
DYNAMIC hb_vfDirectory
|
||||
DYNAMIC hb_vfDirBuild
|
||||
DYNAMIC hb_vfDirExists
|
||||
DYNAMIC hb_vfDirMake
|
||||
DYNAMIC hb_vfDirRemove
|
||||
DYNAMIC hb_vfDirSpace
|
||||
DYNAMIC hb_vfDirUnbuild
|
||||
DYNAMIC hb_vfEof
|
||||
DYNAMIC hb_vfErase
|
||||
DYNAMIC hb_vfExists
|
||||
@@ -957,6 +959,7 @@ DYNAMIC hb_vfLoad
|
||||
DYNAMIC hb_vfLock
|
||||
DYNAMIC hb_vfLockTest
|
||||
DYNAMIC hb_vfMoveFile
|
||||
DYNAMIC hb_vfNameExists
|
||||
DYNAMIC hb_vfOpen
|
||||
DYNAMIC hb_vfRead
|
||||
DYNAMIC hb_vfReadAt
|
||||
|
||||
@@ -1132,11 +1132,13 @@ HB_FUN_HB_VFCLOSE
|
||||
HB_FUN_HB_VFCOMMIT
|
||||
HB_FUN_HB_VFCONFIG
|
||||
HB_FUN_HB_VFCOPYFILE
|
||||
HB_FUN_HB_VFDIRBUILD
|
||||
HB_FUN_HB_VFDIRECTORY
|
||||
HB_FUN_HB_VFDIREXISTS
|
||||
HB_FUN_HB_VFDIRMAKE
|
||||
HB_FUN_HB_VFDIRREMOVE
|
||||
HB_FUN_HB_VFDIRSPACE
|
||||
HB_FUN_HB_VFDIRUNBUILD
|
||||
HB_FUN_HB_VFEOF
|
||||
HB_FUN_HB_VFERASE
|
||||
HB_FUN_HB_VFEXISTS
|
||||
@@ -1149,6 +1151,7 @@ HB_FUN_HB_VFLOAD
|
||||
HB_FUN_HB_VFLOCK
|
||||
HB_FUN_HB_VFLOCKTEST
|
||||
HB_FUN_HB_VFMOVEFILE
|
||||
HB_FUN_HB_VFNAMEEXISTS
|
||||
HB_FUN_HB_VFOPEN
|
||||
HB_FUN_HB_VFREAD
|
||||
HB_FUN_HB_VFREADAT
|
||||
|
||||
@@ -289,6 +289,7 @@ PRG_SOURCES := \
|
||||
ttopbar.prg \
|
||||
typefile.prg \
|
||||
valtoexp.prg \
|
||||
vfilehi.prg \
|
||||
wait.prg \
|
||||
|
||||
LIBNAME := hbrtl
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* High-level portable file functions.
|
||||
*
|
||||
* Copyright 2009-2011 Viktor Szakats (vszakats.net/harbour)
|
||||
* Copyright 2009-2017 Viktor Szakats (vsz.me/hb)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -280,16 +280,16 @@ FUNCTION hb_DirBuild( cDir )
|
||||
|
||||
cDir := hb_DirSepAdd( cDir )
|
||||
|
||||
IF ! Empty( hb_osDriveSeparator() ) .AND. ;
|
||||
IF ! hb_osDriveSeparator() == "" .AND. ;
|
||||
( tmp := At( hb_osDriveSeparator(), cDir ) ) > 0
|
||||
cDirTemp := Left( cDir, tmp )
|
||||
cDir := SubStr( cDir, tmp + 1 )
|
||||
#ifdef __PLATFORM__WINDOWS
|
||||
ELSEIF Left( cDir, 2 ) == "\\" /* UNC Path, network share */
|
||||
ELSEIF hb_LeftEq( cDir, "\\" ) /* UNC Path, network share */
|
||||
cDirTemp := Left( cDir, hb_At( "\", cDir, 3 ) )
|
||||
cDir := SubStr( cDir, Len( cDirTemp ) + 1 )
|
||||
#endif
|
||||
ELSEIF Left( cDir, 1 ) == hb_ps()
|
||||
ELSEIF hb_LeftEq( cDir, hb_ps() )
|
||||
cDirTemp := Left( cDir, 1 )
|
||||
cDir := SubStr( cDir, 2 )
|
||||
ELSE
|
||||
@@ -297,10 +297,10 @@ FUNCTION hb_DirBuild( cDir )
|
||||
ENDIF
|
||||
|
||||
FOR EACH cDirItem IN hb_ATokens( cDir, hb_ps() )
|
||||
IF !( Right( cDirTemp, 1 ) == hb_ps() ) .AND. ! Empty( cDirTemp )
|
||||
IF ! Right( cDirTemp, 1 ) == hb_ps() .AND. ! cDirTemp == ""
|
||||
cDirTemp += hb_ps()
|
||||
ENDIF
|
||||
IF ! Empty( cDirItem ) /* Skip root path, if any */
|
||||
IF ! cDirItem == "" /* Skip root path, if any */
|
||||
cDirTemp += cDirItem
|
||||
IF hb_FileExists( cDirTemp )
|
||||
RETURN .F.
|
||||
@@ -317,7 +317,6 @@ FUNCTION hb_DirBuild( cDir )
|
||||
|
||||
FUNCTION hb_DirUnbuild( cDir )
|
||||
|
||||
LOCAL cDirTemp
|
||||
LOCAL tmp
|
||||
|
||||
IF ! HB_ISSTRING( cDir )
|
||||
@@ -328,19 +327,17 @@ FUNCTION hb_DirUnbuild( cDir )
|
||||
|
||||
cDir := hb_DirSepDel( cDir )
|
||||
|
||||
cDirTemp := cDir
|
||||
DO WHILE ! Empty( cDirTemp )
|
||||
IF hb_DirExists( cDirTemp )
|
||||
IF hb_DirDelete( cDirTemp ) != 0
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
DO WHILE ! Empty( cDir )
|
||||
IF hb_DirExists( cDir ) .AND. ;
|
||||
hb_DirDelete( cDir ) != 0
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
IF ( tmp := RAt( hb_ps(), cDirTemp ) ) == 0
|
||||
IF ( tmp := RAt( hb_ps(), cDir ) ) == 0 /* FIXME: use hb_URAt() function */
|
||||
EXIT
|
||||
ENDIF
|
||||
cDirTemp := Left( cDirTemp, tmp - 1 )
|
||||
IF ! Empty( hb_osDriveSeparator() ) .AND. ;
|
||||
Right( cDirTemp, Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator()
|
||||
cDir := Left( cDir, tmp - 1 )
|
||||
IF ! hb_osDriveSeparator() == "" .AND. ;
|
||||
Right( cDir, Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator()
|
||||
EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
131
src/rtl/vfilehi.prg
Normal file
131
src/rtl/vfilehi.prg
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* High-level VF FILE API based functions.
|
||||
*
|
||||
* Copyright 2009-2017 Viktor Szakats (vsz.me/hb)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file LICENSE.txt. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA (or visit https://www.gnu.org/licenses/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
FUNCTION hb_vfDirBuild( cDir )
|
||||
|
||||
LOCAL cDirTemp
|
||||
LOCAL cDirItem
|
||||
LOCAL tmp
|
||||
|
||||
IF ! HB_ISSTRING( cDir )
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
cDir := hb_PathNormalize( cDir )
|
||||
|
||||
IF ! hb_vfDirExists( cDir )
|
||||
|
||||
cDir := hb_DirSepAdd( cDir )
|
||||
|
||||
IF ! hb_osDriveSeparator() == "" .AND. ;
|
||||
( tmp := At( hb_osDriveSeparator(), cDir ) ) > 0
|
||||
cDirTemp := Left( cDir, tmp )
|
||||
cDir := SubStr( cDir, tmp + 1 )
|
||||
#ifdef __PLATFORM__WINDOWS
|
||||
ELSEIF hb_LeftEq( cDir, "\\" ) /* UNC Path, network share */
|
||||
cDirTemp := Left( cDir, hb_At( "\", cDir, 3 ) )
|
||||
cDir := SubStr( cDir, Len( cDirTemp ) + 1 )
|
||||
#endif
|
||||
ELSEIF hb_LeftEq( cDir, hb_ps() )
|
||||
cDirTemp := Left( cDir, 1 )
|
||||
cDir := SubStr( cDir, 2 )
|
||||
ELSE
|
||||
cDirTemp := ""
|
||||
ENDIF
|
||||
|
||||
FOR EACH cDirItem IN hb_ATokens( cDir, hb_ps() )
|
||||
IF ! Right( cDirTemp, 1 ) == hb_ps() .AND. ! cDirTemp == ""
|
||||
cDirTemp += hb_ps()
|
||||
ENDIF
|
||||
IF ! cDirItem == "" /* Skip root path, if any */
|
||||
cDirTemp += cDirItem
|
||||
IF hb_vfExists( cDirTemp )
|
||||
RETURN .F.
|
||||
ELSEIF ! hb_vfDirExists( cDirTemp )
|
||||
IF hb_vfDirMake( cDirTemp ) != 0
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
NEXT
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
FUNCTION hb_vfDirUnbuild( cDir )
|
||||
|
||||
LOCAL tmp
|
||||
|
||||
IF ! HB_ISSTRING( cDir )
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
IF hb_vfDirExists( cDir )
|
||||
|
||||
cDir := hb_DirSepDel( cDir )
|
||||
|
||||
DO WHILE ! cDir == ""
|
||||
IF hb_vfDirExists( cDir ) .AND. ;
|
||||
hb_vfDirRemove( cDir ) != 0
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
IF ( tmp := RAt( hb_ps(), cDir ) ) == 0 /* FIXME: use hb_URAt() function */
|
||||
EXIT
|
||||
ENDIF
|
||||
cDir := Left( cDir, tmp - 1 )
|
||||
IF ! hb_osDriveSeparator() == "" .AND. ;
|
||||
Right( cDir, Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator()
|
||||
EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
FUNCTION hb_vfNameExists( cName )
|
||||
RETURN ;
|
||||
hb_vfExists( cName ) .OR. ;
|
||||
hb_vfDirExists( cName )
|
||||
Reference in New Issue
Block a user