From a8ce503b925a1d96a8c811f25a6d5b1ce1ecccb0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 21 Jun 2013 17:23:09 +0400 Subject: [PATCH] more work on exportTo(..), now using node.js fs.extra... Signed-off-by: Alex A. Naanou --- ui/compatibility.js | 12 ++++++------ ui/files.js | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ui/compatibility.js b/ui/compatibility.js index 150fbb88..28a4415d 100755 --- a/ui/compatibility.js +++ b/ui/compatibility.js @@ -26,6 +26,7 @@ if(window.CEF_dumpJSON != null){ console.log('node-webkit mode: loading...') var fs = require('fs') + var fse = require('fs.extra') var proc = require('child_process') var gui = require('nw.gui') @@ -60,12 +61,12 @@ if(window.CEF_dumpJSON != null){ // XXX make dirs... if(!fs.existsSync(path)){ console.log('making:', path) - // XXX NOTE: this will not make more than one dir... - fs.mkdirSync(path) + fse.mkdirRecursiveSync(path) } if(!fs.existsSync(dst)){ - fs.linkSync(src, dst) + // NOTE: this is not sync... + return fse.copy(src, dst) } } window.dumpJSON = function(path, data){ @@ -78,9 +79,8 @@ if(window.CEF_dumpJSON != null){ dirs = dirs.join('/') // build path... if(!fs.existsSync(dirs)){ - console.log('making:', dirs, path) - // XXX NOTE: this will not make more than one dir... - fs.mkdirSync(dirs) + console.log('making:', path) + fse.mkdirRecursiveSync(path) } return fs.writeFileSync(path, JSON.stringify(data), encoding='utf8') } diff --git a/ui/files.js b/ui/files.js index 84a4a631..9dc5e45d 100755 --- a/ui/files.js +++ b/ui/files.js @@ -557,11 +557,11 @@ function updateRibbonsFromFavDirs(){ // Export current state to directory... // -// NOTE: if size is null, the original image will be copied... function exportTo(path, im_name, dir_name, size){ path = path == null ? BASE_URL : path im_name = im_name == null ? '%f' : im_name dir_name = dir_name == null ? 'fav' : dir_name + size = size == null ? 1000 : size var base_path = path path = normalizePath(path) @@ -598,8 +598,7 @@ function exportTo(path, im_name, dir_name, size){ dest = path +'/'+ dest - // XXX link... - //console.log('>>>', dest) + // copy... copyFile(src, dest) }