Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 91e88bf8e0a58a611e621f431c08f6bb > files > 39

gjs-devel-0.7.14-3.fc15.i686.rpm

const Gio = imports.gi.Gio;
const Mainloop = imports.mainloop;

function cat(filename) {
    let f = Gio.file_new_for_path(filename);
    f.load_contents_async(null, function(f, res) {
        let contents;
        try {
            contents = f.load_contents_finish(res)[1];
        } catch (e) {
            log("*** ERROR: " + e.message);
            Mainloop.quit('');
            return;
        }
        print(contents);
        Mainloop.quit('');
    }, null);

    Mainloop.run('');
}

if (ARGV.length != 1) {
    printerr("Usage: gio-cat.js filename");
} else {
    cat(ARGV[0]);
}