From 18e94d4e593993956e970de1f3754e897ac8cdfe Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 19 Feb 2011 08:28:16 +0000 Subject: [PATCH] 2011-02-19 09:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/Makefile + src/rtl/hbfilehc.c * src/rtl/hbfilehi.prg % Rewritten high-level HB_FNAME*() functions in C. --- harbour/ChangeLog | 12 +++- harbour/src/rtl/Makefile | 1 + harbour/src/rtl/hbfilehc.c | 103 +++++++++++++++++++++++++++++++++++ harbour/src/rtl/hbfilehi.prg | 46 ---------------- 4 files changed, 113 insertions(+), 49 deletions(-) create mode 100644 harbour/src/rtl/hbfilehc.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 267853b6e4..1ec59aa2ec 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,14 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-19 09:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/Makefile + + src/rtl/hbfilehc.c + * src/rtl/hbfilehi.prg + % Rewritten high-level HB_FNAME*() functions in C. + 2011-02-18 17:53 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/ideharbourhelp.prg ! Fixed: a last moment nasty omission in previous commit. * contrib/hbqt/hbmk2_qt.hbs ! Started: implementation of all C++ level class creation. - Currently new class structure is only appended in - QPainDevice.cpp and QWidget.cpp. - ; This has to go in SVN to keep track of heavy changes + Currently new class structure is only appended in + QPainDevice.cpp and QWidget.cpp. + ; This has to go in SVN to keep track of heavy changes in the engine plus my different working systems (home/office). * contrib/hbqt/qtcore/qth/QAbstractItemModel.qth * contrib/hbqt/qtgui/qth/QGraphicsLinearLayout.qth diff --git a/harbour/src/rtl/Makefile b/harbour/src/rtl/Makefile index 17e51f9c41..2fc54f6a06 100644 --- a/harbour/src/rtl/Makefile +++ b/harbour/src/rtl/Makefile @@ -83,6 +83,7 @@ C_SOURCES := \ hbdynhb.c \ hbfeof.c \ hbfile.c \ + hbfilehc.c \ hbgtcore.c \ hbhex.c \ hbi18n1.c \ diff --git a/harbour/src/rtl/hbfilehc.c b/harbour/src/rtl/hbfilehc.c new file mode 100644 index 0000000000..7aedad98e9 --- /dev/null +++ b/harbour/src/rtl/hbfilehc.c @@ -0,0 +1,103 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * High-level portable file functions. + * + * Copyright 2011 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * 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. + * + */ + +#include "hbapi.h" +#include "hbapifs.h" + +HB_FUNC( HB_FNAMEDIR ) +{ + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + hb_retc( pFilepath->szPath ); + hb_xfree( pFilepath ); +} + +HB_FUNC( HB_FNAMENAME ) +{ + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + hb_retc( pFilepath->szName ); + hb_xfree( pFilepath ); +} + +HB_FUNC( HB_FNAMEEXT ) +{ + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + hb_retc( pFilepath->szExtension ); + hb_xfree( pFilepath ); +} + +HB_FUNC( HB_FNAMENAMEEXT ) +{ + char szPath[ HB_PATH_MAX ]; + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + pFilepath->szPath = NULL; + hb_retc( hb_fsFNameMerge( szPath, pFilepath ) ); + hb_xfree( pFilepath ); +} + +HB_FUNC( HB_FNAMEEXTSET ) +{ + char szPath[ HB_PATH_MAX ]; + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + pFilepath->szExtension = hb_parc( 2 ); + hb_retc( hb_fsFNameMerge( szPath, pFilepath ) ); + hb_xfree( pFilepath ); +} + +HB_FUNC( HB_FNAMEEXTSETDEF ) +{ + char szPath[ HB_PATH_MAX ]; + PHB_FNAME pFilepath = hb_fsFNameSplit( hb_parcx( 1 ) ); + if( ! pFilepath->szExtension ) + pFilepath->szExtension = hb_parc( 2 ); + hb_retc( hb_fsFNameMerge( szPath, pFilepath ) ); + hb_xfree( pFilepath ); +} diff --git a/harbour/src/rtl/hbfilehi.prg b/harbour/src/rtl/hbfilehi.prg index e0d4377e4e..306c770841 100644 --- a/harbour/src/rtl/hbfilehi.prg +++ b/harbour/src/rtl/hbfilehi.prg @@ -339,49 +339,3 @@ FUNCTION hb_DirUnbuild( cDir ) ENDIF RETURN .T. - -FUNCTION hb_FNameDir( cFileName ) - LOCAL cDir - - hb_FNameSplit( cFileName, @cDir ) - - RETURN cDir - -FUNCTION hb_FNameName( cFileName ) - LOCAL cName - - hb_FNameSplit( cFileName,, @cName ) - - RETURN cName - -FUNCTION hb_FNameNameExt( cFileName ) - LOCAL cName, cExt - - hb_FNameSplit( cFileName,, @cName, @cExt ) - - RETURN hb_FNameMerge( NIL, cName, cExt ) - -FUNCTION hb_FNameExt( cFileName ) - LOCAL cExt - - hb_FNameSplit( cFileName,,, @cExt ) - - RETURN cExt - -FUNCTION hb_FNameExtSet( cFileName, cExt ) - LOCAL cDir, cName - - hb_FNameSplit( cFileName, @cDir, @cName ) - - RETURN hb_FNameMerge( cDir, cName, cExt ) - -FUNCTION hb_FNameExtSetDef( cFileName, cDefExt ) - LOCAL cDir, cName, cExt - - hb_FNameSplit( cFileName, @cDir, @cName, @cExt ) - - IF Empty( cExt ) - cExt := cDefExt - ENDIF - - RETURN hb_FNameMerge( cDir, cName, cExt )