Search code examples
ocamlfile-permissionsmkdir

What is the int argument in Sys.mkdir ocaml


On the Sys doc I can see there is a function to create a directory, I guess the string argument is the directory's name, however I don't know what the int argument is for.

val mkdir : string -> int -> unit
Create a directory with the given permissions. [Since 4.12.0]

It may be related to the second argument of the function of the same name in Unix:

val mkdir : string -> file_perm -> unit
Create a directory with the given permissions (see Unix.umask).

But it doesn't help me that much either.

What should I use for this argument if I want to create a directory to create files in?


Solution

  • This is the Unix file permission number. It is a 3 * 3 bit vector corresponding to the {execute,write,execute} permission in function of the the current user (either {owner,group,other}).

    On Windows, this argument is ignored and you can probably use 0o755 as a sensible unix default.