From: Manuel Fahndrich <email@example.com>
To: "'firstname.lastname@example.org'" <email@example.com>
Subject: RE: file permission integer
Date: Tue, 30 Mar 1999 10:13:11 -0800
Thanks for the reply.
I thought about the bit encoding vs. datatype as well. What would be useful
is simply a function that creates the correct bit pattern from a more
descriptive data type list. Then power users can give the bit-pattern
directly, and standard users can go through the encoding function.
From: Xavier Leroy [mailto:Xavier.Leroy@inria.fr]
Sent: Monday, March 29, 1999 8:11 AM
To: Manuel Fahndrich; 'firstname.lastname@example.org'
Subject: Re: file permission integer
> The OCAML core contains a function
> open_out_gen : open_flag list -> int -> string -> out_channel
> where the integer corresponds to the file permissions set when a new file
> created. How is this integer interpreted? Does it vary from platform to
> platform? (Unix vs Windows).
> If this information is described in the doc, I apologize, but I couldn't
> find it.
No need to apologize, this is indeed not documented (oops!).
The integer argument to open_*_gen follows the Unix semantics,
i.e. 0oABC, where A are the user permissions, B the group permissions,
C the permissions for others. A, B, C are single octal digits
obtained by or-ing individual permission bits: 1 for execute permission,
2 for write permission, and 4 for read permission.
Under Windows, only the "write permission" bit of the "user
permission" digit is consulted, and determines if the file is created
read-write or read-only. (The other permission bits don't have any
equivalent in Win32, at least on a FAT file system.)
So, if you pass the correct permissions for Unix, your code should
work just fine under Windows.
In Caml Light, we used to have symbolic names for the various
permission bits. I removed them in OCaml after realizing that the
Unix bit-patterns work just fine in Windows as well. However, the
Unix encoding is a bit cryptic, so maybe those symbolic names were a
good idea after all.
All the best,
- Xavier Leroy
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:21 MET