From 4bd026cccb2c22279dd9c88e704642c5a65d3c53 Mon Sep 17 00:00:00 2001
From: Michael Santos
Date: Fri, 30 Apr 2010 12:22:11 -0400
Subject: Support opening files in exclusive mode
Add an option that atomically tests for the existence of a file and
creates it if the file does not exist, by passing the O_EXCL flag
to open() on Unix and CREATE_NEW flag on Windows. Support for O_EXCL
varies across platforms and filesystems.
{ok, Fd} = file:open("/tmp/foo", [write,exclusive]),
{error, eexist} = file:open("/tmp/foo", [write,exclusive]).
---
lib/kernel/doc/src/file.xml | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
(limited to 'lib/kernel/doc')
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 382262d1ee..a9ceac0bcf 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -603,7 +603,7 @@ f.txt: {person, "kalle", 25}.
Filename = name()
Modes = [Mode]
- Mode = read | write | append | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed
+ Mode = read | write | append | exclusive | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed
Size = Delay = int()
IoDevice = io_device()
Reason = ext_posix() | system_limit
@@ -630,6 +630,17 @@ f.txt: {person, "kalle", 25}.
file opened with append will take place at
the end of the file.
+ exclusive
+ -
+
The file, when opened for writing, is created if it
+ does not exist. If the file exists, open will return
+ {error, eexist}.
+ This option does not guarantee exclusiveness on
+ file systems that do not support O_EXCL properly,
+ such as NFS. Do not depend on this option unless you
+ know that the file system supports it (in general, local
+ file systems should be safe).
+
raw
-
The raw option allows faster access to a file,
--
cgit v1.2.3