[erlang-questions] file:open with O_EXCL mode

Dmitry Belayev <>
Wed Jan 20 14:53:04 CET 2010


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:
> On Wed, Jan 20, 2010 at 02:50:08PM +0300, Dmitry Belayev 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