aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2012-12-20 14:58:49 +0100
committerPatrik Nyblom <[email protected]>2012-12-20 14:58:49 +0100
commit2aee2d0511615c921194134b959a57968fa1a12a (patch)
tree9ae554c31583777731e55fe22dc44e2c6dcbb928 /lib
parente69d4d80e0dbb1916fb6900a2b47e0fdf85aea61 (diff)
parent3f9fd7144dd5598dc55f2e1e071c1db581646314 (diff)
downloadotp-2aee2d0511615c921194134b959a57968fa1a12a.tar.gz
otp-2aee2d0511615c921194134b959a57968fa1a12a.tar.bz2
otp-2aee2d0511615c921194134b959a57968fa1a12a.zip
Merge branch 'jd/file-ram-opt-doc'
* jd/file-ram-opt-doc: Move ram option from mode() type into open/2 spec Basic documentation of the 'ram' mode in the 'file' module OTP-10651
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/doc/src/file.xml6
-rw-r--r--lib/kernel/src/file.erl5
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index b2a259080d..89190d8668 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -610,7 +610,7 @@
<name name="open" arity="2"/>
<fsummary>Open a file</fsummary>
<desc>
- <p>Opens the file <c><anno>Filename</anno></c> in the mode determined
+ <p>Opens the file <c><anno>File</anno></c> in the mode determined
by <c><anno>Modes</anno></c>, which may contain one or more of the
following items:</p>
<taglist>
@@ -767,6 +767,10 @@
<p>The Encoding can be changed for a file "on the fly" by using the <seealso marker="stdlib:io#setopts/2">io:setopts/2</seealso> function, why a file can be analyzed in latin1 encoding for i.e. a BOM, positioned beyond the BOM and then be set for the right encoding before further reading.See the <seealso marker="stdlib:unicode">unicode(3)</seealso> module for functions identifying BOM's.</p>
<p>This option is not allowed on <c>raw</c> files.</p>
</item>
+ <tag><c>ram</c></tag>
+ <item>
+ <p><c>File</c> must be <c>iodata()</c>. Returns an <c>fd()</c> which lets the <c>file</c> module operate on the data in-memory as if it is a file.</p>
+ </item>
</taglist>
<p>Returns:</p>
<taglist>
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 22af38c598..4f7c984b11 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -397,9 +397,10 @@ raw_write_file_info(Name, #file_info{} = Info) ->
%% Contemporary mode specification - list of options
--spec open(Filename, Modes) -> {ok, IoDevice} | {error, Reason} when
+-spec open(File, Modes) -> {ok, IoDevice} | {error, Reason} when
+ File :: Filename | iodata(),
Filename :: name(),
- Modes :: [mode()],
+ Modes :: [mode() | ram],
IoDevice :: io_device(),
Reason :: posix() | badarg | system_limit.