@@ -400,6 +400,13 @@ defmodule File do
400400
401401 You can use `:file.format_error/1` to get a descriptive string of the error.
402402
403+ ## Options (since v1.20)
404+
405+ The supported options are:
406+
407+ * `:raw` - a single atom to bypass the file server and only check
408+ for the file locally
409+
403410 ## Examples
404411
405412 File.read("hello.txt")
@@ -408,15 +415,24 @@ defmodule File do
408415 File.read("non_existing.txt")
409416 #=> {:error, :enoent}
410417 """
411- @ spec read ( Path . t ( ) ) :: { :ok , binary } | { :error , posix | :badarg | :terminated | :system_limit }
412- def read ( path ) do
413- :file . read_file ( IO . chardata_to_string ( path ) )
418+ @ spec read ( Path . t ( ) , [ exists_option ] ) ::
419+ { :ok , binary } | { :error , posix | :badarg | :terminated | :system_limit }
420+ when exists_option: :raw
421+ def read ( path , opts \\ [ ] ) do
422+ :file . read_file ( IO . chardata_to_string ( path ) , opts )
414423 end
415424
416425 @ doc """
417426 Returns a binary with the contents of the given filename,
418427 or raises a `File.Error` exception if an error occurs.
419428
429+ ## Options (since v1.20)
430+
431+ The supported options are:
432+
433+ * `:raw` - a single atom to bypass the file server and only check
434+ for the file locally
435+
420436 ## Examples
421437
422438 File.read!("hello.txt")
@@ -425,9 +441,9 @@ defmodule File do
425441 File.read!("non_existing.txt")
426442 ** (File.Error) could not read file "non_existing.txt": no such file or directory
427443 """
428- @ spec read! ( Path . t ( ) ) :: binary
429- def read! ( path ) do
430- case read ( path ) do
444+ @ spec read! ( Path . t ( ) , [ exists_option ] ) :: binary when exists_option: :raw
445+ def read! ( path , opts \\ [ ] ) do
446+ case read ( path , opts ) do
431447 { :ok , binary } ->
432448 binary
433449
0 commit comments