Closed noppsen closed 9 years ago
It would help if you can provide some code to reproduce this issue...
On Wed, Apr 22, 2015 at 12:40 PM noppsen notifications@github.com wrote:
Hi there, I got a string based path variable from a powershell (Win7) application which can´t be handle by the copyTree method correctly when special characters appears within this path variable. Is there any way to convert or escape the path string variable or something to deal with it? Hope it´s not a silly issue kind regards
— Reply to this email directly or view it on GitHub https://github.com/kriskowal/q-io/issues/138.
Yeah Sure - so I am not the author I am not realy familiar with the code. My Issue is the method CopyTree() doesnt deal with the Path variable when some special characters like "Ä" or "²" appear in the file or folder names.
Here is some pseudo code
path = require('path');
fs = require('q-io/fs');
//*** so we have a powershell Watcher here - get´s started
PnWorker.prototype._watch = function(pattern) {
var args, cmd, dir, id, watcher,
_this = this;
dir = this._getBaseDirFromPattern(pattern);
cmd = 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe';
id = this.options.parser.input.id;
args = ["D:/deployed_versions/30Aug13/WatchITAwesome5.1.ps1", "-WatchThis", dir, "-Archivordner", id];
watcher = spawn(cmd, args);
watcher.stderr.on("data", function(data) {
var e, _error;
_this.logger.error(data.toString());
try {
watcher.kill();
} catch (_error) {
_error = _error;
e = _error;
_this.logger.debug("Can't kill", e);
}
setTimeout((function() {
return _this._watch(pattern);
}), 900000);
return watcher.stderr.destroy();
});
this.logger.debug("Watching " + dir);
return watcher.stdout.pipe(split());
};
//*** so the powershell Watcher returns a String starting with "New:" - we got a new sting based Path variable
PnWorker.prototype._newFile = function(line, cb) {
var file;
if (line.match(/^new:/)) {
file = line.replace(/^new:/, '').trim();
return cb(file);
}
};
//*** i guess we doesnt need this
PnWorker.prototype._getBaseDirFromPattern = function(pattern) {
var dir;
dir = pattern.replace(/\/[^\/]*[\*\(].*$/, '') || '/';
return path.resolve(this.options.basePath, dir);
};
//*** so we like to copy and then delete the original file
PnWorker.prototype._move = function(file) {
extension = path.extname(file);
filename = path.basename(file, extension);
src = (file);
now = new Date();
timestamp = dateformat(now, "yyyy-mm-dd'T'HH-MM-ss");
filename = "" + filename + extension;
targetFolder= path.join("some new Path", timestamp );
target = path.join( targetFolder, filename );
mkdirp(targetFolder)
fs.copyTree(src, target).then(function() {
return fs.removeTree(src);
});
};
}).call(this);
@noppsen did you mean to close this?
The only thing I can think of is that the stdout of the watcher doesn't read the files as utf-8...
Could be the point... Thank you very much so far!
so is it the point to change the powershell-watcher-Output or should I adapt the stdout-listening some how?
Not sure, you could start by outputting what you get as filenames from the watcher.
On Wed, Apr 22, 2015 at 4:13 PM noppsen notifications@github.com wrote:
Could be the point... Thank you very much so far!
so is it the point to change the powershell-watcher-Output or should I adapt the stdout-listening some how?
— Reply to this email directly or view it on GitHub https://github.com/kriskowal/q-io/issues/138#issuecomment-95196113.
Right - that worked! I changed the transfer of the path varaible to a bytes-Array and retranslate this in nodes.js. Additionally to handle all possible Windows file- and fodlernames it was necessary to escape square brackets further more.
best regards and THX very much!
Welcome :-)
On Thu, Apr 23, 2015, 12:09 PM noppsen notifications@github.com wrote:
Right - that worked! I changed the transfer of the path varaible to a bytes-Array and retranslate this in nodes.js. Additionally to handle all possible Windows file- and fodlernames it was necessary to escape square brackets further more.
best regards and THX very much!
— Reply to this email directly or view it on GitHub https://github.com/kriskowal/q-io/issues/138#issuecomment-95523581.
Hi there, I got a string based path variable from a powershell (Win7) application which can´t be handle by the copyTree method correctly when special characters appears within this path variable. Is there any way to convert or escape the path string variable or something to deal with it? Hope it´s not a silly issue kind regards