Funcion File()

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
User avatar
Vikthor
Posts: 299
Joined: Fri Oct 07, 2005 5:20 am
Location: México

Funcion File()

Post by Vikthor »

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
User avatar
Otto
Posts: 7020
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Funcion File()

Post by Otto »

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

You don’t have to recompile the Harbour sources for this. Instead, you can debug it directly—or even replace it with your own extended version—using a #pragma BEGINDUMP block inside your PRG file.

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

Code: Select all | Expand

#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

User avatar
reinaldocrespo
Posts: 991
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Funcion File()

Post by reinaldocrespo »

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.

Post Reply