Giter Club home page Giter Club logo

Comments (7)

wmertens avatar wmertens commented on July 26, 2024

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.

noppsen avatar noppsen commented on July 26, 2024

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.

wmertens avatar wmertens commented on July 26, 2024

@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.

noppsen avatar noppsen commented on July 26, 2024

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.

wmertens avatar wmertens commented on July 26, 2024

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.

noppsen avatar noppsen commented on July 26, 2024

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.

wmertens avatar wmertens commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.