_FCreate( ) (Rutina de biblioteca API)

Asigna un canal de Visual FoxPro a un archivo nuevo.

FCHAN _FCreate(char FAR *filename, int mode)
char FAR *filename;         /* Name of file to create. */
int mode;                     /* File attributes. */

Observaciones

Si ya existe un archivo con el nombre especificado, _FCreate( ) trunca el archivo existente a cero bytes.

El parámetro mode puede ser uno o varios de los siguientes indicadores: FC_READONLY, FC_SYSTEM, FC_HIDDEN y FC_TEMPORARY. Puede combinar estos indicadores mediante los siguientes operadores de C | o +. Un indicador adicional, FC_NORMAL, especifica que el archivo no tiene ninguno de los demás atributos. Los archivos FC_TEMPORARY se eliminan automáticamente cuando se llama a _FClose( ) para cerrar el archivo.

_FCreate( ) devuelve el canal de archivo si tiene éxito en la creación del archivo o devuelve – 1 si falla.

Para obtener más información acerca de cómo crear una biblioteca API e integrarla con Visual FoxPro, vea Acceso a la API de Visual FoxPro.

Ejemplo

El ejemplo siguiente utiliza _FCreate( ) para crear varios archivos mediante los diversos indicadores mode de _FCreate( ).

Código Visual FoxPro

SET LIBRARY TO FCREATE 

Código C

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   FCHAN fchan;

   fchan = _FCreate("normal.tmp", FC_NORMAL);
   _FClose(fchan);

   fchan = _FCreate("readonly.tmp", FC_READONLY);
   _FClose(fchan);

   fchan = _FCreate("hidden.tmp", FC_HIDDEN);
   _FClose(fchan);

   fchan = _FCreate("system.tmp", FC_SYSTEM);
   _FClose(fchan);

   fchan = _FCreate("temp.tmp", FC_TEMPORARY);
   _FClose(fchan);

   fchan = _FCreate("multi.tmp", FC_SYSTEM | FC_READONLY);
   _FClose(fchan);
}

FoxInfo myFoxInfo[] = {
   {"FCREATE", (FPFI) Example, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

Vea también

_FClose( ) (Rutina de biblioteca API) | _FOpen( ) (Rutina de biblioteca API) | Acceso a la API de Visual FoxPro