[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] another dev task before 3.2



Actually, not too many of them to change, I think. PathName had the bulk of the problems.

Also this, in the extMain.sc file in the Windows platform directory. The user might specify a path with \ (as Windows users will tend to do by habit), and they might also run code that uses / and expects to be able to parse those paths as well.

+ Char {
isPathSeparator {
^#[$\\, $/].includes(this)
}
}

This should also take care of a couple of places where sc would generate paths like \\machine\users\dir\/somefile... which, again, doesn't cause an execution error but it looks silly.

Any objection?
hjh




Index: Common/Audio/SynthDef.sc
===================================================================
--- Common/Audio/SynthDef.sc (revision 6813)
+++ Common/Audio/SynthDef.sc (working copy)
@@ -17,7 +17,8 @@
  classvar <synthDefDir;

 

  *synthDefDir_ { arg dir;
- if (dir.last != $/) { dir = dir ++ $/ };
+ if (dir.last.isPathSeparator.not)
+ { dir = dir ++ thisProcess.platform.pathSeparator };
  synthDefDir = dir;
  }

 

Index: Common/Files/PathName.sc
===================================================================
--- Common/Files/PathName.sc (revision 6813)
+++ Common/Files/PathName.sc (working copy)
@@ -44,7 +44,7 @@
  ^colonIndices ?? {
  colonIndices = List.new;
  fullPath.do({ arg eachChar, i; 
- if (eachChar == $/, { colonIndices.add(i) }); 
+ if (eachChar.isPathSeparator, { colonIndices.add(i) }); 
  });
  colonIndices
  }
@@ -82,7 +82,7 @@
  isRelativePath { ^this.isAbsolutePath.not }

 

  isAbsolutePath { 
- ^fullPath.at(0) == $/
+ ^fullPath.at(0).isPathSeparator
  }

 

  asRelativePath {
@@ -185,7 +185,7 @@
  entries {
  var path;
  path = fullPath;
- if(path.last != $/, { path = path ++ "/" });
+ if(path.last.isPathSeparator, { path = path ++ thisProcess.platform.pathSeparator });
  ^pathMatch(path ++ "*").collect({ arg item; PathName(item) });
  }

 

@@ -197,14 +197,14 @@
  var path;
  path = this.pathMatch;
  ^if(path.notEmpty, {
- path.at(0).last == $/
+ path.at(0).last.isPathSeparator
  }, { false });
  }
  isFile {
  var path;
  path = this.pathMatch;
  ^if(path.notEmpty, {
- path.at(0).last != $/
+ path.at(0).last.isPathSeparator.not
  }, { false });
  }

 

@@ -218,7 +218,7 @@
  parentPath {
  var ci = this.colonIndices;

 

- ^if((fullPath.last == $/) && (ci.size > 1), {
+ ^if((fullPath.last.isPathSeparator) && (ci.size > 1), {
  fullPath.copyRange(0, ci[ci.size - 2]);
  }, {
  fullPath.copyRange(0, this.lastColonIndex)
Index: Common/Core/Char.sc
===================================================================
--- Common/Core/Char.sc (revision 6813)
+++ Common/Core/Char.sc (working copy)
@@ -77,6 +77,9 @@
  if(this.isPrint.not,{ ^false });
  ^this.ascii != 47 and: {this.ascii != 58} and: {this.ascii != 34}
  }
+ isPathSeparator {
+ ^(this === thisProcess.platform.pathSeparator)
+ }
  < { arg aChar;
  ^this.ascii < aChar.ascii
  }


: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman