I'm trying to use GJS and more precisely to read a text file in a synchronous way. Here is an example an the asynchronous function for file reading
gio-cat.js I found how to proceed with seed using the next function:
function readFile(filename) {
print(filename);
var input_file = gio.file_new_for_path(filename);
var fstream = input_file.read();
var dstream = new gio.DataInputStream.c_new(fstream);
var data = dstream.read_until("", 0);
fstream.close();
return data;
}
but unfortunately, it doesn't work with GJS. Can anyone help me ?