refactor des clibs et suppression de file.cc qui etait inutile
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
#include <node.h>
|
||||
#include <string>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define nodeparam v8::FunctionCallbackInfo<v8::Value>
|
||||
|
||||
namespace fileNode {
|
||||
void nodeOpen(const nodeparam& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
|
||||
if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsUint32() || ( args.Length() == 3 && !( args[2]->IsUndefined() || args[2]->IsUint32()))) {
|
||||
isolate->ThrowException(v8::Exception::TypeError(
|
||||
v8::String::NewFromUtf8(isolate, "Argument 1 must be a path, 2 must be a number").ToLocalChecked()));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::String::Utf8Value str(isolate, args[0]);
|
||||
std::string path(*str);
|
||||
int flags = args[1].As<v8::Number>()->Value();
|
||||
|
||||
if(args.Length() == 3 && args[2]->IsUndefined()) {
|
||||
mode_t mode = args[2].As<v8::Number>()->Value();
|
||||
args.GetReturnValue().Set(open(path.c_str(), flags, mode));
|
||||
} else {
|
||||
args.GetReturnValue().Set(open(path.c_str(), flags));
|
||||
}
|
||||
}
|
||||
|
||||
void nodeClose(const nodeparam& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
|
||||
if (args.Length() < 1 || !args[0]->IsUint32()) {
|
||||
isolate->ThrowException(v8::Exception::TypeError(
|
||||
v8::String::NewFromUtf8(isolate, "Argument 1 must be a file descriptor (number)").ToLocalChecked()));
|
||||
return;
|
||||
}
|
||||
|
||||
close(args[1].As<v8::Number>()->Value());
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports) {
|
||||
NODE_SET_METHOD(exports, "open", nodeOpen);
|
||||
NODE_SET_METHOD(exports, "close", nodeClose);
|
||||
}
|
||||
|
||||
NODE_MODULE(file_api, Initialize)
|
||||
}
|
||||
@@ -9,19 +9,13 @@
|
||||
namespace ioctlNode {
|
||||
void nodeIoctl(const nodeparam& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
|
||||
|
||||
|
||||
if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsUint32()) {
|
||||
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsUint32()) {
|
||||
isolate->ThrowException(v8::Exception::TypeError(
|
||||
v8::String::NewFromUtf8(isolate, "Argument 1& 2 must be a number").ToLocalChecked()));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::String::Utf8Value str(isolate, args[0]);
|
||||
std::string cppStr(*str);
|
||||
|
||||
int fd = open(cppStr.c_str(), 'r');
|
||||
u_int32_t fd = args[0].As<v8::Number>()->Value();
|
||||
unsigned long request = args[1].As<v8::Number>()->Value();
|
||||
int params[args.Length() - 2];
|
||||
for(int i = 1 ; i < args.Length(); i++ ) {
|
||||
|
||||
Reference in New Issue
Block a user