more work on exportTo(..), now using node.js fs.extra...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-21 17:23:09 +04:00
parent 01e8e39fc9
commit a8ce503b92
2 changed files with 8 additions and 9 deletions

View File

@ -26,6 +26,7 @@ if(window.CEF_dumpJSON != null){
console.log('node-webkit mode: loading...') console.log('node-webkit mode: loading...')
var fs = require('fs') var fs = require('fs')
var fse = require('fs.extra')
var proc = require('child_process') var proc = require('child_process')
var gui = require('nw.gui') var gui = require('nw.gui')
@ -60,12 +61,12 @@ if(window.CEF_dumpJSON != null){
// XXX make dirs... // XXX make dirs...
if(!fs.existsSync(path)){ if(!fs.existsSync(path)){
console.log('making:', path) console.log('making:', path)
// XXX NOTE: this will not make more than one dir... fse.mkdirRecursiveSync(path)
fs.mkdirSync(path)
} }
if(!fs.existsSync(dst)){ if(!fs.existsSync(dst)){
fs.linkSync(src, dst) // NOTE: this is not sync...
return fse.copy(src, dst)
} }
} }
window.dumpJSON = function(path, data){ window.dumpJSON = function(path, data){
@ -78,9 +79,8 @@ if(window.CEF_dumpJSON != null){
dirs = dirs.join('/') dirs = dirs.join('/')
// build path... // build path...
if(!fs.existsSync(dirs)){ if(!fs.existsSync(dirs)){
console.log('making:', dirs, path) console.log('making:', path)
// XXX NOTE: this will not make more than one dir... fse.mkdirRecursiveSync(path)
fs.mkdirSync(dirs)
} }
return fs.writeFileSync(path, JSON.stringify(data), encoding='utf8') return fs.writeFileSync(path, JSON.stringify(data), encoding='utf8')
} }

View File

@ -557,11 +557,11 @@ function updateRibbonsFromFavDirs(){
// Export current state to directory... // Export current state to directory...
// //
// NOTE: if size is null, the original image will be copied...
function exportTo(path, im_name, dir_name, size){ function exportTo(path, im_name, dir_name, size){
path = path == null ? BASE_URL : path path = path == null ? BASE_URL : path
im_name = im_name == null ? '%f' : im_name im_name = im_name == null ? '%f' : im_name
dir_name = dir_name == null ? 'fav' : dir_name dir_name = dir_name == null ? 'fav' : dir_name
size = size == null ? 1000 : size
var base_path = path var base_path = path
path = normalizePath(path) path = normalizePath(path)
@ -598,8 +598,7 @@ function exportTo(path, im_name, dir_name, size){
dest = path +'/'+ dest dest = path +'/'+ dest
// XXX link... // copy...
//console.log('>>>', dest)
copyFile(src, dest) copyFile(src, dest)
} }