Skip to content

Commit

Permalink
update to use node-gyp instead of wscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Machi committed Aug 31, 2012
1 parent d0cd3e8 commit 1d86bc6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
10 changes: 10 additions & 0 deletions binding.gyp
@@ -0,0 +1,10 @@
{
"targets": [
{
"target_name": "xattr",
"sources": [ "src/node_xattr.cc" ],
'cflags': ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"],
}
]
}

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{ {
"name": "xattr", "name": "xattr",
"version": "v0.1.1", "version": "v0.9.0",
"description": "Wrapper for getting and setting extended attributes on files.", "description": "Wrapper for getting and setting extended attributes on files.",
"author": { "author": {
"name": "Dustin Machi", "name": "Dustin Machi",
Expand All @@ -11,7 +11,7 @@
"url": "https://github.com/dmachi/node-xattr" "url": "https://github.com/dmachi/node-xattr"
}, },
"scripts" : { "scripts" : {
"preinstall" : "node-waf configure && node-waf build", "preinstall" : "node-gyp configure && node-gyp build",
"preuninstall" : "rm -rf build/*" "preuninstall" : "rm -rf build/*"
}, },
"main" : "build/Release/xattr.node" "main" : "build/Release/xattr.node"
Expand Down
15 changes: 14 additions & 1 deletion src/node_xattr.cc
Expand Up @@ -58,7 +58,11 @@ static Handle<Value> set(const Arguments& args) {
REQ_ASCII_ARG(2,val); REQ_ASCII_ARG(2,val);
valLen = val.length(); valLen = val.length();


#ifdef __APPLE__
res = setxattr(*filename, *attribute, *val, valLen,0,0);
#else
res = setxattr(*filename, *attribute, *val, valLen,0); res = setxattr(*filename, *attribute, *val, valLen,0);
#endif
//printf("Setting file: %s, attribute: %s, value: %s, length: %d\n", *filename, *attribute, *val,val.length()); //printf("Setting file: %s, attribute: %s, value: %s, length: %d\n", *filename, *attribute, *val,val.length());




Expand All @@ -83,14 +87,23 @@ static Handle<Value> list(const Arguments& args) {
filename= ObjectToString(s).c_str(); filename= ObjectToString(s).c_str();


//get all the extended attributes on filename //get all the extended attributes on filename
listLen = listxattr(filename,list,XATTR_SIZE);


#ifdef __APPLE__
listLen = listxattr(filename,list,XATTR_SIZE,0);
#else
listLen = listxattr(filename,list,XATTR_SIZE);
#endif
// create obj for return // create obj for return
Handle<Object> result = Object::New(); Handle<Object> result = Object::New();


//for each of the attrs, do getxattr and add them as key/val to the obj //for each of the attrs, do getxattr and add them as key/val to the obj
for (ns=0; ns<listLen; ns+= strlen(&list[ns])+1){ for (ns=0; ns<listLen; ns+= strlen(&list[ns])+1){

#ifdef __APPLE__
valueLen = getxattr(filename, &list[ns],value, XATTR_SIZE,0,0);
#else
valueLen = getxattr(filename, &list[ns],value, XATTR_SIZE); valueLen = getxattr(filename, &list[ns],value, XATTR_SIZE);
#endif
if (valueLen > 0){ if (valueLen > 0){
result->Set(String::New(&list[ns]),String::New(value, valueLen)); result->Set(String::New(&list[ns]),String::New(value, valueLen));
} }
Expand Down
13 changes: 0 additions & 13 deletions wscript

This file was deleted.

0 comments on commit 1d86bc6

Please sign in to comment.