Antonio: Bug in cFileSubDir( cPath )

Antonio: Bug in cFileSubDir( cPath )

Postby byte-one » Sun Jan 31, 2016 3: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Antonio: Bug in cFileSubDir( cPath )

Postby Antonio Linares » Mon Feb 01, 2016 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Antonio: Bug in cFileSubDir( cPath )

Postby byte-one » Mon Feb 01, 2016 2: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Antonio: Bug in cFileSubDir( cPath )

Postby Antonio Linares » Mon Feb 01, 2016 4:13 pm

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 ) ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Antonio: Bug in cFileSubDir( cPath )

Postby byte-one » 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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Antonio: Bug in cFileSubDir( cPath )

Postby Antonio Linares » Tue Feb 02, 2016 7:04 pm

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 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Antonio: Bug in cFileSubDir( cPath )

Postby byte-one » Wed Feb 03, 2016 12:05 am

Antonio, thanks!!!
In the next FWH??
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Antonio: Bug in cFileSubDir( cPath )

Postby Antonio Linares » Wed Feb 03, 2016 7:41 am

yes, included in next FWH version :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 78 guests