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(-) 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 From 3f9fd7144dd5598dc55f2e1e071c1db581646314 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Tue, 20 Nov 2012 11:43:50 +0100 Subject: Move ram option from mode() type into open/2 spec The mode() type is used in path_open and copy, two functions that do _not_ accept the ram option (or is at least not supposed to), why I moved the option 'ram' from the type down to the spec for open itself. That also makes the option visible directly under open/2 in the documentation. --- lib/kernel/src/file.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 85426baba1..4f7c984b11 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' | 'ram' + | 'exclusive' | 'raw' | 'binary' | {'delayed_write', Size :: non_neg_integer(), Delay :: non_neg_integer()} @@ -400,7 +400,7 @@ raw_write_file_info(Name, #file_info{} = Info) -> -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. -- cgit v1.2.3