FileMode in TP6 
Author Message
 FileMode in TP6

Hi,

Is there anyone who would post some details about the filemode
variable? eg., allowable values and what the values allow me to
do or not do when reading and writing files.

My code is doing what I want it to, but it was more hit and miss
than programming prowess.

I know it is in the manuals, but my manuals haven't turned up since
I last moved house.

Thanks for your help,

Mike



Wed, 18 Jun 1902 08:00:00 GMT  
 FileMode in TP6

Quote:

>Is there anyone who would post some details about the filemode
>variable? eg., allowable values and what the values allow me to
>do or not do when reading and writing files.

>My code is doing what I want it to, but it was more hit and miss
>than programming prowess.

>I know it is in the manuals, but my manuals haven't turned up since
>I last moved house.

I've abandoned TP6, but how about the online help?  BPW 7.01 says :

<<
FileMode (variable)     (System unit)

The FileMode variable determines the access code to pass to DOS when
typed and untyped files (not text files) are opened using the Reset
procedure.

The default FileMode is 2. Assigning another value to FileMode causes
all subsequent Resets to use that mode.

The range of valid FileMode values depends on the version of DOS in use.
For all versions, these modes are defined:

0       Read only
1       Write only
2       Read/Write

DOS version 3.x and higher defines additional modes, which are primarily
concerned with file-sharing on networks.

(For more details, see your DOS programmer's reference manual.)

The BP7 manual says little more - Rewrite opens new files in Mode 2.

--
John Stockton, Surrey, UK.  Turnpike v1.12.  MIME.



Wed, 18 Jun 1902 08:00:00 GMT  
 FileMode in TP6

Quote:

>Hi,
>Is there anyone who would post some details about the filemode
>variable? eg., allowable values and what the values allow me to
>do or not do when reading and writing files.

In theory, allowable values are 0..255, since it's a byte value.  :-)

In reality, the manual lists the 3 basic values:

0 -- read only
1 -- write only
2 -- read/write

The default is 2.  Trying to open a file for writing in read-only mode, or
vice versa, will cause a runtime error 5 (file access denied).

There are other values not listed defined by DOS 3.x+.  The manual
recommends you refer to a DOS programmer's reference (which I don't have).  
There's probably a table in Ralf Brown's Interrupt List if you have that on
hand.

Quote:
>My code is doing what I want it to, but it was more hit and miss
>than programming prowess.
>I know it is in the manuals, but my manuals haven't turned up since
>I last moved house.

Well, this *should* be in the online help.

Quote:
>Thanks for your help,
>Mike

--
Scott F. Earnest            | We now return you to our regularly scheduled



Wed, 18 Jun 1902 08:00:00 GMT  
 FileMode in TP6

Quote:

> Is there anyone who would post some details about the filemode
> variable? eg., allowable values and what the values allow me to
> do or not do when reading and writing files.

Here's a unit I use to make dealing with filemode easier. At the end
are a bunch of comments from various sources to help explain the
limits.

Don't forget that filemode won't work for files of TEXT. <grr>

unit fmode;
interface
const
  ReadOnly   : byte = $00;
  WriteOnly  : byte = $01;
  ReadWrite  : byte = $02;
  Compatible : byte = $00; {compatibility mode}
  DenyAll    : byte = $10; {prohibit both read and write access by others}
  DenyWrite  : byte = $20; {prohibit write access by others}
  DenyRead   : byte = $30; {prohibit read access by others}
  DenyNone   : byte = $40; {allow full access by others}
  NoInherit  : byte = $80; {file is private to current process and will
                            not be inherited by child processes}
implementation
end.

{       AL = access and sharing modes
            bits 2-0: access mode
                000 read only
                001 write only
                010 read/write
            bit 3: reserved (0)
            bits 6-4: sharing mode (DOS 3+)
                000 compatibility mode
                001 "DENYALL" prohibit both read and write access by others
                010 "DENYWRITE" prohibit write access by others
                011 "DENYREAD" prohibit read access by others
                100 "DENYNONE" allow full access by others
            bit 7: inheritance
                if set, file is private to current process and will not be
                  inherited by child processes

File sharing behavior:
          |     Second and subsequent Opens
 First    |Compat  Deny   Deny   Deny   Deny
 Open     |        All    Write  Read   None
          |R W RW R W RW R W RW R W RW R W RW
 - - - - -| - - - - - - - - - - - - - - - - -
 Compat R |Y Y Y  N N N  1 N N  N N N  1 N N
        W |Y Y Y  N N N  N N N  N N N  N N N
        RW|Y Y Y  N N N  N N N  N N N  N N N
 - - - - -|
 Deny   R |C C C  N N N  N N N  N N N  N N N
 All    W |C C C  N N N  N N N  N N N  N N N
        RW|C C C  N N N  N N N  N N N  N N N
 - - - - -|
 Deny   R |2 C C  N N N  Y N N  N N N  Y N N
 Write  W |C C C  N N N  N N N  Y N N  Y N N
        RW|C C C  N N N  N N N  N N N  Y N N
 - - - - -|
 Deny   R |C C C  N N N  N Y N  N N N  N Y N
 Read   W |C C C  N N N  N N N  N Y N  N Y N
        RW|C C C  N N N  N N N  N N N  N Y N
 - - - - -|
 Deny   R |2 C C  N N N  Y Y Y  N N N  Y Y Y
 None   W |C C C  N N N  N N N  Y Y Y  Y Y Y
        RW|C C C  N N N  N N N  N N N  Y Y Y
Legend: Y = open succeeds, N = open fails with error code 05h
        C = open fails, INT 24 generated
        1 = open succeeds if file read-only, else fails with error code
        2 = open succeeds if file read-only, else fails with INT 24

Quote:
}

Leonard Erickson (aka Shadow)




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Filemode to share (READ/WRITE)

2. Filemode to share (READ/WRITE) and WIN9X

3. filemode

4. FileMode values

5. FileMode

6. FileMode

7. FileMode with Text files

8. filemode values for network

9. Filemode= for sharing

10. windows 2000 en TP6

11. rpcrt100.zip Optimized TP50/TP55/TP6/BP7 CRT Unit

12. TP6 memory limitations?

 

 
Powered by phpBB® Forum Software