• Short file names

    From Marco@21:1/5 to All on Thu Jun 24 06:42:41 2021
    Hi, there is a function in xharbour returning the short file name in 8.3 format of a long file name?

    EXAMPLE:

    LF_ToShort("long_file_name.txt") -> "LONGFI~1.TXT"

    thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dlzc@21:1/5 to Marco on Thu Jun 24 12:09:02 2021
    Dear Marco:

    On Thursday, June 24, 2021 at 6:42:42 AM UTC-7, Marco wrote:
    Hi, there is a function in xharbour returning the short file name in
    8.3 format of a long file name?

    There is not always a "short file name" generated.

    If you get no other answer, you can "RUN" a directory command, pipe the output to a file, and parse the file.
    DIR cfilename.typ /X >PARSEME.TXT
    date... time... size... short file name... long file name.
    Seems to be very columnatic, so should be easy to parse as an SDF or something.

    David A. Smith

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jayadev U@21:1/5 to Marco on Fri Jun 25 09:42:17 2021
    On 24-06-2021 07:12 pm, Marco wrote:
    Hi, there is a function in xharbour returning the short file name in 8.3 format of a long file name?

    EXAMPLE:

    LF_ToShort("long_file_name.txt") -> "LONGFI~1.TXT"

    thanks.


    Hi,

    Please try with the following:

    #pragma begindump

    #include <windows.h>
    #include "hbapi.h"

    HB_FUNC( GETSHORTPATHNAME )
    {
    char buffer[ MAX_PATH + 1 ] = {0};
    GetShortPathName( hb_parcx(1), buffer, MAX_PATH );
    hb_retc( buffer );
    }

    HB_FUNC( GETSHORTFILENAME )
    {
    char pszReturn[ MAX_PATH ] ;
    pszReturn[0]= '\0' ;

    GetShortPathName( hb_parcx( 1 ), pszReturn, MAX_PATH - 1 ) ;
    hb_retc( pszReturn ) ;
    }

    #pragma enddump


    HTH,

    Warm regards,

    Jayadev

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marco@21:1/5 to All on Tue Jul 6 02:08:43 2021
    Il giorno venerdì 25 giugno 2021 alle 06:12:21 UTC+2 Jayadev U ha scritto:
    On 24-06-2021 07:12 pm, Marco wrote:
    Hi, there is a function in xharbour returning the short file name in 8.3 format of a long file name?

    EXAMPLE:

    LF_ToShort("long_file_name.txt") -> "LONGFI~1.TXT"

    thanks.

    Hi,

    Please try with the following:

    #pragma begindump

    #include <windows.h>
    #include "hbapi.h"

    HB_FUNC( GETSHORTPATHNAME )
    {
    char buffer[ MAX_PATH + 1 ] = {0};
    GetShortPathName( hb_parcx(1), buffer, MAX_PATH );
    hb_retc( buffer );
    }

    HB_FUNC( GETSHORTFILENAME )
    {
    char pszReturn[ MAX_PATH ] ;
    pszReturn[0]= '\0' ;

    GetShortPathName( hb_parcx( 1 ), pszReturn, MAX_PATH - 1 ) ;
    hb_retc( pszReturn ) ;
    }

    #pragma enddump


    HTH,

    Warm regards,

    Jayadev

    Thanks it works!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)