Skip to content

Commit

Permalink
Use utimes from musl (#16282)
Browse files Browse the repository at this point in the history
Followup to #16262
  • Loading branch information
kripken authored Feb 14, 2022
1 parent 27de9b4 commit aa147e7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
45 changes: 0 additions & 45 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,6 @@ LibraryManager.library = {
return cString;
},

// ==========================================================================
// utime.h
// ==========================================================================

#if FILESYSTEM
$setFileTime__deps: ['$FS', '$setErrNo'],
$setFileTime: function(path, time) {
path = UTF8ToString(path);
try {
FS.utime(path, time, time);
return 0;
} catch (e) {
if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
setErrNo(e.errno);
return -1;
}
},
#else
$setFileTime__deps: ['$setErrNo'],
$setFileTime: function(path, time) {
// No filesystem support; return an error as if the file does not exist
// (which it almost certainly does not, except for standard streams).
setErrNo({{{ cDefine('ENOENT') }}});
return -1;
},
#endif

utimes__deps: ['$setFileTime'],
utimes__proxy: 'sync',
utimes__sig: 'iii',
utimes: function(path, times) {
// utimes is just like utime but take an array of 2 times: `struct timeval times[2]`
// times[0] is the new access time (which we currently ignore)
// times[1] is the new modification time.
var time;
if (times) {
var mtime = times + {{{ C_STRUCTS.timeval.__size__ }}};
time = {{{ makeGetValue('mtime', C_STRUCTS.timeval.tv_sec, 'i32') }}} * 1000;
time += {{{ makeGetValue('mtime', C_STRUCTS.timeval.tv_usec, 'i32') }}} / 1000;
} else {
time = Date.now();
}
return setFileTime(path, time);
},

exit__sig: 'vi',
#if MINIMAL_RUNTIME
// minimal runtime doesn't do any exit cleanup handling so just
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def get_files(self):

libc_files += files_in_path(
path='system/lib/libc/musl/src/linux',
filenames=['getdents.c', 'gettid.c'])
filenames=['getdents.c', 'gettid.c', 'utimes.c'])
libc_files += files_in_path(
path='system/lib/libc/musl/src/env',
filenames=['__environ.c', 'getenv.c', 'putenv.c', 'setenv.c', 'unsetenv.c'])
Expand Down

0 comments on commit aa147e7

Please sign in to comment.