Subversion Repositories HomeAutomation

Rev

Rev 1402 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1402 Rev 1405
Line 87... Line 87...
87
    myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread));
87
    myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread));
88
    myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread));
88
    myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread));
89
    myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread));
89
    myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread));
90
    myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore));
90
    myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore));
91
    myGlobal->Set(String::New("getFileContents"), FunctionTemplate::New(VirtualMachine::_getFileContents));
91
    myGlobal->Set(String::New("getFileContents"), FunctionTemplate::New(VirtualMachine::_getFileContents));
-
 
92
    myGlobal->Set(String::New("setFileContents"), FunctionTemplate::New(VirtualMachine::_setFileContents));
92
    myGlobal->Set(String::New("system"), FunctionTemplate::New(VirtualMachine::_system));
93
    myGlobal->Set(String::New("system"), FunctionTemplate::New(VirtualMachine::_system));
93
    myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex));
94
    myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex));
94
    myGlobal->Set(String::New("hex2bin"), FunctionTemplate::New(VirtualMachine::_hex2bin));
95
    myGlobal->Set(String::New("hex2bin"), FunctionTemplate::New(VirtualMachine::_hex2bin));
95
    myGlobal->Set(String::New("bin2hex"), FunctionTemplate::New(VirtualMachine::_bin2hex));
96
    myGlobal->Set(String::New("bin2hex"), FunctionTemplate::New(VirtualMachine::_bin2hex));
96
    myGlobal->Set(String::New("bin2float"), FunctionTemplate::New(VirtualMachine::_bin2float));
97
    myGlobal->Set(String::New("bin2float"), FunctionTemplate::New(VirtualMachine::_bin2float));
Line 592... Line 593...
592
    }
593
    }
593
 
594
 
594
    string content = file_get_contents(*filename);
595
    string content = file_get_contents(*filename);
595
 
596
 
596
    return String::New(content.c_str());
597
    return String::New(content.c_str());
-
 
598
}
-
 
599
 
-
 
600
Handle<Value> VirtualMachine::_setFileContents(const Arguments& args)
-
 
601
{
-
 
602
    String::AsciiValue filename(args[0]);
-
 
603
    String::AsciiValue content(args[1]);
-
 
604
 
-
 
605
    std::ofstream dstfile(*filename);
-
 
606
 
-
 
607
    if (!dstfile.is_open())
-
 
608
    {
-
 
609
        dstfile.close();
-
 
610
        return Undefined();
-
 
611
    }
-
 
612
 
-
 
613
    dstfile << *content;
-
 
614
    dstfile.close();
-
 
615
 
-
 
616
    return Undefined();
597
}
617
}
598
 
618
 
599
#include <string>
619
#include <string>
600
#include <iostream>
620
#include <iostream>
601
#include <stdio.h>
621
#include <stdio.h>