[erlang-questions] file:open with O_EXCL mode
John Kougoulos
koug@REDACTED
Wed Jan 20 18:05:23 CET 2010
As far as I know Unix "ln" is atomic too, which can be used to provide
locks for files.
On Wed, 20 Jan 2010, Dmitry Belayev wrote:
> Yes, I know about directories. But I have to create new files in one
> directory without any subdirectories.
>
> I've looked through mailing list archive and found out that people meet this
> problem once a year since 2004 year.
> And nothing changed since then.
>
> Michael Santos wrote:
>>> I have a problem creating unique files on linux in Erlang.
>>>
>>> So, is there any way to open file with O_EXCL mode from Erlang? Or will
>>> it be possible in next releases?
>>>
>>
>> While this doesn't answer your question directly, under Unix you can
>> guarantee atomicity by creating a directory and then the temp file inside
>> of the directory. For example:
>>
>> http://github.com/msantos/procket/blob/master/src/mktmp.erl
>>
>> The example spawns chmod, since Erlang doesn't seem to provide a way of
>> setting permissions. Instead, you could write to a private directory or
>> set your umask before starting beam
>
More information about the erlang-questions
mailing list