diff options
author | José Valim <[email protected]> | 2014-02-27 12:41:53 +0100 |
---|---|---|
committer | José Valim <[email protected]> | 2014-03-10 16:33:40 -0700 |
commit | b45af5f9608d5dc79a5f201afdcc9a7e28e7ba83 (patch) | |
tree | e29a75437513104f820f3ad84b76fd7cf01fc0af /lib | |
parent | 8acc644e162bad52f7ab81c76c0cad15628e4f3d (diff) | |
download | otp-b45af5f9608d5dc79a5f201afdcc9a7e28e7ba83.tar.gz otp-b45af5f9608d5dc79a5f201afdcc9a7e28e7ba83.tar.bz2 otp-b45af5f9608d5dc79a5f201afdcc9a7e28e7ba83.zip |
Correct file:set_cwd/1 typespec
file:set_cwd/1 accepts binaries as arguments, however the binaries
must be properly encoded as per file:native_name_encoding/0.
Also update the note under no_translation error to refer that passing
a ISO-latin-1 encoded binary under any unicode file name encoding.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/doc/src/file.xml | 9 | ||||
-rw-r--r-- | lib/kernel/src/file.erl | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index 66ecba1bf2..71db9b66bd 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -1622,6 +1622,11 @@ <desc> <p>Sets the current working directory of the file server to <c><anno>Dir</anno></c>. Returns <c>ok</c> if successful.</p> + <p>The functions in the <c>file</c> module usually treat binaries + as raw filenames, i.e. they are passed as is even when the encoding + of the binary does not agree with <c>file:native_name_encoding()</c>. + This function however expects binaries to be encoded according to the + value returned by <c>file:native_name_encoding()</c>.</p> <p>Typical error reasons are:</p> <taglist> <tag><c>enoent</c></tag> @@ -1646,8 +1651,8 @@ <tag><c>no_translation</c></tag> <item> <p><c><anno>Dir</anno></c> is a <c>binary()</c> with - characters coded in ISO-latin-1 and the VM was started - with the parameter <c>+fnue</c>.</p> + characters coded in ISO-latin-1 and the VM is operating + with unicode file name encoding.</p> </item> </taglist> <warning> diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 36289053eb..5467175654 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -197,7 +197,8 @@ get_cwd(Drive) -> check_and_call(get_cwd, [file_name(Drive)]). -spec set_cwd(Dir) -> ok | {error, Reason} when - Dir :: name(), + Dir :: name() | EncodedBinary, + EncodedBinary :: binary(), Reason :: posix() | badarg | no_translation. set_cwd(Dirname) -> |