Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Windows-specific options to fs.writeFile #1277

Closed
reverofevil opened this issue May 11, 2014 · 2 comments
Closed

Windows-specific options to fs.writeFile #1277

reverofevil opened this issue May 11, 2014 · 2 comments

Comments

@reverofevil
Copy link

(Mostly following the lines of feature request for Node.js: nodejs/node-v0.x-archive#7593)

I would like to create a temporary file. Packages tmp and node-temp set neither FILE_ATTRIBUTE_TEMPORARY nor FILE_FLAG_DELETE_ON_CLOSE attributes for the temporary file. These are required for Windows to keep the file in memory, emulating some kind of tmpfs. The problem is that this problem cannot be solved with plain fs API. cmd commands are of no help either, because the second flag should be set to CreateFile WinAPI, and cannot be set after the file is already created.

Could you add OS-specific options for fs.writeFile API, please?

CreateFile flags list:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
File attributes constants list:
http://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx

I've been asked by Fedor Indutny which of these are most useful for Node users, and I'm not sure. I suppose the best solution would be to pass a number "as is", and leave the list of possible constants for some third-party package. If identifiers of those constants are changed, it would be harder to find the needed options, and would result in unnecessary duplication. All of these flags are of no use to the most of Node users, and there's no need to bloat the library.

@saghul
Copy link
Contributor

saghul commented May 12, 2014

I think the right thing to do here would be to have some uv_fs_tmpfile function which uses tmpfile() (or mkstemp) on Unix and whatever equivalent on Windows. It would return the fd of the opened temporary file and then the rest of the fs functions should just work.

@saghul
Copy link
Contributor

saghul commented Nov 26, 2014

Closing. Feel free to open a PR in libuv/libuv if you plan on working on this.

@saghul saghul closed this as completed Nov 26, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants