xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_OsPathDelimiters()

Returns the operating specific characters for paths.

Syntax

HB_OsPathDelimiters() --> cDelimiters

Return

The function returns a character string holding all delimiting characters that may occur in a full qualified path name, including separators for the drive and directories.

Info

See also:HB_OsNewLine(), HB_OsDriveSeparator(), HB_OsPathListSeparator(), HB_OsPathSeparator()
Category: Environment functions , xHarbour extensions
Source:rtl\philes.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example implements a function that splits a full qualified
// file name into all components.

   PROCEDURE Main
      LOCAL cFile := "c:\xhb\samples\Test.prg"
      LOCAL aFile

      aFile := SplitFileName( cFile )
      AEval( aFile, {|c| QOut( c ) } )

      ** output
      // c
      // xhb
      // samples
      // test.prg
   RETURN

   FUNCTION SplitFileName( cFileName )
      LOCAL cDelims:= HB_OSPathDelimiters()
      LOCAL aPos   := {0}, nStart, nEnd
      LOCAL aFile  := {}
      LOCAL cDelim, i, imax, cStr

      FOR EACH cDelim IN cDelims
         nStart := 1
         DO WHILE ( nEnd := At( cDelim, cFileName, nStart ) ) > 0
            AAdd( aPos, nEnd )
            nStart := nEnd + 1
         ENDDO
      NEXT

      imax  := Len( aPos )
      AAdd( aPos, Len( cFileName ) + 1 )
      ASort( aPos )

      FOR i:=1 TO imax
         nStart   := aPos[i] + 1
         nEnd     := aPos[i+1]
         cStr     := SubStr( cFileName, nStart, nEnd-nStart )
         IF .NOT. cStr == ""
            AAdd( aFile, cStr )
         ENDIF
      NEXT
   RETURN aFile

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe