xHarbour Reference Documentation > Function Reference |
Returns the operating specific characters for paths.
HB_OsPathDelimiters() --> cDelimiters
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.
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 |
// 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
http://www.xHarbour.com