5
<title>File System Node.js v0.10.15 Manual & Documentation</title>
6
<link rel="stylesheet" href="assets/style.css">
7
<link rel="stylesheet" href="assets/sh.css">
8
<link rel="canonical" href="http://nodejs.org/api/fs.html">
10
<body class="alt apidoc" id="api-section-fs">
11
<div id="intro" class="interior">
12
<a href="/" title="Go back to the home page">
13
<img id="logo" src="http://nodejs.org/images/logo-light.png" alt="node.js">
16
<div id="content" class="clearfix">
17
<div id="column2" class="interior">
19
<li><a href="/" class="home">Home</a></li>
20
<li><a href="/download/" class="download">Download</a></li>
21
<li><a href="/about/" class="about">About</a></li>
22
<li><a href="http://npmjs.org/" class="npm">npm Registry</a></li>
23
<li><a href="http://nodejs.org/api/" class="docs current">Docs</a></li>
24
<li><a href="http://blog.nodejs.org" class="blog">Blog</a></li>
25
<li><a href="/community/" class="community">Community</a></li>
26
<li><a href="/logos/" class="logos">Logos</a></li>
27
<li><a href="http://jobs.nodejs.org/" class="jobs">Jobs</a></li>
29
<p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
32
<div id="column1" class="interior">
34
<h1>Node.js v0.10.15 Manual & Documentation</h1>
37
<a href="index.html" name="toc">Index</a> |
38
<a href="all.html">View on single page</a> |
39
<a href="fs.json">View as JSON</a>
46
<h2>Table of Contents</h2>
48
<li><a href="#fs_file_system">File System</a><ul>
49
<li><a href="#fs_fs_rename_oldpath_newpath_callback">fs.rename(oldPath, newPath, callback)</a></li>
50
<li><a href="#fs_fs_renamesync_oldpath_newpath">fs.renameSync(oldPath, newPath)</a></li>
51
<li><a href="#fs_fs_ftruncate_fd_len_callback">fs.ftruncate(fd, len, callback)</a></li>
52
<li><a href="#fs_fs_ftruncatesync_fd_len">fs.ftruncateSync(fd, len)</a></li>
53
<li><a href="#fs_fs_truncate_path_len_callback">fs.truncate(path, len, callback)</a></li>
54
<li><a href="#fs_fs_truncatesync_path_len">fs.truncateSync(path, len)</a></li>
55
<li><a href="#fs_fs_chown_path_uid_gid_callback">fs.chown(path, uid, gid, callback)</a></li>
56
<li><a href="#fs_fs_chownsync_path_uid_gid">fs.chownSync(path, uid, gid)</a></li>
57
<li><a href="#fs_fs_fchown_fd_uid_gid_callback">fs.fchown(fd, uid, gid, callback)</a></li>
58
<li><a href="#fs_fs_fchownsync_fd_uid_gid">fs.fchownSync(fd, uid, gid)</a></li>
59
<li><a href="#fs_fs_lchown_path_uid_gid_callback">fs.lchown(path, uid, gid, callback)</a></li>
60
<li><a href="#fs_fs_lchownsync_path_uid_gid">fs.lchownSync(path, uid, gid)</a></li>
61
<li><a href="#fs_fs_chmod_path_mode_callback">fs.chmod(path, mode, callback)</a></li>
62
<li><a href="#fs_fs_chmodsync_path_mode">fs.chmodSync(path, mode)</a></li>
63
<li><a href="#fs_fs_fchmod_fd_mode_callback">fs.fchmod(fd, mode, callback)</a></li>
64
<li><a href="#fs_fs_fchmodsync_fd_mode">fs.fchmodSync(fd, mode)</a></li>
65
<li><a href="#fs_fs_lchmod_path_mode_callback">fs.lchmod(path, mode, callback)</a></li>
66
<li><a href="#fs_fs_lchmodsync_path_mode">fs.lchmodSync(path, mode)</a></li>
67
<li><a href="#fs_fs_stat_path_callback">fs.stat(path, callback)</a></li>
68
<li><a href="#fs_fs_lstat_path_callback">fs.lstat(path, callback)</a></li>
69
<li><a href="#fs_fs_fstat_fd_callback">fs.fstat(fd, callback)</a></li>
70
<li><a href="#fs_fs_statsync_path">fs.statSync(path)</a></li>
71
<li><a href="#fs_fs_lstatsync_path">fs.lstatSync(path)</a></li>
72
<li><a href="#fs_fs_fstatsync_fd">fs.fstatSync(fd)</a></li>
73
<li><a href="#fs_fs_link_srcpath_dstpath_callback">fs.link(srcpath, dstpath, callback)</a></li>
74
<li><a href="#fs_fs_linksync_srcpath_dstpath">fs.linkSync(srcpath, dstpath)</a></li>
75
<li><a href="#fs_fs_symlink_srcpath_dstpath_type_callback">fs.symlink(srcpath, dstpath, [type], callback)</a></li>
76
<li><a href="#fs_fs_symlinksync_srcpath_dstpath_type">fs.symlinkSync(srcpath, dstpath, [type])</a></li>
77
<li><a href="#fs_fs_readlink_path_callback">fs.readlink(path, callback)</a></li>
78
<li><a href="#fs_fs_readlinksync_path">fs.readlinkSync(path)</a></li>
79
<li><a href="#fs_fs_realpath_path_cache_callback">fs.realpath(path, [cache], callback)</a></li>
80
<li><a href="#fs_fs_realpathsync_path_cache">fs.realpathSync(path, [cache])</a></li>
81
<li><a href="#fs_fs_unlink_path_callback">fs.unlink(path, callback)</a></li>
82
<li><a href="#fs_fs_unlinksync_path">fs.unlinkSync(path)</a></li>
83
<li><a href="#fs_fs_rmdir_path_callback">fs.rmdir(path, callback)</a></li>
84
<li><a href="#fs_fs_rmdirsync_path">fs.rmdirSync(path)</a></li>
85
<li><a href="#fs_fs_mkdir_path_mode_callback">fs.mkdir(path, [mode], callback)</a></li>
86
<li><a href="#fs_fs_mkdirsync_path_mode">fs.mkdirSync(path, [mode])</a></li>
87
<li><a href="#fs_fs_readdir_path_callback">fs.readdir(path, callback)</a></li>
88
<li><a href="#fs_fs_readdirsync_path">fs.readdirSync(path)</a></li>
89
<li><a href="#fs_fs_close_fd_callback">fs.close(fd, callback)</a></li>
90
<li><a href="#fs_fs_closesync_fd">fs.closeSync(fd)</a></li>
91
<li><a href="#fs_fs_open_path_flags_mode_callback">fs.open(path, flags, [mode], callback)</a></li>
92
<li><a href="#fs_fs_opensync_path_flags_mode">fs.openSync(path, flags, [mode])</a></li>
93
<li><a href="#fs_fs_utimes_path_atime_mtime_callback">fs.utimes(path, atime, mtime, callback)</a></li>
94
<li><a href="#fs_fs_utimessync_path_atime_mtime">fs.utimesSync(path, atime, mtime)</a></li>
95
<li><a href="#fs_fs_futimes_fd_atime_mtime_callback">fs.futimes(fd, atime, mtime, callback)</a></li>
96
<li><a href="#fs_fs_futimessync_fd_atime_mtime">fs.futimesSync(fd, atime, mtime)</a></li>
97
<li><a href="#fs_fs_fsync_fd_callback">fs.fsync(fd, callback)</a></li>
98
<li><a href="#fs_fs_fsyncsync_fd">fs.fsyncSync(fd)</a></li>
99
<li><a href="#fs_fs_write_fd_buffer_offset_length_position_callback">fs.write(fd, buffer, offset, length, position, callback)</a></li>
100
<li><a href="#fs_fs_writesync_fd_buffer_offset_length_position">fs.writeSync(fd, buffer, offset, length, position)</a></li>
101
<li><a href="#fs_fs_read_fd_buffer_offset_length_position_callback">fs.read(fd, buffer, offset, length, position, callback)</a></li>
102
<li><a href="#fs_fs_readsync_fd_buffer_offset_length_position">fs.readSync(fd, buffer, offset, length, position)</a></li>
103
<li><a href="#fs_fs_readfile_filename_options_callback">fs.readFile(filename, [options], callback)</a></li>
104
<li><a href="#fs_fs_readfilesync_filename_options">fs.readFileSync(filename, [options])</a></li>
105
<li><a href="#fs_fs_writefile_filename_data_options_callback">fs.writeFile(filename, data, [options], callback)</a></li>
106
<li><a href="#fs_fs_writefilesync_filename_data_options">fs.writeFileSync(filename, data, [options])</a></li>
107
<li><a href="#fs_fs_appendfile_filename_data_options_callback">fs.appendFile(filename, data, [options], callback)</a></li>
108
<li><a href="#fs_fs_appendfilesync_filename_data_options">fs.appendFileSync(filename, data, [options])</a></li>
109
<li><a href="#fs_fs_watchfile_filename_options_listener">fs.watchFile(filename, [options], listener)</a></li>
110
<li><a href="#fs_fs_unwatchfile_filename_listener">fs.unwatchFile(filename, [listener])</a></li>
111
<li><a href="#fs_fs_watch_filename_options_listener">fs.watch(filename, [options], [listener])</a><ul>
112
<li><a href="#fs_caveats">Caveats</a><ul>
113
<li><a href="#fs_availability">Availability</a></li>
114
<li><a href="#fs_filename_argument">Filename Argument</a></li>
119
<li><a href="#fs_fs_exists_path_callback">fs.exists(path, callback)</a></li>
120
<li><a href="#fs_fs_existssync_path">fs.existsSync(path)</a></li>
121
<li><a href="#fs_class_fs_stats">Class: fs.Stats</a></li>
122
<li><a href="#fs_fs_createreadstream_path_options">fs.createReadStream(path, [options])</a></li>
123
<li><a href="#fs_class_fs_readstream">Class: fs.ReadStream</a><ul>
124
<li><a href="#fs_event_open">Event: 'open'</a></li>
127
<li><a href="#fs_fs_createwritestream_path_options">fs.createWriteStream(path, [options])</a></li>
128
<li><a href="#fs_class_fs_writestream">Class: fs.WriteStream</a><ul>
129
<li><a href="#fs_event_open_1">Event: 'open'</a></li>
130
<li><a href="#fs_file_byteswritten">file.bytesWritten</a></li>
133
<li><a href="#fs_class_fs_fswatcher">Class: fs.FSWatcher</a><ul>
134
<li><a href="#fs_watcher_close">watcher.close()</a></li>
135
<li><a href="#fs_event_change">Event: 'change'</a></li>
136
<li><a href="#fs_event_error">Event: 'error'</a></li>
145
<div id="apicontent">
146
<h1>File System<span><a class="mark" href="#fs_file_system" id="fs_file_system">#</a></span></h1>
147
<pre class="api_stability_3">Stability: 3 - Stable</pre><!--name=fs-->
149
<p>File I/O is provided by simple wrappers around standard POSIX functions. To
150
use this module do <code>require('fs')</code>. All the methods have asynchronous and
154
<p>The asynchronous form always take a completion callback as its last argument.
155
The arguments passed to the completion callback depend on the method, but the
156
first argument is always reserved for an exception. If the operation was
157
completed successfully, then the first argument will be <code>null</code> or <code>undefined</code>.
160
<p>When using the synchronous form any exceptions are immediately thrown.
161
You can use try/catch to handle exceptions or allow them to bubble up.
164
<p>Here is an example of the asynchronous version:
167
<pre><code>var fs = require('fs');
169
fs.unlink('/tmp/hello', function (err) {
171
console.log('successfully deleted /tmp/hello');
173
<p>Here is the synchronous version:
176
<pre><code>var fs = require('fs');
178
fs.unlinkSync('/tmp/hello')
179
console.log('successfully deleted /tmp/hello');</code></pre>
180
<p>With the asynchronous methods there is no guaranteed ordering. So the
181
following is prone to error:
184
<pre><code>fs.rename('/tmp/hello', '/tmp/world', function (err) {
186
console.log('renamed complete');
188
fs.stat('/tmp/world', function (err, stats) {
190
console.log('stats: ' + JSON.stringify(stats));
192
<p>It could be that <code>fs.stat</code> is executed before <code>fs.rename</code>.
193
The correct way to do this is to chain the callbacks.
196
<pre><code>fs.rename('/tmp/hello', '/tmp/world', function (err) {
198
fs.stat('/tmp/world', function (err, stats) {
200
console.log('stats: ' + JSON.stringify(stats));
203
<p>In busy processes, the programmer is <em>strongly encouraged</em> to use the
204
asynchronous versions of these calls. The synchronous versions will block
205
the entire process until they complete--halting all connections.
208
<p>Relative path to filename can be used, remember however that this path will be
209
relative to <code>process.cwd()</code>.
212
<p>Most fs functions let you omit the callback argument. If you do, a default
213
callback is used that ignores errors, but prints a deprecation
217
<p><strong>IMPORTANT</strong>: Omitting the callback is deprecated. v0.12 will throw the
218
errors as exceptions.
222
<h2>fs.rename(oldPath, newPath, callback)<span><a class="mark" href="#fs_fs_rename_oldpath_newpath_callback" id="fs_fs_rename_oldpath_newpath_callback">#</a></span></h2>
223
<p>Asynchronous rename(2). No arguments other than a possible exception are given
224
to the completion callback.
227
<h2>fs.renameSync(oldPath, newPath)<span><a class="mark" href="#fs_fs_renamesync_oldpath_newpath" id="fs_fs_renamesync_oldpath_newpath">#</a></span></h2>
228
<p>Synchronous rename(2).
231
<h2>fs.ftruncate(fd, len, callback)<span><a class="mark" href="#fs_fs_ftruncate_fd_len_callback" id="fs_fs_ftruncate_fd_len_callback">#</a></span></h2>
232
<p>Asynchronous ftruncate(2). No arguments other than a possible exception are
233
given to the completion callback.
236
<h2>fs.ftruncateSync(fd, len)<span><a class="mark" href="#fs_fs_ftruncatesync_fd_len" id="fs_fs_ftruncatesync_fd_len">#</a></span></h2>
237
<p>Synchronous ftruncate(2).
240
<h2>fs.truncate(path, len, callback)<span><a class="mark" href="#fs_fs_truncate_path_len_callback" id="fs_fs_truncate_path_len_callback">#</a></span></h2>
241
<p>Asynchronous truncate(2). No arguments other than a possible exception are
242
given to the completion callback.
245
<h2>fs.truncateSync(path, len)<span><a class="mark" href="#fs_fs_truncatesync_path_len" id="fs_fs_truncatesync_path_len">#</a></span></h2>
246
<p>Synchronous truncate(2).
249
<h2>fs.chown(path, uid, gid, callback)<span><a class="mark" href="#fs_fs_chown_path_uid_gid_callback" id="fs_fs_chown_path_uid_gid_callback">#</a></span></h2>
250
<p>Asynchronous chown(2). No arguments other than a possible exception are given
251
to the completion callback.
254
<h2>fs.chownSync(path, uid, gid)<span><a class="mark" href="#fs_fs_chownsync_path_uid_gid" id="fs_fs_chownsync_path_uid_gid">#</a></span></h2>
255
<p>Synchronous chown(2).
258
<h2>fs.fchown(fd, uid, gid, callback)<span><a class="mark" href="#fs_fs_fchown_fd_uid_gid_callback" id="fs_fs_fchown_fd_uid_gid_callback">#</a></span></h2>
259
<p>Asynchronous fchown(2). No arguments other than a possible exception are given
260
to the completion callback.
263
<h2>fs.fchownSync(fd, uid, gid)<span><a class="mark" href="#fs_fs_fchownsync_fd_uid_gid" id="fs_fs_fchownsync_fd_uid_gid">#</a></span></h2>
264
<p>Synchronous fchown(2).
267
<h2>fs.lchown(path, uid, gid, callback)<span><a class="mark" href="#fs_fs_lchown_path_uid_gid_callback" id="fs_fs_lchown_path_uid_gid_callback">#</a></span></h2>
268
<p>Asynchronous lchown(2). No arguments other than a possible exception are given
269
to the completion callback.
272
<h2>fs.lchownSync(path, uid, gid)<span><a class="mark" href="#fs_fs_lchownsync_path_uid_gid" id="fs_fs_lchownsync_path_uid_gid">#</a></span></h2>
273
<p>Synchronous lchown(2).
276
<h2>fs.chmod(path, mode, callback)<span><a class="mark" href="#fs_fs_chmod_path_mode_callback" id="fs_fs_chmod_path_mode_callback">#</a></span></h2>
277
<p>Asynchronous chmod(2). No arguments other than a possible exception are given
278
to the completion callback.
281
<h2>fs.chmodSync(path, mode)<span><a class="mark" href="#fs_fs_chmodsync_path_mode" id="fs_fs_chmodsync_path_mode">#</a></span></h2>
282
<p>Synchronous chmod(2).
285
<h2>fs.fchmod(fd, mode, callback)<span><a class="mark" href="#fs_fs_fchmod_fd_mode_callback" id="fs_fs_fchmod_fd_mode_callback">#</a></span></h2>
286
<p>Asynchronous fchmod(2). No arguments other than a possible exception
287
are given to the completion callback.
290
<h2>fs.fchmodSync(fd, mode)<span><a class="mark" href="#fs_fs_fchmodsync_fd_mode" id="fs_fs_fchmodsync_fd_mode">#</a></span></h2>
291
<p>Synchronous fchmod(2).
294
<h2>fs.lchmod(path, mode, callback)<span><a class="mark" href="#fs_fs_lchmod_path_mode_callback" id="fs_fs_lchmod_path_mode_callback">#</a></span></h2>
295
<p>Asynchronous lchmod(2). No arguments other than a possible exception
296
are given to the completion callback.
299
<p>Only available on Mac OS X.
302
<h2>fs.lchmodSync(path, mode)<span><a class="mark" href="#fs_fs_lchmodsync_path_mode" id="fs_fs_lchmodsync_path_mode">#</a></span></h2>
303
<p>Synchronous lchmod(2).
306
<h2>fs.stat(path, callback)<span><a class="mark" href="#fs_fs_stat_path_callback" id="fs_fs_stat_path_callback">#</a></span></h2>
307
<p>Asynchronous stat(2). The callback gets two arguments <code>(err, stats)</code> where
308
<code>stats</code> is a <a href="#fs_class_fs_stats">fs.Stats</a> object. See the <a href="#fs_class_fs_stats">fs.Stats</a>
309
section below for more information.
312
<h2>fs.lstat(path, callback)<span><a class="mark" href="#fs_fs_lstat_path_callback" id="fs_fs_lstat_path_callback">#</a></span></h2>
313
<p>Asynchronous lstat(2). The callback gets two arguments <code>(err, stats)</code> where
314
<code>stats</code> is a <code>fs.Stats</code> object. <code>lstat()</code> is identical to <code>stat()</code>, except that if
315
<code>path</code> is a symbolic link, then the link itself is stat-ed, not the file that it
319
<h2>fs.fstat(fd, callback)<span><a class="mark" href="#fs_fs_fstat_fd_callback" id="fs_fs_fstat_fd_callback">#</a></span></h2>
320
<p>Asynchronous fstat(2). The callback gets two arguments <code>(err, stats)</code> where
321
<code>stats</code> is a <code>fs.Stats</code> object. <code>fstat()</code> is identical to <code>stat()</code>, except that
322
the file to be stat-ed is specified by the file descriptor <code>fd</code>.
325
<h2>fs.statSync(path)<span><a class="mark" href="#fs_fs_statsync_path" id="fs_fs_statsync_path">#</a></span></h2>
326
<p>Synchronous stat(2). Returns an instance of <code>fs.Stats</code>.
329
<h2>fs.lstatSync(path)<span><a class="mark" href="#fs_fs_lstatsync_path" id="fs_fs_lstatsync_path">#</a></span></h2>
330
<p>Synchronous lstat(2). Returns an instance of <code>fs.Stats</code>.
333
<h2>fs.fstatSync(fd)<span><a class="mark" href="#fs_fs_fstatsync_fd" id="fs_fs_fstatsync_fd">#</a></span></h2>
334
<p>Synchronous fstat(2). Returns an instance of <code>fs.Stats</code>.
337
<h2>fs.link(srcpath, dstpath, callback)<span><a class="mark" href="#fs_fs_link_srcpath_dstpath_callback" id="fs_fs_link_srcpath_dstpath_callback">#</a></span></h2>
338
<p>Asynchronous link(2). No arguments other than a possible exception are given to
339
the completion callback.
342
<h2>fs.linkSync(srcpath, dstpath)<span><a class="mark" href="#fs_fs_linksync_srcpath_dstpath" id="fs_fs_linksync_srcpath_dstpath">#</a></span></h2>
343
<p>Synchronous link(2).
346
<h2>fs.symlink(srcpath, dstpath, [type], callback)<span><a class="mark" href="#fs_fs_symlink_srcpath_dstpath_type_callback" id="fs_fs_symlink_srcpath_dstpath_type_callback">#</a></span></h2>
347
<p>Asynchronous symlink(2). No arguments other than a possible exception are given
348
to the completion callback.
349
<code>type</code> argument can be either <code>'dir'</code>, <code>'file'</code>, or <code>'junction'</code> (default is <code>'file'</code>). It is only
350
used on Windows (ignored on other platforms).
351
Note that Windows junction points require the destination path to be absolute. When using
352
<code>'junction'</code>, the <code>destination</code> argument will automatically be normalized to absolute path.
355
<h2>fs.symlinkSync(srcpath, dstpath, [type])<span><a class="mark" href="#fs_fs_symlinksync_srcpath_dstpath_type" id="fs_fs_symlinksync_srcpath_dstpath_type">#</a></span></h2>
356
<p>Synchronous symlink(2).
359
<h2>fs.readlink(path, callback)<span><a class="mark" href="#fs_fs_readlink_path_callback" id="fs_fs_readlink_path_callback">#</a></span></h2>
360
<p>Asynchronous readlink(2). The callback gets two arguments <code>(err,
364
<h2>fs.readlinkSync(path)<span><a class="mark" href="#fs_fs_readlinksync_path" id="fs_fs_readlinksync_path">#</a></span></h2>
365
<p>Synchronous readlink(2). Returns the symbolic link's string value.
368
<h2>fs.realpath(path, [cache], callback)<span><a class="mark" href="#fs_fs_realpath_path_cache_callback" id="fs_fs_realpath_path_cache_callback">#</a></span></h2>
369
<p>Asynchronous realpath(2). The <code>callback</code> gets two arguments <code>(err,
370
resolvedPath)</code>. May use <code>process.cwd</code> to resolve relative paths. <code>cache</code> is an
371
object literal of mapped paths that can be used to force a specific path
372
resolution or avoid additional <code>fs.stat</code> calls for known real paths.
378
<pre><code>var cache = {'/etc':'/private/etc'};
379
fs.realpath('/etc/passwd', cache, function (err, resolvedPath) {
381
console.log(resolvedPath);
383
<h2>fs.realpathSync(path, [cache])<span><a class="mark" href="#fs_fs_realpathsync_path_cache" id="fs_fs_realpathsync_path_cache">#</a></span></h2>
384
<p>Synchronous realpath(2). Returns the resolved path.
387
<h2>fs.unlink(path, callback)<span><a class="mark" href="#fs_fs_unlink_path_callback" id="fs_fs_unlink_path_callback">#</a></span></h2>
388
<p>Asynchronous unlink(2). No arguments other than a possible exception are given
389
to the completion callback.
392
<h2>fs.unlinkSync(path)<span><a class="mark" href="#fs_fs_unlinksync_path" id="fs_fs_unlinksync_path">#</a></span></h2>
393
<p>Synchronous unlink(2).
396
<h2>fs.rmdir(path, callback)<span><a class="mark" href="#fs_fs_rmdir_path_callback" id="fs_fs_rmdir_path_callback">#</a></span></h2>
397
<p>Asynchronous rmdir(2). No arguments other than a possible exception are given
398
to the completion callback.
401
<h2>fs.rmdirSync(path)<span><a class="mark" href="#fs_fs_rmdirsync_path" id="fs_fs_rmdirsync_path">#</a></span></h2>
402
<p>Synchronous rmdir(2).
405
<h2>fs.mkdir(path, [mode], callback)<span><a class="mark" href="#fs_fs_mkdir_path_mode_callback" id="fs_fs_mkdir_path_mode_callback">#</a></span></h2>
406
<p>Asynchronous mkdir(2). No arguments other than a possible exception are given
407
to the completion callback. <code>mode</code> defaults to <code>0777</code>.
410
<h2>fs.mkdirSync(path, [mode])<span><a class="mark" href="#fs_fs_mkdirsync_path_mode" id="fs_fs_mkdirsync_path_mode">#</a></span></h2>
411
<p>Synchronous mkdir(2).
414
<h2>fs.readdir(path, callback)<span><a class="mark" href="#fs_fs_readdir_path_callback" id="fs_fs_readdir_path_callback">#</a></span></h2>
415
<p>Asynchronous readdir(3). Reads the contents of a directory.
416
The callback gets two arguments <code>(err, files)</code> where <code>files</code> is an array of
417
the names of the files in the directory excluding <code>'.'</code> and <code>'..'</code>.
420
<h2>fs.readdirSync(path)<span><a class="mark" href="#fs_fs_readdirsync_path" id="fs_fs_readdirsync_path">#</a></span></h2>
421
<p>Synchronous readdir(3). Returns an array of filenames excluding <code>'.'</code> and
422
<code>'..'</code>.
425
<h2>fs.close(fd, callback)<span><a class="mark" href="#fs_fs_close_fd_callback" id="fs_fs_close_fd_callback">#</a></span></h2>
426
<p>Asynchronous close(2). No arguments other than a possible exception are given
427
to the completion callback.
430
<h2>fs.closeSync(fd)<span><a class="mark" href="#fs_fs_closesync_fd" id="fs_fs_closesync_fd">#</a></span></h2>
431
<p>Synchronous close(2).
434
<h2>fs.open(path, flags, [mode], callback)<span><a class="mark" href="#fs_fs_open_path_flags_mode_callback" id="fs_fs_open_path_flags_mode_callback">#</a></span></h2>
435
<p>Asynchronous file open. See open(2). <code>flags</code> can be:
439
<li><p><code>'r'</code> - Open file for reading.
440
An exception occurs if the file does not exist.</p>
442
<li><p><code>'r+'</code> - Open file for reading and writing.
443
An exception occurs if the file does not exist.</p>
445
<li><p><code>'rs'</code> - Open file for reading in synchronous mode. Instructs the operating
446
system to bypass the local file system cache.</p>
447
<p>This is primarily useful for opening files on NFS mounts as it allows you to
448
skip the potentially stale local cache. It has a very real impact on I/O
449
performance so don't use this mode unless you need it.</p>
450
<p>Note that this doesn't turn <code>fs.open()</code> into a synchronous blocking call.
451
If that's what you want then you should be using <code>fs.openSync()</code></p>
453
<li><p><code>'rs+'</code> - Open file for reading and writing, telling the OS to open it
454
synchronously. See notes for <code>'rs'</code> about using this with caution.</p>
456
<li><p><code>'w'</code> - Open file for writing.
457
The file is created (if it does not exist) or truncated (if it exists).</p>
459
<li><p><code>'wx'</code> - Like <code>'w'</code> but opens the file in exclusive mode.</p>
461
<li><p><code>'w+'</code> - Open file for reading and writing.
462
The file is created (if it does not exist) or truncated (if it exists).</p>
464
<li><p><code>'wx+'</code> - Like <code>'w+'</code> but opens the file in exclusive mode.</p>
466
<li><p><code>'a'</code> - Open file for appending.
467
The file is created if it does not exist.</p>
469
<li><p><code>'ax'</code> - Like <code>'a'</code> but opens the file in exclusive mode.</p>
471
<li><p><code>'a+'</code> - Open file for reading and appending.
472
The file is created if it does not exist.</p>
474
<li><p><code>'ax+'</code> - Like <code>'a+'</code> but opens the file in exclusive mode.</p>
477
<p><code>mode</code> defaults to <code>0666</code>. The callback gets two arguments <code>(err, fd)</code>.
480
<p>Exclusive mode (<code>O_EXCL</code>) ensures that <code>path</code> is newly created. <code>fs.open()</code>
481
fails if a file by that name already exists. On POSIX systems, symlinks are
482
not followed. Exclusive mode may or may not work with network file systems.
485
<p>On Linux, positional writes don't work when the file is opened in append mode.
486
The kernel ignores the position argument and always appends the data to
490
<h2>fs.openSync(path, flags, [mode])<span><a class="mark" href="#fs_fs_opensync_path_flags_mode" id="fs_fs_opensync_path_flags_mode">#</a></span></h2>
491
<p>Synchronous open(2).
494
<h2>fs.utimes(path, atime, mtime, callback)<span><a class="mark" href="#fs_fs_utimes_path_atime_mtime_callback" id="fs_fs_utimes_path_atime_mtime_callback">#</a></span></h2>
495
<h2>fs.utimesSync(path, atime, mtime)<span><a class="mark" href="#fs_fs_utimessync_path_atime_mtime" id="fs_fs_utimessync_path_atime_mtime">#</a></span></h2>
496
<p>Change file timestamps of the file referenced by the supplied path.
499
<h2>fs.futimes(fd, atime, mtime, callback)<span><a class="mark" href="#fs_fs_futimes_fd_atime_mtime_callback" id="fs_fs_futimes_fd_atime_mtime_callback">#</a></span></h2>
500
<h2>fs.futimesSync(fd, atime, mtime)<span><a class="mark" href="#fs_fs_futimessync_fd_atime_mtime" id="fs_fs_futimessync_fd_atime_mtime">#</a></span></h2>
501
<p>Change the file timestamps of a file referenced by the supplied file
505
<h2>fs.fsync(fd, callback)<span><a class="mark" href="#fs_fs_fsync_fd_callback" id="fs_fs_fsync_fd_callback">#</a></span></h2>
506
<p>Asynchronous fsync(2). No arguments other than a possible exception are given
507
to the completion callback.
510
<h2>fs.fsyncSync(fd)<span><a class="mark" href="#fs_fs_fsyncsync_fd" id="fs_fs_fsyncsync_fd">#</a></span></h2>
511
<p>Synchronous fsync(2).
514
<h2>fs.write(fd, buffer, offset, length, position, callback)<span><a class="mark" href="#fs_fs_write_fd_buffer_offset_length_position_callback" id="fs_fs_write_fd_buffer_offset_length_position_callback">#</a></span></h2>
515
<p>Write <code>buffer</code> to the file specified by <code>fd</code>.
518
<p><code>offset</code> and <code>length</code> determine the part of the buffer to be written.
521
<p><code>position</code> refers to the offset from the beginning of the file where this data
522
should be written. If <code>position</code> is <code>null</code>, the data will be written at the
527
<p>The callback will be given three arguments <code>(err, written, buffer)</code> where <code>written</code>
528
specifies how many <em>bytes</em> were written from <code>buffer</code>.
531
<p>Note that it is unsafe to use <code>fs.write</code> multiple times on the same file
532
without waiting for the callback. For this scenario,
533
<code>fs.createWriteStream</code> is strongly recommended.
536
<p>On Linux, positional writes don't work when the file is opened in append mode.
537
The kernel ignores the position argument and always appends the data to
541
<h2>fs.writeSync(fd, buffer, offset, length, position)<span><a class="mark" href="#fs_fs_writesync_fd_buffer_offset_length_position" id="fs_fs_writesync_fd_buffer_offset_length_position">#</a></span></h2>
542
<p>Synchronous version of <code>fs.write()</code>. Returns the number of bytes written.
545
<h2>fs.read(fd, buffer, offset, length, position, callback)<span><a class="mark" href="#fs_fs_read_fd_buffer_offset_length_position_callback" id="fs_fs_read_fd_buffer_offset_length_position_callback">#</a></span></h2>
546
<p>Read data from the file specified by <code>fd</code>.
549
<p><code>buffer</code> is the buffer that the data will be written to.
552
<p><code>offset</code> is offset within the buffer where reading will start.
555
<p><code>length</code> is an integer specifying the number of bytes to read.
558
<p><code>position</code> is an integer specifying where to begin reading from in the file.
559
If <code>position</code> is <code>null</code>, data will be read from the current file position.
562
<p>The callback is given the three arguments, <code>(err, bytesRead, buffer)</code>.
565
<h2>fs.readSync(fd, buffer, offset, length, position)<span><a class="mark" href="#fs_fs_readsync_fd_buffer_offset_length_position" id="fs_fs_readsync_fd_buffer_offset_length_position">#</a></span></h2>
566
<p>Synchronous version of <code>fs.read</code>. Returns the number of <code>bytesRead</code>.
569
<h2>fs.readFile(filename, [options], callback)<span><a class="mark" href="#fs_fs_readfile_filename_options_callback" id="fs_fs_readfile_filename_options_callback">#</a></span></h2>
570
<div class="signature"><ul>
571
<li><code>filename</code> <span class="type">String</span></li>
572
<li><code>options</code> <span class="type">Object</span><ul>
573
<li><code>encoding</code> <span class="type">String | Null</span> default = <code>null</code></li>
574
<li><code>flag</code> <span class="type">String</span> default = <code>'r'</code></li>
577
<li><code>callback</code> <span class="type">Function</span></li>
579
<p>Asynchronously reads the entire contents of a file. Example:
582
<pre><code>fs.readFile('/etc/passwd', function (err, data) {
586
<p>The callback is passed two arguments <code>(err, data)</code>, where <code>data</code> is the
587
contents of the file.
590
<p>If no encoding is specified, then the raw buffer is returned.
594
<h2>fs.readFileSync(filename, [options])<span><a class="mark" href="#fs_fs_readfilesync_filename_options" id="fs_fs_readfilesync_filename_options">#</a></span></h2>
595
<p>Synchronous version of <code>fs.readFile</code>. Returns the contents of the <code>filename</code>.
598
<p>If the <code>encoding</code> option is specified then this function returns a
599
string. Otherwise it returns a buffer.
603
<h2>fs.writeFile(filename, data, [options], callback)<span><a class="mark" href="#fs_fs_writefile_filename_data_options_callback" id="fs_fs_writefile_filename_data_options_callback">#</a></span></h2>
604
<div class="signature"><ul>
605
<li><code>filename</code> <span class="type">String</span></li>
606
<li><code>data</code> <span class="type">String | Buffer</span></li>
607
<li><code>options</code> <span class="type">Object</span><ul>
608
<li><code>encoding</code> <span class="type">String | Null</span> default = <code>'utf8'</code></li>
609
<li><code>mode</code> <span class="type">Number</span> default = <code>438</code> (aka <code>0666</code> in Octal)</li>
610
<li><code>flag</code> <span class="type">String</span> default = <code>'w'</code></li>
613
<li><code>callback</code> <span class="type">Function</span></li>
615
<p>Asynchronously writes data to a file, replacing the file if it already exists.
616
<code>data</code> can be a string or a buffer.
619
<p>The <code>encoding</code> option is ignored if <code>data</code> is a buffer. It defaults
620
to <code>'utf8'</code>.
626
<pre><code>fs.writeFile('message.txt', 'Hello Node', function (err) {
628
console.log('It\'s saved!');
630
<h2>fs.writeFileSync(filename, data, [options])<span><a class="mark" href="#fs_fs_writefilesync_filename_data_options" id="fs_fs_writefilesync_filename_data_options">#</a></span></h2>
631
<p>The synchronous version of <code>fs.writeFile</code>.
634
<h2>fs.appendFile(filename, data, [options], callback)<span><a class="mark" href="#fs_fs_appendfile_filename_data_options_callback" id="fs_fs_appendfile_filename_data_options_callback">#</a></span></h2>
635
<div class="signature"><ul>
636
<li><code>filename</code> <span class="type">String</span></li>
637
<li><code>data</code> <span class="type">String | Buffer</span></li>
638
<li><code>options</code> <span class="type">Object</span><ul>
639
<li><code>encoding</code> <span class="type">String | Null</span> default = <code>'utf8'</code></li>
640
<li><code>mode</code> <span class="type">Number</span> default = <code>438</code> (aka <code>0666</code> in Octal)</li>
641
<li><code>flag</code> <span class="type">String</span> default = <code>'a'</code></li>
644
<li><code>callback</code> <span class="type">Function</span></li>
646
<p>Asynchronously append data to a file, creating the file if it not yet exists.
647
<code>data</code> can be a string or a buffer.
653
<pre><code>fs.appendFile('message.txt', 'data to append', function (err) {
655
console.log('The "data to append" was appended to file!');
657
<h2>fs.appendFileSync(filename, data, [options])<span><a class="mark" href="#fs_fs_appendfilesync_filename_data_options" id="fs_fs_appendfilesync_filename_data_options">#</a></span></h2>
658
<p>The synchronous version of <code>fs.appendFile</code>.
661
<h2>fs.watchFile(filename, [options], listener)<span><a class="mark" href="#fs_fs_watchfile_filename_options_listener" id="fs_fs_watchfile_filename_options_listener">#</a></span></h2>
662
<pre class="api_stability_2">Stability: 2 - Unstable. Use fs.watch instead, if possible.</pre><p>Watch for changes on <code>filename</code>. The callback <code>listener</code> will be called each
663
time the file is accessed.
666
<p>The second argument is optional. The <code>options</code> if provided should be an object
667
containing two members a boolean, <code>persistent</code>, and <code>interval</code>. <code>persistent</code>
668
indicates whether the process should continue to run as long as files are
669
being watched. <code>interval</code> indicates how often the target should be polled,
670
in milliseconds. The default is <code>{ persistent: true, interval: 5007 }</code>.
673
<p>The <code>listener</code> gets two arguments the current stat object and the previous
677
<pre><code>fs.watchFile('message.text', function (curr, prev) {
678
console.log('the current mtime is: ' + curr.mtime);
679
console.log('the previous mtime was: ' + prev.mtime);
681
<p>These stat objects are instances of <code>fs.Stat</code>.
684
<p>If you want to be notified when the file was modified, not just accessed
685
you need to compare <code>curr.mtime</code> and <code>prev.mtime</code>.
688
<h2>fs.unwatchFile(filename, [listener])<span><a class="mark" href="#fs_fs_unwatchfile_filename_listener" id="fs_fs_unwatchfile_filename_listener">#</a></span></h2>
689
<pre class="api_stability_2">Stability: 2 - Unstable. Use fs.watch instead, if possible.</pre><p>Stop watching for changes on <code>filename</code>. If <code>listener</code> is specified, only that
690
particular listener is removed. Otherwise, <em>all</em> listeners are removed and you
691
have effectively stopped watching <code>filename</code>.
694
<p>Calling <code>fs.unwatchFile()</code> with a filename that is not being watched is a
698
<h2>fs.watch(filename, [options], [listener])<span><a class="mark" href="#fs_fs_watch_filename_options_listener" id="fs_fs_watch_filename_options_listener">#</a></span></h2>
699
<pre class="api_stability_2">Stability: 2 - Unstable.</pre><p>Watch for changes on <code>filename</code>, where <code>filename</code> is either a file or a
700
directory. The returned object is a <a href="#fs_class_fs_fswatcher">fs.FSWatcher</a>.
703
<p>The second argument is optional. The <code>options</code> if provided should be an object
704
containing a boolean member <code>persistent</code>, which indicates whether the process
705
should continue to run as long as files are being watched. The default is
706
<code>{ persistent: true }</code>.
709
<p>The listener callback gets two arguments <code>(event, filename)</code>. <code>event</code> is either
710
'rename' or 'change', and <code>filename</code> is the name of the file which triggered
714
<h3>Caveats<span><a class="mark" href="#fs_caveats" id="fs_caveats">#</a></span></h3>
717
<p>The <code>fs.watch</code> API is not 100% consistent across platforms, and is
718
unavailable in some situations.
721
<h4>Availability<span><a class="mark" href="#fs_availability" id="fs_availability">#</a></span></h4>
724
<p>This feature depends on the underlying operating system providing a way
725
to be notified of filesystem changes.
729
<li>On Linux systems, this uses <code>inotify</code>.</li>
730
<li>On BSD systems (including OS X), this uses <code>kqueue</code>.</li>
731
<li>On SunOS systems (including Solaris and SmartOS), this uses <code>event ports</code>.</li>
732
<li>On Windows systems, this feature depends on <code>ReadDirectoryChangesW</code>.</li>
734
<p>If the underlying functionality is not available for some reason, then
735
<code>fs.watch</code> will not be able to function. For example, watching files or
736
directories on network file systems (NFS, SMB, etc.) often doesn't work
740
<p>You can still use <code>fs.watchFile</code>, which uses stat polling, but it is slower and
744
<h4>Filename Argument<span><a class="mark" href="#fs_filename_argument" id="fs_filename_argument">#</a></span></h4>
747
<p>Providing <code>filename</code> argument in the callback is not supported
748
on every platform (currently it's only supported on Linux and Windows). Even
749
on supported platforms <code>filename</code> is not always guaranteed to be provided.
750
Therefore, don't assume that <code>filename</code> argument is always provided in the
751
callback, and have some fallback logic if it is null.
754
<pre><code>fs.watch('somedir', function (event, filename) {
755
console.log('event is: ' + event);
757
console.log('filename provided: ' + filename);
759
console.log('filename not provided');
762
<h2>fs.exists(path, callback)<span><a class="mark" href="#fs_fs_exists_path_callback" id="fs_fs_exists_path_callback">#</a></span></h2>
763
<p>Test whether or not the given path exists by checking with the file system.
764
Then call the <code>callback</code> argument with either true or false. Example:
767
<pre><code>fs.exists('/etc/passwd', function (exists) {
768
util.debug(exists ? "it's there" : "no passwd!");
770
<h2>fs.existsSync(path)<span><a class="mark" href="#fs_fs_existssync_path" id="fs_fs_existssync_path">#</a></span></h2>
771
<p>Synchronous version of <code>fs.exists</code>.
774
<h2>Class: fs.Stats<span><a class="mark" href="#fs_class_fs_stats" id="fs_class_fs_stats">#</a></span></h2>
775
<p>Objects returned from <code>fs.stat()</code>, <code>fs.lstat()</code> and <code>fs.fstat()</code> and their
776
synchronous counterparts are of this type.
780
<li><code>stats.isFile()</code></li>
781
<li><code>stats.isDirectory()</code></li>
782
<li><code>stats.isBlockDevice()</code></li>
783
<li><code>stats.isCharacterDevice()</code></li>
784
<li><code>stats.isSymbolicLink()</code> (only valid with <code>fs.lstat()</code>)</li>
785
<li><code>stats.isFIFO()</code></li>
786
<li><code>stats.isSocket()</code></li>
788
<p>For a regular file <code>util.inspect(stats)</code> would return a string very
792
<pre><code>{ dev: 2114,
802
atime: Mon, 10 Oct 2011 23:24:11 GMT,
803
mtime: Mon, 10 Oct 2011 23:24:11 GMT,
804
ctime: Mon, 10 Oct 2011 23:24:11 GMT }</code></pre>
805
<p>Please note that <code>atime</code>, <code>mtime</code> and <code>ctime</code> are instances
806
of <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">Date</a> object and to compare the values of
807
these objects you should use appropriate methods. For most
808
general uses <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime">getTime()</a> will return
809
the number of milliseconds elapsed since <em>1 January 1970
810
00:00:00 UTC</em> and this integer should be sufficient for
811
any comparison, however there additional methods which can
812
be used for displaying fuzzy information. More details can
813
be found in the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">MDN JavaScript Reference</a> page.
816
<h2>fs.createReadStream(path, [options])<span><a class="mark" href="#fs_fs_createreadstream_path_options" id="fs_fs_createreadstream_path_options">#</a></span></h2>
817
<p>Returns a new ReadStream object (See <code>Readable Stream</code>).
820
<p><code>options</code> is an object with the following defaults:
823
<pre><code>{ flags: 'r',
829
<p><code>options</code> can include <code>start</code> and <code>end</code> values to read a range of bytes from
830
the file instead of the entire file. Both <code>start</code> and <code>end</code> are inclusive and
831
start at 0. The <code>encoding</code> can be <code>'utf8'</code>, <code>'ascii'</code>, or <code>'base64'</code>.
834
<p>If <code>autoClose</code> is false, then the file descriptor won't be closed, even if
835
there's an error. It is your responsiblity to close it and make sure
836
there's no file descriptor leak. If <code>autoClose</code> is set to true (default
837
behavior), on <code>error</code> or <code>end</code> the file descriptor will be closed
841
<p>An example to read the last 10 bytes of a file which is 100 bytes long:
844
<pre><code>fs.createReadStream('sample.txt', {start: 90, end: 99});</code></pre>
845
<h2>Class: fs.ReadStream<span><a class="mark" href="#fs_class_fs_readstream" id="fs_class_fs_readstream">#</a></span></h2>
846
<p><code>ReadStream</code> is a <a href="stream.html#stream_class_stream_readable">Readable Stream</a>.
849
<h3>Event: 'open'<span><a class="mark" href="#fs_event_open" id="fs_event_open">#</a></span></h3>
850
<div class="signature"><ul>
851
<li><code>fd</code> <span class="type">Integer</span> file descriptor used by the ReadStream.</li>
853
<p>Emitted when the ReadStream's file is opened.
857
<h2>fs.createWriteStream(path, [options])<span><a class="mark" href="#fs_fs_createwritestream_path_options" id="fs_fs_createwritestream_path_options">#</a></span></h2>
858
<p>Returns a new WriteStream object (See <code>Writable Stream</code>).
861
<p><code>options</code> is an object with the following defaults:
864
<pre><code>{ flags: 'w',
866
mode: 0666 }</code></pre>
867
<p><code>options</code> may also include a <code>start</code> option to allow writing data at
868
some position past the beginning of the file. Modifying a file rather
869
than replacing it may require a <code>flags</code> mode of <code>r+</code> rather than the
870
default mode <code>w</code>.
873
<h2>Class: fs.WriteStream<span><a class="mark" href="#fs_class_fs_writestream" id="fs_class_fs_writestream">#</a></span></h2>
874
<p><code>WriteStream</code> is a <a href="stream.html#stream_class_stream_writable">Writable Stream</a>.
877
<h3>Event: 'open'<span><a class="mark" href="#fs_event_open_1" id="fs_event_open_1">#</a></span></h3>
878
<div class="signature"><ul>
879
<li><code>fd</code> <span class="type">Integer</span> file descriptor used by the WriteStream.</li>
881
<p>Emitted when the WriteStream's file is opened.
884
<h3>file.bytesWritten<span><a class="mark" href="#fs_file_byteswritten" id="fs_file_byteswritten">#</a></span></h3>
885
<p>The number of bytes written so far. Does not include data that is still queued
889
<h2>Class: fs.FSWatcher<span><a class="mark" href="#fs_class_fs_fswatcher" id="fs_class_fs_fswatcher">#</a></span></h2>
890
<p>Objects returned from <code>fs.watch()</code> are of this type.
893
<h3>watcher.close()<span><a class="mark" href="#fs_watcher_close" id="fs_watcher_close">#</a></span></h3>
894
<p>Stop watching for changes on the given <code>fs.FSWatcher</code>.
897
<h3>Event: 'change'<span><a class="mark" href="#fs_event_change" id="fs_event_change">#</a></span></h3>
898
<div class="signature"><ul>
899
<li><code>event</code> <span class="type">String</span> The type of fs change</li>
900
<li><code>filename</code> <span class="type">String</span> The filename that changed (if relevant/available)</li>
902
<p>Emitted when something changes in a watched directory or file.
903
See more details in <a href="#fs_fs_watch_filename_options_listener">fs.watch</a>.
906
<h3>Event: 'error'<span><a class="mark" href="#fs_event_error" id="fs_event_error">#</a></span></h3>
907
<div class="signature"><ul>
908
<li><code>error</code> <span class="type">Error object</span></li>
910
<p>Emitted when an error occurs.
917
<a href="http://joyent.com" class="joyent-logo">Joyent</a>
918
<ul class="clearfix">
919
<li><a href="/">Node.js</a></li>
920
<li><a href="/download/">Download</a></li>
921
<li><a href="/about/">About</a></li>
922
<li><a href="http://npmjs.org/">npm Registry</a></li>
923
<li><a href="http://nodejs.org/api/">Docs</a></li>
924
<li><a href="http://blog.nodejs.org">Blog</a></li>
925
<li><a href="/community/">Community</a></li>
926
<li><a href="/logos/">Logos</a></li>
927
<li><a href="http://jobs.nodejs.org/">Jobs</a></li>
928
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
931
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.10.15/LICENSE">license</a>.</p>
934
<script src="../sh_main.js"></script>
935
<script src="../sh_javascript.min.js"></script>
936
<script>highlight(undefined, undefined, 'pre');</script>
938
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
940
var g = d.createElement(t),
941
s = d.getElementsByTagName(t)[0];
942
g.src = '//www.google-analytics.com/ga.js';
943
s.parentNode.insertBefore(g, s);
944
}(document, 'script'));