FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Funcion File()
Posts: 298
Joined: Fri Oct 07, 2005 05:20 AM

Funcion File()

Posted: Tue Apr 07, 2026 06:32 PM

Buen d铆a a tod@s :

Solamente he utilizado mod_harboour con la versi贸n Harbour 3.2.0dev (r2004201301) y ADS, no hab铆a tenido ning煤n problema hasta el d铆a de hoy.
Despu茅s de revisar todo el c贸digo fuente, he conclu铆do que la funci贸n FILE() no resuelve la siguiente ruta:

  • //SERVIDOR:Puerto/CARPETA/SUBCARAPETA/TABLA.DBF

La funci贸n devuelve falso, si omito el "puerto" la funci贸n devuelve True.

Los procesos funcionaban correctamente desde el a帽o 2022.

驴 Alguna sugerencia ?

Vikthor
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Funcion File()

Posted: Thu Apr 09, 2026 06:15 AM

Vikthor, I think you could try debugging the C implementation of Harbour鈥檚 FILE() function.

You don鈥檛 have to recompile the Harbour sources for this. Instead, you can debug it directly鈥攐r even replace it with your own extended version鈥攗sing a #pragma BEGINDUMP block inside your PRG file.

Here鈥檚 an example of a debugging version of FILE(): (from AI not tested!)

#pragma BEGINDUMP

#include "hbapi.h"
#include "hbapifs.h"
#include "stdio.h"   // for printf

// Custom FILE_DEBUG function
HB_FUNC( FILE_DEBUG )
{
    // 1. Get parameter as string
    PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
    const char * szFileName = NULL;
    HB_BOOL bExist = FALSE;

if( pFileName && hb_itemType( pFileName ) & HB_IT_STRING )
{
    szFileName = hb_itemGetCPtr( pFileName );
    
    // Debug output: show the path being checked
    printf( "FILE_DEBUG: checking path -> '%s'\n", szFileName );
    fflush( stdout ); // flush immediately

    // 2. Call the original Harbour check
    //    hb_spFile is the internal C function used by FILE()
    bExist = hb_spFile( ( const char * ) szFileName, NULL );

    // Debug output: show the result
    printf( "FILE_DEBUG: result -> %s\n", bExist ? "EXISTS" : "DOES NOT EXIST" );
    fflush( stdout );
}
else
{
    printf( "FILE_DEBUG: ERROR - no string parameter received!\n" );
    fflush( stdout );
}

// Return result to Harbour
hb_retl( bExist );
}

#pragma ENDDUMP

Best regards,
Otto

Posts: 991
Joined: Thu Nov 17, 2005 05:49 PM

Re: Funcion File()

Posted: Tue May 19, 2026 12:08 PM

Hola Vikthor. (and hello Otto).

File() solo puede ver dentro de directorios locales. Piensa que File() le pregunta al sistema operativo si en el file system ese archivo existe. El OS no puede responder sobre la existencia de un archivo en un PC remota. Cuando preguntas con un UNC que hasta incluye puerto, no preguntas al sistema operativo sobre su propio file system.

Si el archivo es local en el server, entonces pregunta as铆: file( c:\FilePath\FileName.Ext ).

De paso, hablas de que usas ADS. Yo tambi茅n. Inspirado y con la ayuda de Antonio he producido un PHP language extension para usar ADS. Simplemente hago un map 1:1 de todas las funciones de ACE. Y basado en esas funciones, clases para usar ADS desde PHP que espero pronto publicar. Es mucho mas r谩pido que acceder a los datos usando Harbour + rddads pues no necesita compilar el .prg antes de ejecutar.

Saludos.

Continue the discussion