//write meta data info fs.open(this.resourceMetadataFile, 'w', function (err, fd) { console.log('start operate resource metadata provider file: ' + this.proxy.resourceMetadataFile); if (err) { console.error('write file error: ' + this.proxy.resourceMetadataFile); return ; } var str = this.proxy.javaMetaDataProviderClassName; fs.writeSync(fd, str, 0, str.length, 0); console.log('complete operate resource metadata provider file: ' + this.proxy.resourceMetadataFile); }.bind({proxy: this}));
function saveToFile (data, outFile, callback) { var writeFile; try { writeFile = fs.openSync(outFile, 'w'); fs.writeSync(writeFile, data); fs.close(writeFile); callback(null, outFile); } catch (err) { console.log('\n[' + chalk.gray('mochawesome') + '] Error: Unable to save ' + outFile + '\n' + err + '\n'); callback(err); } }
write(str) { fs.writeSync(this.fd, str); }
/** * */ setFactorsRowSync(type, rowId, vec) { if (this.options.lowmem) { let size1 = this.TypedArraySize1; let latentFactorsFd = (type == 'byUser' ? this.userFactorsFd : this.itemFactorsFd); let start = rowId * this.factorsCount * this.TypedArraySize1; fs.writeSync(latentFactorsFd, Buffer.from(vec.data.buffer), 0, vec.length * size1, start); } else { //see getFactorsRow() - was get by ref, no copy } }
function createSampleFileSync(sampleFilePath){ if(!fs.existsSync(sampleFilePath)){ mkdirsSync(pathLib.dirname(sampleFilePath)); var fd = fs.openSync(sampleFilePath, 'w'); if(fd){ fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.closeSync(fd); } } return sampleFilePath; }
fs.open('./frontend/config/env.js', 'w', function(err, fd) { const buf = 'export default \'production\';'; fs.writeSync(fd, buf, 0, buf.length, 0); });
function writeCSV(products) { const fileName = 'products.csv'; console.log(`Writing data to ${fileName}...`); fs.open(fileName, 'w', (error, fileDescriptor) => { if (error != null) { console.error(`Can not write to file: ${fileName}`, error); return; } // Write header fs.writeSync(fileDescriptor, 'name,price,unit\n'); // Write content products.forEach((product) => { const line = `${product.name},${product.price},${product.unit}\n`; fs.writeSync(fileDescriptor, line); }); console.log('Done.'); }); }
fs.writeSync(this.handler, buffer, 0, buffer.length, null, function (e) { throw e; });
write(str) { fs.writeSync(this.fd, str); }
fs.open('./frontend/config/env.js', 'w', function(err, fd) { const buf = 'export default \'development\';'; fs.writeSync(fd, buf, 0, buf.length, 0); });
function createSampleFileSync(sampleFilePath){ if(!fs.existsSync(sampleFilePath)){ mkdirsSync(pathLib.dirname(sampleFilePath)); var fd = fs.openSync(sampleFilePath, 'w'); if(fd){ fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.closeSync(fd); } } return sampleFilePath; }
function createSampleFileSync(sampleFilePath){ if(!fs.existsSync(sampleFilePath)){ mkdirsSync(pathLib.dirname(sampleFilePath)); var fd = fs.openSync(sampleFilePath, 'w'); if(fd){ for(let i=0;i < 1000000;i++){ fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); } fs.closeSync(fd); } } return sampleFilePath; }
function createSampleFile(sampleFilePath){ if(!fs.existsSync(sampleFilePath)){ mkdirsSync(pathLib.dirname(sampleFilePath)); var fd = fs.openSync(sampleFilePath, 'w'); if(fd){ for(let i=0;i < 1000000;i++){ fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); } fs.closeSync(fd); } } return sampleFilePath; }
function createSampleFileSync(sampleFilePath){ if(!fs.existsSync(sampleFilePath)){ mkdirsSync(pathLib.dirname(sampleFilePath)); var fd = fs.openSync(sampleFilePath, 'w'); if(fd){ for(let i=0;i < 1000000;i++){ fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); fs.writeSync(fd, String(Math.random()) + '\n'); } fs.closeSync(fd); } } return sampleFilePath; }