Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.utimes return errors on Windows #5561

Closed
simon-tannai opened this issue Mar 4, 2016 · 2 comments
Closed

fs.utimes return errors on Windows #5561

simon-tannai opened this issue Mar 4, 2016 · 2 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@simon-tannai
Copy link

Hi !

I'm using fs.utimes in node script on Ubuntu, all work fine.
But when I'm launching this script on Windows, I get an error:

{ [Error: EINVAL: invalid argument, utime 'C:\Users\sit\Documents\_TRAVAUX\app\client_websocket_webdav\files\Corporate\issue3584.pdf']
  errno: -4071,
  code: 'EINVAL',
  syscall: 'utime',
  path: 'C:\\Users\\sit\\Documents\\_TRAVAUX\\app\\client_websocket_webdav\\files\\Corporate\\issue3584.pdf' }

The small script:

  fs.utimes(fullPathOfFile, currentUnixTimestamp, modifiedUnixTimestamp, function(err){
    if( err ) {
      console.log(err);
    }
  });

Have you any solution ?

  • Version: v5.1.0
  • Platform: Windows 7 64 bits
@simon-tannai simon-tannai changed the title fs.utimes return error on Windows fs.utimes return errors on Windows Mar 4, 2016
@mscdex mscdex added fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform. labels Mar 4, 2016
@bnoordhuis
Copy link
Member

Can you post a complete test case? It's unclear from your example what e.g. currentUnixTimestamp contains.

@simon-tannai
Copy link
Author

After several tests, I have found the solution:
atime and mtime parameters must be instances of Date().

So, the final code:

// Get current date
var currentDate = new Date();

var modifiedDate = new Date(modifiedUnixTimestamp * 1000);

var fullPathOfFile = "C:/path/to/file.txt";

// File, created date, modified date
fs.utimes(fullPathOfFile, currentDate, modifiedDate, function(err){
  if( err ) {
    console.log(err);
  }
});

tcoulter added a commit to trufflesuite/truffle-core that referenced this issue Sep 29, 2017
gnidan added a commit to trufflesuite/truffle-core that referenced this issue Sep 29, 2017
gnidan added a commit to trufflesuite/truffle-core that referenced this issue Sep 29, 2017
gnidan added a commit to trufflesuite/truffle-core that referenced this issue Sep 29, 2017
gnidan pushed a commit to trufflesuite/truffle-core that referenced this issue Sep 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

3 participants