Page 1 of 1

Antonio: Bug in cFileSubDir( cPath )

PostPosted: Sun Jan 31, 2016 3:03 pm
by byte-one
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.

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Mon Feb 01, 2016 9:46 am
by Antonio Linares
Günther,

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

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Mon Feb 01, 2016 2:34 pm
by byte-one
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().

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Mon Feb 01, 2016 4:13 pm
by Antonio Linares
Please try this one:

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

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

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Tue Feb 02, 2016 12:05 pm
by byte-one
Antonio, thanks!
But this method is not functioning with UNC-path !

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Tue Feb 02, 2016 7:04 pm
by Antonio Linares
Günther,

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

Code: Select all  Expand view
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: Select all  Expand view
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 )

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Wed Feb 03, 2016 12:05 am
by byte-one
Antonio, thanks!!!
In the next FWH??

Re: Antonio: Bug in cFileSubDir( cPath )

PostPosted: Wed Feb 03, 2016 7:41 am
by Antonio Linares
yes, included in next FWH version :-)