home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flnew -- Create a file (but not if it already exists)
- *
- * Synopsis ercode = flnew(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 does not exist, it is created and
- * opened for reading and writing. The file can be
- * accessed by using the returned handle number. An error
- * occurs if the file already exists.
- *
- * 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_ARCHIVE (32) - Archive flag (file changed since
- * last backed up)
- *
- * File attributes may be combined by adding the attribute
- * codes. Volume labels or subdirectories cannot be
- * created using FLNEW.
- *
- * An error occurs if the program is not running under DOS
- * version 3.0 or greater. (Use FLCREATE in that case.)
- *
- * The file is opened in "compatibility mode". See FLOPEN
- * for more information about this.
- *
- * 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>
- #include <bquery.h>
-
- int flnew(pfile,phandle,attrib)
- char *pfile;
- int *phandle,attrib;
- {
- DOSREG dos_reg;
- int minor,ercode;
- ADS file_ads;
-
- if (qydosver(&minor) < 3)
- {
- ercode = 1;
- }
- else
- {
- dos_reg.ax = 0x5b00;
- 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);
- }