From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA19005 for caml-redistribution; Tue, 30 Mar 1999 09:47:06 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA10134 for ; Tue, 30 Mar 1999 09:31:55 +0200 (MET DST) Received: from cs.Technion.AC.IL (csa.cs.technion.ac.il [132.68.32.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA29193; Tue, 30 Mar 1999 09:31:48 +0200 (MET DST) Received: from localhost (roy@localhost) by cs.Technion.AC.IL (8.9.0/8.9.0) with SMTP id JAA14056; Tue, 30 Mar 1999 09:33:12 +0200 (IST) Date: Tue, 30 Mar 1999 09:33:12 +0200 (IST) From: Friedman Roy To: Xavier Leroy cc: Manuel Fahndrich , "'caml-list@inria.fr'" Subject: Re: file permission integer In-Reply-To: <19990329181056.50745@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis The only caveat is that in Unix this also sets the user/group/other permissions, and the equivalent in NT involves writing a C function that sets the ACL attributes for the file. Roy On Mon, 29 Mar 1999, Xavier Leroy wrote: > > 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 is > > 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 > >