FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Antonio: Bug in cFileSubDir( cPath )
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Antonio: Bug in cFileSubDir( cPath )
Posted: Sun Jan 31, 2016 03:03 PM
in cFileSubDir( cPath ) are also the drive name returned! This should not be so!
Returns:
<cDirName> Just the path name specified inside the full filename, excluding the drive name.
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Mon Feb 01, 2016 09:46 AM

Günther,

Why do you think that the drive name should not be in the result ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Mon Feb 01, 2016 02:34 PM
Antonio, read the description from this function:
Returns:
<cDirName> Just the path name specified inside the full filename, excluding the drive name.

Look also at cFilePath()! This now the same result as cFileSubDir().
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Mon Feb 01, 2016 04:13 PM
Please try this one:

Code (fw): Select all Collapse
function cFileSubDir( cPath )   // returns the subdir of a path & filename

return SubStr( 4, cFilePath( If( Right( cPath, 1 ) == "\" ,;
                  Left( cPath, Len( cPath ) - 1 ), cPath ) ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Tue Feb 02, 2016 12:05 PM

Antonio, thanks!
But this method is not functioning with UNC-path !

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Tue Feb 02, 2016 07:04 PM
Günther,

Here you have it with UNC support. cFilePath() needs to be changed too:

Code (fw): Select all Collapse
function cFilePath( cPathMask )   // returns path of a filename

   local lUNC := "/" $ cPathMask
   local cSep := If( lUNC, "/", "\" )
   local n := RAt( cSep, cPathMask ), cDisk

return If( n > 0, Upper( Left( cPathMask, n ) ),;
           ( cDisk := cFileDisc( cPathMask ) ) + If( ! Empty( cDisk ), cSep, "" ) )


Code (fw): Select all Collapse
function cFileSubDir( cPath )   // returns the subdir of a path & filename

   local lUNC := "/" $ cPath
   local cTemp := cFilePath( If( Right( cPath, 1 ) $ "\/" ,;
                             Left( cPath, Len( cPath ) - 1 ), cPath ) )

return If( ! lUNC, SubStr( cTemp, 4 ), cTemp )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Wed Feb 03, 2016 12:05 AM

Antonio, thanks!!!
In the next FWH??

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Antonio: Bug in cFileSubDir( cPath )
Posted: Wed Feb 03, 2016 07:41 AM

yes, included in next FWH version :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion