In Erlang mode, calling file_open with [] as the FileOpts will result in [read, write, raw, binary] being passed to Erlang's file:open/2. As per the Erlang docs,
write
The file is opened for writing. It is created if it does not exist.
In NIF mode, calling file_open with [] as the FileOps will result in O_RDWR | O_APPEND being passed into the open call. Without O_CREATE, O_RDWR will return enoent when attempting to open a file that does not exist.
The end result of this is that calling file_open/2 in Erlang mode will create a file if it doesn't exist, but calling it it in NIF mode it will not. This relates closely to #242.
https://github.com/basho/bitcask/blob/develop/src/bitcask_file.erl#L133-L134 https://github.com/basho/bitcask/blob/develop/c_src/bitcask_nifs.c#L2314
In Erlang mode, calling
file_open
with[]
as the FileOpts will result in[read, write, raw, binary]
being passed to Erlang'sfile:open/2
. As per the Erlang docs,In NIF mode, calling
file_open
with[]
as the FileOps will result inO_RDWR | O_APPEND
being passed into theopen
call. WithoutO_CREATE
,O_RDWR
will returnenoent
when attempting to open a file that does not exist.The end result of this is that calling file_open/2 in Erlang mode will create a file if it doesn't exist, but calling it it in NIF mode it will not. This relates closely to #242.