Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>sopen</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
sopen

Usage

   #include <io.h>
   int sopen(char *file,int oflag,int shflag[,int pmode]);

Description

   This function is comparable to the standard library open() function but
   prepares an opened file for DOS sharing. Note that attempting to use
   sopen() with DOS 2.x will result in an error. The DOS utility SHARE
   should be installed if files are to be opened in shared mode.



   char *file       Name of file to open

   int oflag        Operations allowed - one or more of:

                    O_APPEND         position file pointer to end

                    O_CREAT          create file if it doesn't exist

                    O_EXCL           used with O_CREAT, returns an error
                                     if file already exists

                    O_RDONLY         open file for reading only

                    O_RDWR           open file for reading and writing

                    O_TRUNC          truncates an existing file

                    O_WRONLY         opens file for writing only


   int shflag   Type of sharing allowed - one of:

                    SH_COMPAT        sets compatibility mode

                    SH_DENYRW        denies read and write access

                    SH_DENYWR        denies write access

                    SH_DENYRD        denies read access

                    SH_DENYNO        permits read and write access


   int pmode    optional permission mode - one or more of:

                    S_IWRITE         used with O_CREAT, permit writing

                    S_IREAD          used with O_CREAT, permit reading




Example 

   #include <stdio.h>
   #include <io.h>
   #include <stdlib.h>

   int main()
   {
       int fd;
       if (ERROR == (fd = sopen("file.ext", O_CREAT | O_RDWR,
               SH_COMPAT, S_IWRITE))) {
           printf ("Can't open file.ext");
           return EXIT_FAILURE;
       }
       return EXIT_SUCCESS;
   }

Return Value


   A file handle to the opened file is returned, otherwise -1
   and errno is set.

See Also

   open  fopen


See Also: open fopen

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