From d96af2dd3333e8870523402de97f022796c34b5c Mon Sep 17 00:00:00 2001 From: Jan Daniel Bothma Date: Wed, 14 Nov 2012 18:01:07 +0100 Subject: Basic documentation of the 'ram' mode in the 'file' module --- lib/kernel/doc/src/file.xml | 6 +++++- lib/kernel/src/file.erl | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/kernel') 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 @@ Open a file -

Opens the file Filename in the mode determined +

Opens the file File in the mode determined by Modes, which may contain one or more of the following items:

@@ -767,6 +767,10 @@

The Encoding can be changed for a file "on the fly" by using the io:setopts/2 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 unicode(3) module for functions identifying BOM's.

This option is not allowed on raw files.

+ ram + +

File must be iodata(). Returns an fd() which lets the file module operate on the data in-memory as if it is a file.

+

Returns:

diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 22af38c598..85426baba1 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -88,7 +88,7 @@ | {'cur', Offset :: integer()} | {'eof', Offset :: integer()} | 'bof' | 'cur' | 'eof'. -type mode() :: 'read' | 'write' | 'append' - | 'exclusive' | 'raw' | 'binary' + | 'exclusive' | 'raw' | 'binary' | 'ram' | {'delayed_write', Size :: non_neg_integer(), Delay :: non_neg_integer()} @@ -397,7 +397,8 @@ 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()], IoDevice :: io_device(), -- cgit v1.2.3