Menu

Working on new API

We are working on a new API for cnatural, it's called BasicIO and it's usage will be like:

// alias:
let io = window.NaturalClient.API.BasicIO;
let con = window.NaturalClient.API.SoftConsole;

let chunkSize = 500; // Read 500B (bytes) per operation
let chunkPos = 0; // Position of the chunk in the file

io.ReadFile("/home/user/filename.txt", chunkPos, chunkSize, function(err, readed)
{
    if(err)
        throw err;

    // assert(readed.length == chunkSize); // This is true

    // Remove null bytes added by the EOF-past read.
    readed = readed.replace(/\0/gmi, "");

    con.writeLine("Readed" + readed);
});

This API provides functions to read, write and update files on the server. It's counterpart, FileIO will be more complex and complete, but for now is not in development.

Posted by Alejandro Linarez 2017-05-18 Labels: basicio server api client

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.