Comments (7)
It would help if you can provide some code to reproduce this issue...
On Wed, Apr 22, 2015 at 12:40 PM noppsen [email protected] 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
#138.
from q-io.
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);
from q-io.
@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...
from q-io.
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?
from q-io.
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 [email protected] 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
#138 (comment).
from q-io.
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!
from q-io.
Welcome :-)
On Thu, Apr 23, 2015, 12:09 PM noppsen [email protected] 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
#138 (comment).
from q-io.
Related Issues (20)
- HTTP request fails with code 204 HOT 2
- Reader().map() fails to limit properly the number of parallel instances of a function. HOT 3
- proxy requests HOT 2
- join() doesn't support network shares HOT 4
- not able to do x-www-unencoded body HOT 5
- Crash on reading large objects HOT 1
- HTTP.read resolves with buffer instead of string HOT 1
- q-io downloading or writing too much data in version 1.13 HOT 14
- Mock: fs.copy() is buggy HOT 1
- removeTree() thinks it fails with ENOTEMPTY, but works on second try HOT 2
- `write()` resolves before content is written HOT 5
- Bump version of collections to avoid conflict with ES6 HOT 3
- filetree compatible with jstree
- `fs.copyTree` does not copy a large amount of files HOT 1
- is v2 up to date? HOT 3
- [v2] Last written file is always empty HOT 1
- Drop usage of collections, it breaks globals HOT 15
- Fixing a Prototype Override Protection Bypass Vulnerability in qs HOT 3
- Connect Timeout setting HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from q-io.