-
Notifications
You must be signed in to change notification settings - Fork 44
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
Get the file owner in a platform-independent way #26
Comments
Yes that sounds like a good addition to the library. It might be worth checking what Perl does with stat() on Windows. If it "just works" then I suggest we provide a patched fs.stat rather than a new function. |
Thanks! Good idea to look at the others like Perl. Perl and Ruby just return what the My first choice was to set the Windows equivalents for the user and group identifiers there - SIDs. Having a POSIX-compatibility module - Creating another members for the SIDs or another methods to return the ownership would not break the type contract of the interface, but also leave it useless n Windows. Adding new members like Perl, Ruby and node.js don't offer multiplatform interface to get/set the file owner and/or to resolve user IDs and user names, although they partially offer the POSIX interface for that. Because both POSIX and Windows have the concept of IDs and JavaScript is not a strong-typed language, setting strings to the I'm still undecided what the best interface would be. Setting strings like "S-1-5-18" to |
I have the extensions using SIDs almost ready:
It goes beyond the scope of the
The fs-related extensions could be either in |
@baudehlo any updates on this issue? |
Instead of this code:
I use this as a workaround:
I checked the fs-ext extension to the posix-ext module too, but still allowing the integration with fs-ext. Let's see if it's just temporarily or not... |
So is it available ? If yes, then please tell me how to use it for getting owner name. |
fs.stat
returns the owner IDs on POSIX platforms only. Thestat.uid
andstat.gid
members are always zero on Windows and there are no stat members exposing the user and group SIDs there.Would you accept implementation of a method retrieving the file owner information in the
fs-ext
module? (I'd probably add the both user and group information, sync and async methods andfs.chown
wrappers for the sake of completeness.)I suggest adding a dedicated function, extending the
fs.stat
or wrapping thefs.stat
:Node.js does not provide a native way to resolve a user/group ID to the name or other information, which is usually wanted. The rest of the scenario - resolving the user and group IDs to the information - would be probably delegated to platform-specific modules.
There is a function
getpwnam
available on POSIX systems and exposed by thenode-posix
module:The file ownership is not enquired by the
fstat
on Windows, but using authorization and network APIs:The text was updated successfully, but these errors were encountered: