Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_dos_creat() create a file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _dos_creat()            Create a file

 #include   <dos.h>

  unsigned     _dos_creat(path, attribute, handle);
  char *path;            String containing drive, path, and filename
  unsigned attribute;    File attributes
  int *handle;           File identifier return buffer

    _dos_creat uses MS-DOS function 3Ch to create a new file named 'path'
    with MS-DOS file attributes specified by 'attribute'. The assigned
    handle is returned in the location pointed to by handle. If the file
    already exists, _dos_creat() will empty it and leave the attributes
    unchanged. Use one or more of the following manifest constants, ORed
    together,  to specify attributes.

                    Constant     Attribute
                    -------------------------------------------
                    _A_NORMAL    Normal file - full read/write
                    _A_RDONLY    Read only file
                    _A_HIDDEN    Hidden file
                    _A_SYSTEM    System file
                    _A_VOLID     Volume ID file
                    _A_SUBDIR    Subdirectory
                    _A_ARCH      Archive file

    Returns:    _dos_creat() returns 0 if the file was opened
                successfully. If unsuccessful, it returns the MS-DOS
                error code and sets errno to one of the following
                manifest constants:

                    Constant     Meaning
                    ------------------------------------------------
                    ENOENT       Unknown path

                    EMFILE       No file handles available (too
                                 many files open already)

                    EACCES       Access denied (directory is full,
                                 or file already exists in an
                                 incompatible mode such as read only)

      Notes:    _dos_creat() opens a file with both read and write
                access, and if the MS-DOS SHARE command has been
                previously invoked the file is opened in compatibility
                mode.

                In MS-DOS 3.0 or higher, dosexterr() can be used for
                extended error code information.

   Portability:     MS-DOS only, version 2.0 or higher

 ------------------------------ Example ---------------------------------

           This program creates a file using _dos_creat()

           #include             <dos.h>

           main()
           {
             int handle;
             unsigned err_code;

             err_code = _dos_creat("c:\work\datafile.dat", _A_NORMAL,
           &handle);
             if (err_code)
                printf("Unable to create file -- error code is %u\n",
           err_code);
             .
             .  (file is used and closed)
             .
           }


See Also: _dos_creatnew() _dos_open() _dos_close()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson