@@ -23,6 +23,8 @@ defmodule IO do
23
23
24
24
"""
25
25
26
+ import :erlang , only: [ group_leader: 0 ]
27
+
26
28
@ doc """
27
29
Reads `count` bytes from the IO device. It returns:
28
30
@@ -34,7 +36,7 @@ defmodule IO do
34
36
for instance {:error, :estale} if reading from an
35
37
NFS file system.
36
38
"""
37
- def read ( device // :stdio , count ) do
39
+ def read ( device // group_leader ( ) , count ) do
38
40
:io . get_chars ( map_dev ( device ) , "" , count )
39
41
end
40
42
@@ -44,7 +46,7 @@ defmodule IO do
44
46
45
47
Check `read/2` for more information.
46
48
"""
47
- def binread ( device // :stdio , count ) do
49
+ def binread ( device // group_leader ( ) , count ) do
48
50
case :file . read ( map_dev ( device ) , count ) do
49
51
{ :ok , data } -> data
50
52
other -> other
@@ -65,7 +67,7 @@ defmodule IO do
65
67
This function does the same as `gets/2`,
66
68
except the prompt is not required as argument.
67
69
"""
68
- def readline ( device // :stdio ) do
70
+ def readline ( device // group_leader ( ) ) do
69
71
:io . get_line ( map_dev ( device ) , "" )
70
72
end
71
73
@@ -75,7 +77,7 @@ defmodule IO do
75
77
76
78
Check `readline/1` for more information.
77
79
"""
78
- def binreadline ( device // :stdio ) do
80
+ def binreadline ( device // group_leader ( ) ) do
79
81
case :file . read_line ( map_dev ( device ) ) do
80
82
{ :ok , data } -> data
81
83
other -> other
@@ -99,7 +101,7 @@ defmodule IO do
99
101
#=> "error"
100
102
101
103
"""
102
- def write ( device // :stdio , item ) do
104
+ def write ( device // group_leader ( ) , item ) do
103
105
:io . put_chars map_dev ( device ) , to_iodata ( item )
104
106
end
105
107
@@ -109,7 +111,7 @@ defmodule IO do
109
111
110
112
Check `write/2` for more information.
111
113
"""
112
- def binwrite ( device // :stdio , item ) do
114
+ def binwrite ( device // group_leader ( ) , item ) do
113
115
:file . write map_dev ( device ) , to_iodata ( item )
114
116
end
115
117
@@ -118,7 +120,7 @@ defmodule IO do
118
120
but adds a new line at the end. The argument is expected
119
121
to be a chardata.
120
122
"""
121
- def puts ( device // :stdio , item ) do
123
+ def puts ( device // group_leader ( ) , item ) do
122
124
erl_dev = map_dev ( device )
123
125
:io . put_chars erl_dev , [ to_iodata ( item ) , ?\n ]
124
126
end
@@ -127,7 +129,7 @@ defmodule IO do
127
129
Inspects and writes the given argument to the device
128
130
followed by a new line. Returns the item given.
129
131
"""
130
- def inspect ( device // :stdio , item , opts // [ ] ) do
132
+ def inspect ( device // group_leader ( ) , item , opts // [ ] ) do
131
133
puts device , Binary.Inspect . inspect ( item , opts )
132
134
item
133
135
end
@@ -143,7 +145,7 @@ defmodule IO do
143
145
for instance {:error, :estale} if reading from an
144
146
NFS file system.
145
147
"""
146
- def getb ( device // :stdio , prompt , count // 1 ) do
148
+ def getb ( device // group_leader ( ) , prompt , count // 1 ) do
147
149
:io . get_chars ( map_dev ( device ) , to_iodata ( prompt ) , count )
148
150
end
149
151
@@ -159,7 +161,7 @@ defmodule IO do
159
161
for instance {:error, :estale} if reading from an
160
162
NFS file system.
161
163
"""
162
- def gets ( device // :stdio , prompt ) do
164
+ def gets ( device // group_leader ( ) , prompt ) do
163
165
:io . get_line ( map_dev ( device ) , to_iodata ( prompt ) )
164
166
end
165
167
0 commit comments