@@ -59,19 +59,19 @@ defmodule File do
59
59
This module contains functions to manipulate files.
60
60
61
61
Some of those functions are low-level, allowing the user
62
- to interact with the file or IO devices, like `File. open/2`,
63
- `File. copy/3` and others. This module also provides higher
62
+ to interact with the file or IO devices, like `open/2`,
63
+ `copy/3` and others. This module also provides higher
64
64
level functions that works with filenames and have their naming
65
65
based on UNIX variants. For example, one can copy a file
66
- via `File. cp/3` and remove files and directories recursively
67
- via `File. rm_rf/2 `
66
+ via `cp/3` and remove files and directories recursively
67
+ via `rm_rf/1 `
68
68
69
69
In order to write and read files, one must use the functions
70
- in the IO module. By default, a file is opened in binary mode
71
- which requires the functions `IO.binread` and `IO.binwrite`
70
+ in the `IO` module. By default, a file is opened in binary mode
71
+ which requires the functions `IO.binread/2 ` and `IO.binwrite/2 `
72
72
to interact with the file. A developer may pass `:utf8` as an
73
73
option when opening the file and then all other functions
74
- from IO are available, since they work directly with Unicode
74
+ from `IO` are available, since they work directly with Unicode
75
75
data.
76
76
77
77
Most of the functions in this module return `:ok` or
@@ -104,7 +104,7 @@ defmodule File do
104
104
alias :filelib , as: FL
105
105
106
106
@ doc """
107
- Returns true if the path is a regular file.
107
+ Returns ` true` if the path is a regular file.
108
108
109
109
## Examples
110
110
@@ -116,14 +116,14 @@ defmodule File do
116
116
end
117
117
118
118
@ doc """
119
- Returns true if the path is a directory.
119
+ Returns ` true` if the path is a directory.
120
120
"""
121
121
def dir? ( path ) do
122
122
FL . is_dir ( path )
123
123
end
124
124
125
125
@ doc """
126
- Returns true if the given path exists.
126
+ Returns ` true` if the given path exists.
127
127
It can be regular file, directory, socket,
128
128
symbolic link, named pipe or device file.
129
129
@@ -161,7 +161,7 @@ defmodule File do
161
161
end
162
162
163
163
@ doc """
164
- Same as `mkdir`, but raises an exception in case of failure. Otherwise `:ok`.
164
+ Same as `mkdir/1 `, but raises an exception in case of failure. Otherwise `:ok`.
165
165
"""
166
166
def mkdir! ( path ) do
167
167
case mkdir ( path ) do
@@ -186,7 +186,7 @@ defmodule File do
186
186
end
187
187
188
188
@ doc """
189
- Same as `mkdir_p`, but raises an exception in case of failure. Otherwise `:ok`.
189
+ Same as `mkdir_p/1 `, but raises an exception in case of failure. Otherwise `:ok`.
190
190
"""
191
191
def mkdir_p! ( path ) do
192
192
case mkdir_p ( path ) do
@@ -210,15 +210,15 @@ defmodule File do
210
210
On some platforms, `:enoent` is returned instead.
211
211
* :enomem - There is not enough memory for the contents of the file.
212
212
213
- You can use `:file.format_error(reason) ` to get a descriptive string of the error.
213
+ You can use `:file.format_error/1 ` to get a descriptive string of the error.
214
214
"""
215
215
def read ( path ) do
216
216
F . read_file ( path )
217
217
end
218
218
219
219
@ doc """
220
220
Returns binary with the contents of the given filename or raises
221
- File.Error if an error occurs.
221
+ ` File.Error` if an error occurs.
222
222
"""
223
223
def read! ( path ) do
224
224
case read ( path ) do
@@ -233,14 +233,14 @@ defmodule File do
233
233
Returns information about the `path`. If it exists, it
234
234
returns a `{ :ok, info }` tuple, where info is a
235
235
`File.Info` record. Retuns `{ :error, reason }` with
236
- the same reasons as `File. read` if a failure occurs.
236
+ the same reasons as `read/1 ` if a failure occurs.
237
237
238
238
## Options
239
239
240
240
The accepted options are:
241
241
242
- * `:time` if the time should be local, universal or posix.
243
- Default is local.
242
+ * `:time` if the time should be `: local`, `: universal` or `: posix` .
243
+ Default is `: local` .
244
244
245
245
"""
246
246
def stat ( path , opts // [ ] ) do
@@ -253,7 +253,7 @@ defmodule File do
253
253
end
254
254
255
255
@ doc """
256
- Same as `stat` but returns the `File.Stat` directly and
256
+ Same as `stat/2 ` but returns the `File.Stat` directly and
257
257
throws `File.Error` if an error is returned.
258
258
"""
259
259
def stat! ( path , opts // [ ] ) do
@@ -296,7 +296,7 @@ defmodule File do
296
296
end
297
297
298
298
@ doc """
299
- Same as `touch/1 ` but raises an exception if it fails.
299
+ Same as `touch/2 ` but raises an exception if it fails.
300
300
Returns `:ok` otherwise.
301
301
"""
302
302
def touch! ( path , time // :calendar . local_time ) do
@@ -311,7 +311,7 @@ defmodule File do
311
311
Copies the contents of `source` to `destination`.
312
312
313
313
Both parameters can be a filename or an io device opened
314
- with `File. open/2`. `bytes_count` specifies the number of
314
+ with `open/2`. `bytes_count` specifies the number of
315
315
bytes to copy, the default being `:infinity`.
316
316
317
317
If file `destination` already exists, it is overwritten
@@ -320,14 +320,14 @@ defmodule File do
320
320
Returns `{ :ok, bytes_copied }` if successful,
321
321
`{ :error, reason }` otherwise.
322
322
323
- Compared to the `File. cp/3`, this function is more low-level,
323
+ Compared to the `cp/3`, this function is more low-level,
324
324
allowing a copy from device to device limited by a number of
325
- bytes. On the other hand, `File. cp/3` performs more extensive
325
+ bytes. On the other hand, `cp/3` performs more extensive
326
326
checks on both source and destination and it also preserves
327
327
the file mode after copy.
328
328
329
329
Typical error reasons are the same as in `open/2`,
330
- `read/1` and `write/2 `.
330
+ `read/1` and `write/3 `.
331
331
"""
332
332
def copy ( source , destination , bytes_count // :infinity ) do
333
333
F . copy ( source , destination , bytes_count )
@@ -355,15 +355,15 @@ defmodule File do
355
355
copies the contents of `source` to `destination/source`.
356
356
357
357
If a file already exists in the destination, it invokes a
358
- callback which should return true if the existing file
359
- should be overwritten, false otherwise. It defaults to return true.
358
+ callback which should return ` true` if the existing file
359
+ should be overwritten, ` false` otherwise. It defaults to return ` true` .
360
360
361
361
It returns `:ok` in case of success, returns
362
362
`{ :error, reason }` otherwise.
363
363
364
364
If you want to copy contents from an io device to another device
365
365
or do a straight copy from a source to a destination without
366
- preserving modes, check `File. copy/3` instead.
366
+ preserving modes, check `copy/3` instead.
367
367
"""
368
368
def cp ( source , destination , callback // fn ( _ , _ ) -> true end ) do
369
369
output =
@@ -381,7 +381,7 @@ defmodule File do
381
381
end
382
382
383
383
@ doc """
384
- The same as `cp/3`, but raises File.CopyError if it fails.
384
+ The same as `cp/3`, but raises ` File.CopyError` if it fails.
385
385
Returns the list of copied files otherwise.
386
386
"""
387
387
def cp! ( source , destination , callback // fn ( _ , _ ) -> true end ) do
@@ -407,8 +407,8 @@ defmodule File do
407
407
408
408
If a file already exists in the destination,
409
409
it invokes a callback which should return
410
- true if the existing file should be overwritten,
411
- false otherwise. It defaults to return true.
410
+ ` true` if the existing file should be overwritten,
411
+ ` false` otherwise. It defaults to return ` true` .
412
412
413
413
If a directory already exists in the destination
414
414
where a file is meant to be (or otherwise), this
@@ -456,7 +456,7 @@ defmodule File do
456
456
end
457
457
458
458
@ doc """
459
- The same as `cp_r/3`, but raises File.CopyError if it fails.
459
+ The same as `cp_r/3`, but raises ` File.CopyError` if it fails.
460
460
Returns the list of copied files otherwise.
461
461
"""
462
462
def cp_r! ( source , destination , callback // fn ( _ , _ ) -> true end ) do
@@ -607,7 +607,7 @@ defmodule File do
607
607
end
608
608
609
609
@ doc """
610
- Same as `rm`, but raises an exception in case of failure. Otherwise `:ok`.
610
+ Same as `rm/1 `, but raises an exception in case of failure. Otherwise `:ok`.
611
611
"""
612
612
def rm! ( path ) do
613
613
case rm ( path ) do
@@ -724,8 +724,8 @@ defmodule File do
724
724
Opens the given `path` according to the given list of modes.
725
725
726
726
In order to write and read files, one must use the functions
727
- in the IO module. By default, a file is opened in binary mode
728
- which requires the functions `IO.binread` and `IO.binwrite`
727
+ in the `IO` module. By default, a file is opened in binary mode
728
+ which requires the functions `IO.binread/2 ` and `IO.binwrite/2 `
729
729
to interact with the file. A developer may pass `:utf8` as an
730
730
option when opening the file and then all other functions from
731
731
`IO` are available, since they work directly with Unicode data.
@@ -758,8 +758,8 @@ defmodule File do
758
758
759
759
If a function is given to modes (instead of a list), it dispatches to `open/3`.
760
760
761
- Check ` http://www.erlang.org/doc/man/file.html#open-2` for more information about
762
- other options as `read_ahead` and `delayed_write`.
761
+ Check http://www.erlang.org/doc/man/file.html#open-2 for more information about
762
+ other options like `read_ahead` and `delayed_write`.
763
763
764
764
This function returns:
765
765
@@ -879,7 +879,7 @@ defmodule File do
879
879
end
880
880
881
881
@ doc """
882
- The same as `cd/0 `, but raises an exception if it fails.
882
+ The same as `cd/1 `, but raises an exception if it fails.
883
883
"""
884
884
def cd! ( path ) do
885
885
case F . set_cwd ( path ) do
@@ -964,7 +964,7 @@ defmodule File do
964
964
@ doc """
965
965
Opens the given `file` with the given `mode` and
966
966
returns its binstream. The returned stream will
967
- fail for the same reasons as `File. open!`. Note
967
+ fail for the same reasons as `open!/2 `. Note
968
968
that the file is opened when the iteration begins.
969
969
"""
970
970
def binstream! ( file , mode // [ ] ) do
0 commit comments