•  Back 
  •  File functions 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File5.10.19  Fopen                                                     TOS

 Name:         »File open« - Open a given file.

 Opcode:       61

 Syntax:       int32_t Fopen ( const int8_t *fname, int16_t mode );

 Description:  The GEMDOS routine Fopen serves for opening specified 
               files. The following apply:

                Parameter  Meaning

                fname      Name of file to be opened
                mode       Mode, as bit-vector:
                            Bit-0..2  = Access mode
                                       0 =     Read only
                                       1 =     Write only
                                       2 =     Read and write
                            Bit-3     = Reserved (to be set to 0)
                            Bit-4..6  = Sharing-Modus
                            Bit-7     = Inheritance flag
                           The bits 3..7 are only available with a 
                           GEMDOS that offers file locking extensions 
                           (test for _FLK cookie). The inheritance 
                           flag determines whether a child started by 
                           a process inherits any open file handles 
                           and has the same access as the parent. If 
                           this flag is set then a child has to reopen 
                           any files it wishes to use and must face 
                           the same sharing restrictions that other 
                           processes must share. The sharing mode 
                           determines the way other processes may 
                           access the file once it has been opened. 
                           The following apply:
                            Sharing  Meaning

                            0        Compatibility mode (will be used 
                                     by those programs that do not 
                                     know about network extensions). 
                                     If the file's read-only bit is 
                                     set then this is the same as deny 
                                     writing; otherwise it is the same 
                                     as deny reading/writing.
                            1        Reading and writing denied (the 
                                     file may not be opened a second 
                                     time)
                            2        Writing denied (the file may only 
                                     be reopened for reading)
                            3        Reading denied (the file may only 
                                     be reopened for writing)
                            4        Everything is allowed

               Warning: The file locking may be implemented in an 
               advisory manner, i.e. it may be possible to access 
               segments despite the presence of a lock. Programs that 
               support file locking should therefore set their own 
               lock before making an access and release it again 
               immediately after the access. In this way one can 
               guarantee that possible locks set by others will be 
               respected.

               In MiNT and MagiC there are in addition the following 
               modes available:

                mode   Meaning

                0x080  Reserved for MiNT
                0x100  Do not block file for I/O
                0x200  Create file, if this does not exist
                0x400  Set existing file to zero length
                0x800  Do not open existing file

               Note: For some devices, standard channel numbers 
               already exist, so that it is not necessary to call 
               Fopen. In detail:

                Channel  Meaning

                0        Keyboard (stdin:)
                1        Screen (stdout:)
                2        Serial port (stdaux:)
                3        Parallel port (stdprn:)

               According to Atari the standard channel numbers 4 and 5 
               are reserved, so that normal channel numbers for files 
               only start at 6.

               In addition it is also possible to open the following 
               character-oriented devices:

                  . PRN: (parallel port, -3)
                  . AUX: (serial port, -2)
                  . CON: (console, -1)

               Symbolic links are automatically dereferenced by this 
               function, i.e. if the file already exists as a symbolic 
               link, the file referenced from it will be opened or, 
               depending on the mode, truncated to zero length.

 Return value: The function returns the corresponding file handle in 
               the lower WORD of the positive LONG, or a negative 
               error-message.

 Availability: All GEMDOS versions.

 Group:        File functions

 See Also:     Binding   Fcreate   The BIOS input/output channels 
               F_SETLK