Hi everyone,

I was using fs.utimes to change the mtime of files and my problem is it seems that it has no effect on mtime when I called this method multiple times on windows. I ran the same code on ubuntu and everything's fine.

I tried to change ws.on('finish' to rs.on('close' which will be emitted before ws's finish event and found the change of mtime has done but it was changed again later. So I was wondering maybe when the finish event is emitted, the write of the file still has not been done.

Could anyone tell me what's wrong with my code?

Here's my code:

var fs = require('fs');

function doTest(path1, path2) {
     var rs = fs.createReadStream(path1),
         ws = fs.createWriteStream(path2);
     rs.on('readable', function fn() {
         var buf = rs.read(2);
         rs.removeListener('readable', fn);

         ws.on('finish', function () {
               var d = new Date('2014-4-11 12:30');

               // fs.statSync(path2).mtime;
               fs.utimesSync(path2, d, d);
               console.log(+d, +fs.statSync(path2).mtime);

               setTimeout(function () {
               }, 1000);


doTest('./test1.txt', './test1.write.txt');
doTest('./test2.txt', './test2.write.txt');

Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at

You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupnodejs @
postedMay 4, '14 at 12:25a
activeMay 4, '14 at 12:25a

1 user in discussion

Sean Young: 1 post



site design / logo © 2022 Grokbase