home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flcreate -- Create a file (even if it already exists)
- *
- * Synopsis ercode = flcreate(pfile,phandle,attrib);
- *
- * int ercode Returned DOS error code
- * char *pfile File path name to be opened
- * int *phandle Returned DOS file handle
- * int attrib file attribute
- *
- * Description If the specified file exists, it is truncated to length
- * zero; if it does not exist, it is created. The file is
- * opened for reading and writing. The file can be
- * accessed by using the returned handle number.
- *
- * The file is given the attributes specified by attrib.
- * The possible values are:
- *
- * AT_GENERAL ( 0) - General, no attribute
- * AT_RDONLY ( 1) - Read only (may not be opened for writing)
- * AT_HIDDEN ( 2) - Hidden file
- * AT_SYSTEM ( 4) - System file
- * AT_VOLUME ( 8) - Volume label
- * AT_DIR (16) - Subdirectory
- * AT_ARCHIVE (32) - Archive flag (file changed since
- * last backed up)
- *
- * File attributes may be combined by adding the attribute
- * codes. Volume labels and subdirectories cannot be
- * created using FLCREATE.
- *
- * Under DOS 3.0 or greater, the file is opened in
- * "compatibility mode". See FLOPEN for more information
- * about this.
- *
- * Note that an existing read-only file cannot be created
- * (since it cannot be truncated).
- *
- * Under DOS 3.0 or greater, use FLNEW to create a file
- * without truncating any pre-existing copy of the file, or
- * FLTEMP to create a file with a unique name.
- *
- * Returns ercode DOS function error code
- * *phandle File handle of the created file. If an
- * error is encountered, -1 is returned.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bfile.h>
-
- int flcreate(pfile,phandle,attrib)
- char *pfile;
- int *phandle,attrib;
- {
- DOSREG dos_reg;
- int ercode;
- ADS file_ads;
-
- dos_reg.ax = 0x3c00; /* Function call 0x3C */
- dos_reg.cx = utbyword(0,attrib);
- utabsptr(pfile,&file_ads);
- dos_reg.ds = file_ads.s;
- dos_reg.dx = file_ads.r;
-
- ercode = dos(&dos_reg);
- if (ercode == 0)
- *phandle = (int)dos_reg.ax;
- else
- *phandle = -1;
-
- return(ercode);
- }