How to access named pipes using JavaScript in Firefox add-on? -


i'm trying access named pipe in firefox add-on. code, based on solution 2 this codeproject question, is:

var file = components.classes["@mozilla.org/file/local;1"].createinstance(components.interfaces.nsilocalfile); file.initwithpath("\\\\.\\pipe\\test"); var text = "some text written"; var writer = components.classes["@mozilla.org/network/file-output-stream;1"].createinstance(components.interfaces.nsifileoutputstream); // open file read/write access, , create if not exist. writer.init (file, 0x04 | 0x08, -1, 0); writer.write (text, text.length); writer.flush (); writer.close (); 

when run firefox scratchpad, get:

/* exception: component returned failure code: 0x80520012 (ns_error_file_not_found) [nsifileoutputstream.init] @6 */ 

line 6 line call writer.init.

i've played passing different flags writer.init, no luck. i'm able write normal file path code, not named pipe path.

i've been searching more information of day. other relevant thing i've found this bugzilla bug mentions same problem, it's dated 2009.

thank in advance suggestions.

edit: based on replies tried following:

var encoder = new textencoder(); var array = encoder.encode("this text"); var path = "\\\\.\\pipe\\test"; task.spawn(function() {     let pfh = yield os.file.open(path, {write: true});     yield pfh.write(array);     yield pfh.close();  }); 

which lets me write file (if change path accordingly) not seem send pipe.

here (admittedly crude) code i'm using read pipe on .net side:

let server = new namedpipeserverstream ("\\\\.\\pipe\\test", pipedirection.inout) let reader = new streamreader (server)     printfn "listening..."     server.waitforconnection ()     printfn "connected." while true     while reader.endofstream = false reader.readline () |> printfn "%s" 

and code threw verify @ least write pipe in .net:

let client = new namedpipeclientstream ("\\\\.\\pipe\\test") client.connect () let writer = new streamwriter (client) writer.autoflush <- true  // wait connection system.threading.thread.sleep (1000) let message = "hello" message |> writer.writeline 

try os.file:

let encoder = new textencoder();                                   // encoder can reused several writes let array = encoder.encode("this text");                   // convert text array let promise = os.file.writeatomic("\\\\.\\pipe\\test", array,               // write array atomically "file.txt", using temporary     {tmppath: "file.txt.tmp"});                                    // buffer "file.txt.tmp". 

Comments

Popular posts from this blog

node.js - req param returns an empty array -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -