I am having a problem on Windows with the following code:

module mytest;

import std.stdio, std.file, std.path;

enum EXIT_SUCCESS = 0;
enum EXIT_FAILURE = -1;

int main(string[] args) {
  string appdir;
  switch(args.length-1) {
    case 0:
writeln("You must provide an argument with a valid directory path.");
      break;
    case 1:
      appdir = buildNormalizedPath(args[1]);
      if(appdir.exists && appdir.isDir) break;
    default:
writefln("Error: '%s' is not a valid directory path.", appdir);
      return EXIT_FAILURE;
  }
  writeln("OK");
  return EXIT_SUCCESS;
}

Suppose I compiled this unit on current dir and then executed these commands:

mkdir "my dir"
mytest "my dir\"

I should get "OK", but instead I get:
Error: 'my test"' is not a valid directory path.

If the trailing backslash is removed it works as intended, but IMHO buildNormalizedPath should have worked.

In any case, notice the double quote in the output. To me this suggests the backslash is acting not as a path terminator but as an escape sequence.

Reply via email to