• file_copy()

    From Mortifis@VERT/ALLEYCAT to All on Saturday, February 29, 2020 07:45:11
    moding /sbbs/exec/load/openweathermap.js to copy the /sbbs/temp/{response}.json file but it isn't working ...

    OpenWeatherMap.prototype.write_cache = function (endpoint, params, response) {
    const hash = base64_encode(endpoint + JSON.stringify(params));
    cache_file = new File(system.temp_dir + 'openweathermap_' + hash + '.json');
    cache_file.open('w');
    cache_file.write(JSON.stringify(response));
    cache_file.close();
    file_copy(cache_file, '/sbbs/etrucker/' + 'owm.json');
    writeln('Copied '+cache_file + 'to /sbbs/etrucker.owm.json');
    }

    the file_copy(cache_file, '/sbbs/etrucker/' + 'owm.json'); seems to error

    any ideas?

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Digital Man@VERT to Mortifis on Saturday, February 29, 2020 12:47:15
    Re: file_copy()
    By: Mortifis to All on Sat Feb 29 2020 07:45 am

    moding /sbbs/exec/load/openweathermap.js to copy the /sbbs/temp/{response}.json file but it isn't working ...

    OpenWeatherMap.prototype.write_cache = function (endpoint, params, response) {
    const hash = base64_encode(endpoint + JSON.stringify(params));
    cache_file = new File(system.temp_dir + 'openweathermap_' + hash + '.json');
    cache_file.open('w');
    cache_file.write(JSON.stringify(response));
    cache_file.close();
    file_copy(cache_file, '/sbbs/etrucker/' + 'owm.json');
    writeln('Copied '+cache_file + 'to /sbbs/etrucker.owm.json');
    }

    the file_copy(cache_file, '/sbbs/etrucker/' + 'owm.json'); seems to error

    any ideas?

    cache_file is a File object. The file_copy() method requires strings (filenames) for arguments.

    So I think you want:
    file_copy(cache_file.name, '/sbbs/etrucker/owm.json');
    instead.

    Also, check the return value of file_copy() to see if the copy was successful or not.

    digital man

    This Is Spinal Tap quote #32:
    Derek Smalls: [A jog?] We don't have time for that.
    Norco, CA WX: 70.2øF, 27.0% humidity, 0 mph NW wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net