X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=File.js;h=2726e0ebd5aea9feaaee9243ad3cbe543d9f6c8c;hb=e39cfe56bed8c2713fd2e8c13ad2323a744c527e;hp=4c9846894f83196536449562e0ac3026e867125a;hpb=19b046e43d1b3d1c0c3572311ce26b65a763c2d7;p=app.Builder.js diff --git a/File.js b/File.js index 4c9846894..2726e0ebd 100644 --- a/File.js +++ b/File.js @@ -22,20 +22,41 @@ var File = { SEPARATOR : '/', - join : function () { - // fixme! - imports['String.js'].load(String); + // fixme - this needs a bitter location.. + // they where in a string class before, but overriding String methods is not a good normally a good idea.. + + rtrim : function (s,toTrim) { + if (s.substr(s.length - toTrim.length) == toTrim) { + return s.slice(0, s.length - toTrim.length); + } + + return s; + }, + trim : function (s,toTrim) { + var out = s.ltrim(toTrim); + out = out.rtrim(toTrim); + return out; + }, + + ltrim : function (s, toTrim) { + if (s.substr(0, toTrim.length) == toTrim) { + return s.slice(toTrim.length); + } + return s; + }, + + join : function () { var out = ""; for (var i = 0; i < arguments.length; i++) { if (i == 0) { - out += arguments[i].rtrim(File.SEPARATOR); + out += this.rtrim(arguments[i], File.SEPARATOR); } else if (i == arguments.length - 1) { - out += File.SEPARATOR + arguments[i].ltrim(File.SEPARATOR); + out += File.SEPARATOR + this.ltrim(arguments[i], File.SEPARATOR); } else { - out += File.SEPARATOR + arguments[i].trim(File.SEPARATOR); + out += File.SEPARATOR + this.trim(arguments[i], File.SEPARATOR); } } return out;