@@ -34,83 +34,87 @@ package object fs {
34
34
35
35
/**
36
36
* File System Extensions
37
- * @param fs the given [[Fs file system ]] instance
37
+ * @param instance the given [[Fs file system ]] instance
38
38
*/
39
- implicit final class FsExtensions (private val fs : Fs ) extends AnyVal {
39
+ implicit final class FsExtensions (private val instance : Fs ) extends AnyVal {
40
+ @ deprecated(" Use Fs directly instead of Fs.fs" , " 0.9.0" )
41
+ @ inline
42
+ def fs : Fs = instance
43
+
40
44
@ inline
41
45
def accessFuture (path : Buffer | String ): Future [Unit ] = {
42
- promiseWithError0[FileIOError ](fs .access(path, _))
46
+ promiseWithError0[FileIOError ](instance .access(path, _))
43
47
}
44
48
45
49
@ inline
46
50
def accessFuture (path : Buffer | String , mode : FileMode ): Future [Unit ] = {
47
- promiseWithError0[FileIOError ](fs .access(path, mode, _))
51
+ promiseWithError0[FileIOError ](instance .access(path, mode, _))
48
52
}
49
53
50
54
@ inline
51
55
def appendFileFuture (file : Buffer | FileDescriptor | String ,
52
56
data : Buffer | String ,
53
57
options : FileAppendOptions = null ): Future [Unit ] = {
54
- promiseWithError0[FileIOError ](fs .appendFile(file, data, options, _))
58
+ promiseWithError0[FileIOError ](instance .appendFile(file, data, options, _))
55
59
}
56
60
57
61
@ inline
58
62
def chmodFuture (path : Buffer | String , mode : FileMode , callback : js.Function1 [FileIOError , Any ]): Future [Unit ] = {
59
- promiseWithError0[FileIOError ](fs .chmod(path, mode, _))
63
+ promiseWithError0[FileIOError ](instance .chmod(path, mode, _))
60
64
}
61
65
62
66
@ inline
63
- def closeFuture (fd : FileDescriptor ): Future [Unit ] = promiseWithError0[FileIOError ](fs .close(fd, _))
67
+ def closeFuture (fd : FileDescriptor ): Future [Unit ] = promiseWithError0[FileIOError ](instance .close(fd, _))
64
68
65
69
@ inline
66
- def existsFuture (path : String ): Future [Boolean ] = promiseWithErrorAsBoolean[FileIOError ](fs .access(path, _))
70
+ def existsFuture (path : String ): Future [Boolean ] = promiseWithErrorAsBoolean[FileIOError ](instance .access(path, _))
67
71
68
72
@ inline
69
- def fdatasyncFuture (fd : FileDescriptor ): Future [Unit ] = promiseWithError0[FileIOError ](fs .fdatasync(fd, _))
73
+ def fdatasyncFuture (fd : FileDescriptor ): Future [Unit ] = promiseWithError0[FileIOError ](instance .fdatasync(fd, _))
70
74
71
75
@ inline
72
76
def futimesFuture (fd : FileDescriptor , atime : Time , mtime : Time ): Future [Unit ] = {
73
- promiseWithError0[FileIOError ](fs .futimes(fd, atime, mtime, _))
77
+ promiseWithError0[FileIOError ](instance .futimes(fd, atime, mtime, _))
74
78
}
75
79
76
80
@ inline
77
81
def lchmodFuture (path : Buffer | String , mode : FileMode ): Future [Unit ] = {
78
- promiseWithError0[FileIOError ](fs .lchmod(path, mode, _))
82
+ promiseWithError0[FileIOError ](instance .lchmod(path, mode, _))
79
83
}
80
84
81
85
@ inline
82
86
def lchownFuture (path : Buffer | String , uid : UID , gid : GID ): Future [Unit ] = {
83
- promiseWithError0[FileIOError ](fs .lchown(path, uid, gid, _))
87
+ promiseWithError0[FileIOError ](instance .lchown(path, uid, gid, _))
84
88
}
85
89
86
90
@ inline
87
91
def linkFuture (srcpath : Buffer | String , dstpath : Buffer | String ): Future [Unit ] = {
88
- promiseWithError0[FileIOError ](fs .link(srcpath, dstpath, _))
92
+ promiseWithError0[FileIOError ](instance .link(srcpath, dstpath, _))
89
93
}
90
94
91
95
@ inline
92
96
def mkdirFuture (path : Buffer | String , mode : FileMode ): Future [Unit ] = {
93
- promiseWithError0[FileIOError ](fs .mkdir(path, mode, _))
97
+ promiseWithError0[FileIOError ](instance .mkdir(path, mode, _))
94
98
}
95
99
96
100
@ inline
97
101
def mkdirFuture (path : Buffer | String ): Future [Unit ] = {
98
- promiseWithError0[FileIOError ](fs .mkdir(path, _))
102
+ promiseWithError0[FileIOError ](instance .mkdir(path, _))
99
103
}
100
104
101
105
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs10)
102
106
@ inline
103
107
def mkdirFuture (path : Buffer | String , options : MkdirOptions ): Future [Unit ] = {
104
- promiseWithError0[FileIOError ](fs .mkdir(path, options, _))
108
+ promiseWithError0[FileIOError ](instance .mkdir(path, options, _))
105
109
}
106
110
107
111
@ inline
108
112
def openFuture (path : Buffer | String , flags : Flags , mode : FileMode ): Future [FileDescriptor ] = {
109
- promiseWithError1[FileIOError , FileDescriptor ](fs .open(path, flags, mode, _))
113
+ promiseWithError1[FileIOError , FileDescriptor ](instance .open(path, flags, mode, _))
110
114
}
111
115
@ inline
112
116
def openFuture (path : Buffer | String , flags : Flags ): Future [FileDescriptor ] = {
113
- promiseWithError1[FileIOError , FileDescriptor ](fs .open(path, flags, _))
117
+ promiseWithError1[FileIOError , FileDescriptor ](instance .open(path, flags, _))
114
118
}
115
119
116
120
@ inline
@@ -125,15 +129,15 @@ package object fs {
125
129
@ inline
126
130
def readdirFuture (path : Buffer | String , options : String = " utf8" ): Future [js.Array [String ]] = {
127
131
val callback : FsCallback1 [js.Array [String ]] => Unit = { callback =>
128
- fs .readdir(path, options, callback.asInstanceOf [FsCallback1 [ReaddirArrays ]])
132
+ instance .readdir(path, options, callback.asInstanceOf [FsCallback1 [ReaddirArrays ]])
129
133
}
130
134
promiseWithError1[FileIOError , js.Array [String ]](callback)
131
135
}
132
136
133
137
@ inline
134
138
def readdirBufferFuture (path : Buffer | String ): Future [js.Array [Buffer ]] = {
135
139
val callback : FsCallback1 [js.Array [Buffer ]] => Unit = { callback =>
136
- fs .readdir(
140
+ instance .readdir(
137
141
path,
138
142
new FileEncodingOptions (encoding = " buffer" ),
139
143
callback.asInstanceOf [FsCallback1 [ReaddirArrays ]]
@@ -146,61 +150,65 @@ package object fs {
146
150
@ inline
147
151
def readdirDirentFuture (path : Buffer | String ): Future [js.Array [Dirent ]] = {
148
152
val callback : FsCallback1 [js.Array [Dirent ]] => Unit = { callback =>
149
- fs.readdir(path, new ReaddirOptions (withFileTypes = true ), callback.asInstanceOf [FsCallback1 [ReaddirArrays2 ]])
153
+ instance.readdir(
154
+ path,
155
+ new ReaddirOptions (withFileTypes = true ),
156
+ callback.asInstanceOf [FsCallback1 [ReaddirArrays2 ]]
157
+ )
150
158
}
151
159
promiseWithError1[FileIOError , js.Array [Dirent ]](callback)
152
160
}
153
161
154
162
@ inline
155
163
def readFileFuture (file : String , options : ReadFileOptions = null ): Future [Output ] = {
156
- promiseWithError1[FileIOError , Output ](fs .readFile(file, options, _))
164
+ promiseWithError1[FileIOError , Output ](instance .readFile(file, options, _))
157
165
}
158
166
159
167
@ inline
160
168
def renameFuture (oldPath : String , newPath : String ): Future [Unit ] = {
161
- promiseWithError0[FileIOError ](fs .rename(oldPath, newPath, _))
169
+ promiseWithError0[FileIOError ](instance .rename(oldPath, newPath, _))
162
170
}
163
171
164
172
@ inline
165
173
def realpathFuture (path : String ): Future [String ] = {
166
- promiseWithError1[FileIOError , String ](fs .realpath(path, _))
174
+ promiseWithError1[FileIOError , String ](instance .realpath(path, _))
167
175
}
168
176
169
177
@ inline
170
178
def realpathFuture (path : String , options : FileEncodingOptions ): Future [Output ] = {
171
- promiseWithError1[FileIOError , Output ](fs .realpath(path, options, _))
179
+ promiseWithError1[FileIOError , Output ](instance .realpath(path, options, _))
172
180
}
173
181
174
182
@ inline
175
- def rmdirFuture (path : Buffer | String ): Future [Unit ] = promiseWithError0[FileIOError ](fs .rmdir(path, _))
183
+ def rmdirFuture (path : Buffer | String ): Future [Unit ] = promiseWithError0[FileIOError ](instance .rmdir(path, _))
176
184
177
185
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
178
186
@ inline
179
187
def rmdirFuture (path : Buffer | String , options : RmdirOptions ): Future [Unit ] =
180
- promiseWithError0[FileIOError ](fs .rmdir(path, options, _))
188
+ promiseWithError0[FileIOError ](instance .rmdir(path, options, _))
181
189
182
190
@ inline
183
- def statFuture (path : String ): Future [Stats ] = promiseWithError1[FileIOError , Stats ](fs .stat(path, _))
191
+ def statFuture (path : String ): Future [Stats ] = promiseWithError1[FileIOError , Stats ](instance .stat(path, _))
184
192
185
193
@ inline
186
194
def symlinkFuture (target : Buffer | String , path : Buffer | String , `type` : String = null ): Future [Unit ] = {
187
- promiseWithError0[FileIOError ](fs .symlink(target, path, `type`, _))
195
+ promiseWithError0[FileIOError ](instance .symlink(target, path, `type`, _))
188
196
}
189
197
190
198
@ inline
191
- def unlinkFuture (path : Buffer | String ): Future [Unit ] = promiseWithError0[FileIOError ](fs .unlink(path, _))
199
+ def unlinkFuture (path : Buffer | String ): Future [Unit ] = promiseWithError0[FileIOError ](instance .unlink(path, _))
192
200
193
201
@ inline
194
202
def unwatchFileFuture (filename : Buffer | String ): Future [Unit ] =
195
- promiseWithError0[FileIOError ](fs .unwatchFile(filename, _))
203
+ promiseWithError0[FileIOError ](instance .unwatchFile(filename, _))
196
204
197
205
@ inline
198
206
def utimesFuture (path : Buffer | String , atime : Int , mtime : Int ): Future [Unit ] =
199
- promiseWithError0[FileIOError ](fs .utimes(path, atime, mtime, _))
207
+ promiseWithError0[FileIOError ](instance .utimes(path, atime, mtime, _))
200
208
201
209
@ inline
202
210
def watchFuture (filename : String , options : FSWatcherOptions = null ): Future [(String , String )] = {
203
- promiseCallback2[String , String ](fs .watch(filename, options, _))
211
+ promiseCallback2[String , String ](instance .watch(filename, options, _))
204
212
}
205
213
206
214
@ inline
@@ -209,37 +217,37 @@ package object fs {
209
217
offset : Int | Null = null ,
210
218
length : Int | Null = null ,
211
219
position : Int | Null = null ): Future [(FileType , Buffer )] = {
212
- promiseWithError2[FileIOError , Int , Buffer ](fs .write(fd, buffer, offset, length, position, _))
220
+ promiseWithError2[FileIOError , Int , Buffer ](instance .write(fd, buffer, offset, length, position, _))
213
221
}
214
222
215
223
@ inline
216
224
def writeFuture (fd : FileDescriptor , string : String , position : Int , encoding : String ): Future [(FileType , String )] = {
217
- promiseWithError2[FileIOError , Int , String ](fs .write(fd, string, position, encoding, _))
225
+ promiseWithError2[FileIOError , Int , String ](instance .write(fd, string, position, encoding, _))
218
226
}
219
227
220
228
@ inline
221
229
def writeFuture (fd : FileDescriptor , string : String , position : Int ): Future [(FileType , String )] = {
222
- promiseWithError2[FileIOError , Int , String ](fs .write(fd, string, position, null , _))
230
+ promiseWithError2[FileIOError , Int , String ](instance .write(fd, string, position, null , _))
223
231
}
224
232
225
233
@ inline
226
234
def writeFuture (fd : FileDescriptor , string : String ): Future [(FileType , String )] = {
227
- promiseWithError2[FileIOError , Int , String ](fs .write(fd, string, _))
235
+ promiseWithError2[FileIOError , Int , String ](instance .write(fd, string, _))
228
236
}
229
237
230
238
@ inline
231
239
def writeFileFuture (file : String , data : Buffer , options : FileWriteOptions = null ): Future [Unit ] = {
232
- promiseWithError0[FileIOError ](fs .writeFile(file, data, options, _))
240
+ promiseWithError0[FileIOError ](instance .writeFile(file, data, options, _))
233
241
}
234
242
235
243
@ inline
236
244
def writeFileFuture (file : String , data : String , options : FileWriteOptions ): Future [Unit ] = {
237
- promiseWithError0[FileIOError ](fs .writeFile(file, data, options, _))
245
+ promiseWithError0[FileIOError ](instance .writeFile(file, data, options, _))
238
246
}
239
247
240
248
@ inline
241
249
def writeFileFuture (file : String , data : String ): Future [Unit ] = {
242
- promiseWithError0[FileIOError ](fs .writeFile(file, data, _))
250
+ promiseWithError0[FileIOError ](instance .writeFile(file, data, _))
243
251
}
244
252
}
245
253
0 commit comments