Index: test/codegen/expect/path/path.js |
diff --git a/test/codegen/expect/path/path.js b/test/codegen/expect/path/path.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a98becdaf701025a4076fe4e1ce408ae5a79ef58 |
--- /dev/null |
+++ b/test/codegen/expect/path/path.js |
@@ -0,0 +1,1070 @@ |
+dart_library.library('path', null, /* Imports */[ |
Jennifer Messerly
2016/05/06 18:53:07
feel free to .gitignore these if you don't want th
Jacob
2016/05/06 19:17:33
Added these to the .gitignore
|
+ 'dart_sdk' |
+], function(exports, dart_sdk) { |
+ 'use strict'; |
+ const core = dart_sdk.core; |
+ const dart = dart_sdk.dart; |
+ const dartx = dart_sdk.dartx; |
+ const path$ = Object.create(null); |
+ const src__context = Object.create(null); |
+ const src__style = Object.create(null); |
+ const src__style__posix = Object.create(null); |
+ const src__style__url = Object.create(null); |
+ const src__style__windows = Object.create(null); |
+ const src__utils = Object.create(null); |
+ const src__characters = Object.create(null); |
+ const src__parsed_path = Object.create(null); |
+ const src__path_exception = Object.create(null); |
+ const src__internal_style = Object.create(null); |
+ dart.defineLazy(path$, { |
+ get posix() { |
+ return src__context.Context.new({style: src__style.Style.posix}); |
+ } |
+ }); |
+ dart.defineLazy(path$, { |
+ get windows() { |
+ return src__context.Context.new({style: src__style.Style.windows}); |
+ } |
+ }); |
+ dart.defineLazy(path$, { |
+ get url() { |
+ return src__context.Context.new({style: src__style.Style.url}); |
+ } |
+ }); |
+ dart.defineLazy(path$, { |
+ get context() { |
+ return src__context.createInternal(); |
+ } |
+ }); |
+ dart.copyProperties(path$, { |
+ get style() { |
+ return path$.context.style; |
+ } |
+ }); |
+ dart.copyProperties(path$, { |
+ get current() { |
+ let uri = core.Uri.base; |
+ if (dart.equals(uri, path$._currentUriBase)) return path$._current; |
+ path$._currentUriBase = uri; |
+ if (dart.equals(src__style.Style.platform, src__style.Style.url)) { |
+ path$._current = dart.toString(uri.resolve('.')); |
+ return path$._current; |
+ } else { |
+ let path = uri.toFilePath(); |
+ let lastIndex = dart.notNull(path[dartx.length]) - 1; |
+ dart.assert(path[dartx.get](lastIndex) == '/' || path[dartx.get](lastIndex) == '\\'); |
+ path$._current = path[dartx.substring](0, lastIndex); |
+ return path$._current; |
+ } |
+ } |
+ }); |
+ path$._currentUriBase = null; |
+ path$._current = null; |
+ dart.copyProperties(path$, { |
+ get separator() { |
+ return path$.context.separator; |
+ } |
+ }); |
+ path$.absolute = function(part1, part2, part3, part4, part5, part6, part7) { |
+ if (part2 === void 0) part2 = null; |
+ if (part3 === void 0) part3 = null; |
+ if (part4 === void 0) part4 = null; |
+ if (part5 === void 0) part5 = null; |
+ if (part6 === void 0) part6 = null; |
+ if (part7 === void 0) part7 = null; |
+ return path$.context.absolute(part1, part2, part3, part4, part5, part6, part7); |
+ }; |
+ dart.fn(path$.absolute, core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String]); |
+ path$.basename = function(path) { |
+ return path$.context.basename(path); |
+ }; |
+ dart.fn(path$.basename, core.String, [core.String]); |
+ path$.basenameWithoutExtension = function(path) { |
+ return path$.context.basenameWithoutExtension(path); |
+ }; |
+ dart.fn(path$.basenameWithoutExtension, core.String, [core.String]); |
+ path$.dirname = function(path) { |
+ return path$.context.dirname(path); |
+ }; |
+ dart.fn(path$.dirname, core.String, [core.String]); |
+ path$.extension = function(path) { |
+ return path$.context.extension(path); |
+ }; |
+ dart.fn(path$.extension, core.String, [core.String]); |
+ path$.rootPrefix = function(path) { |
+ return path$.context.rootPrefix(path); |
+ }; |
+ dart.fn(path$.rootPrefix, core.String, [core.String]); |
+ path$.isAbsolute = function(path) { |
+ return path$.context.isAbsolute(path); |
+ }; |
+ dart.fn(path$.isAbsolute, core.bool, [core.String]); |
+ path$.isRelative = function(path) { |
+ return path$.context.isRelative(path); |
+ }; |
+ dart.fn(path$.isRelative, core.bool, [core.String]); |
+ path$.isRootRelative = function(path) { |
+ return path$.context.isRootRelative(path); |
+ }; |
+ dart.fn(path$.isRootRelative, core.bool, [core.String]); |
+ path$.join = function(part1, part2, part3, part4, part5, part6, part7, part8) { |
+ if (part2 === void 0) part2 = null; |
+ if (part3 === void 0) part3 = null; |
+ if (part4 === void 0) part4 = null; |
+ if (part5 === void 0) part5 = null; |
+ if (part6 === void 0) part6 = null; |
+ if (part7 === void 0) part7 = null; |
+ if (part8 === void 0) part8 = null; |
+ return path$.context.join(part1, part2, part3, part4, part5, part6, part7, part8); |
+ }; |
+ dart.fn(path$.join, core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String, core.String]); |
+ path$.joinAll = function(parts) { |
+ return path$.context.joinAll(parts); |
+ }; |
+ dart.fn(path$.joinAll, core.String, [core.Iterable$(core.String)]); |
+ path$.split = function(path) { |
+ return path$.context.split(path); |
+ }; |
+ dart.fn(path$.split, core.List$(core.String), [core.String]); |
+ path$.normalize = function(path) { |
+ return path$.context.normalize(path); |
+ }; |
+ dart.fn(path$.normalize, core.String, [core.String]); |
+ path$.relative = function(path, opts) { |
+ let from = opts && 'from' in opts ? opts.from : null; |
+ return path$.context.relative(path, {from: from}); |
+ }; |
+ dart.fn(path$.relative, core.String, [core.String], {from: core.String}); |
+ path$.isWithin = function(parent, child) { |
+ return path$.context.isWithin(parent, child); |
+ }; |
+ dart.fn(path$.isWithin, core.bool, [core.String, core.String]); |
+ path$.withoutExtension = function(path) { |
+ return path$.context.withoutExtension(path); |
+ }; |
+ dart.fn(path$.withoutExtension, core.String, [core.String]); |
+ path$.fromUri = function(uri) { |
+ return path$.context.fromUri(uri); |
+ }; |
+ dart.fn(path$.fromUri, core.String, [dart.dynamic]); |
+ path$.toUri = function(path) { |
+ return path$.context.toUri(path); |
+ }; |
+ dart.fn(path$.toUri, core.Uri, [core.String]); |
+ path$.prettyUri = function(uri) { |
+ return path$.context.prettyUri(uri); |
+ }; |
+ dart.fn(path$.prettyUri, core.String, [dart.dynamic]); |
+ const _current = Symbol('_current'); |
+ const _parse = Symbol('_parse'); |
+ const _needsNormalization = Symbol('_needsNormalization'); |
+ const _isWithinFast = Symbol('_isWithinFast'); |
+ const _pathDirection = Symbol('_pathDirection'); |
+ src__context.Context = class Context extends core.Object { |
+ static new(opts) { |
+ let style = opts && 'style' in opts ? opts.style : null; |
+ let current = opts && 'current' in opts ? opts.current : null; |
+ if (current == null) { |
+ if (style == null) { |
+ current = path$.current; |
+ } else { |
+ current = "."; |
+ } |
+ } |
+ if (style == null) { |
+ style = src__style.Style.platform; |
+ } else if (!dart.is(style, src__internal_style.InternalStyle)) { |
+ dart.throw(new core.ArgumentError("Only styles defined by the path package are " + "allowed.")); |
+ } |
+ return new src__context.Context._(dart.as(style, src__internal_style.InternalStyle), current); |
+ } |
+ _internal() { |
+ this.style = dart.as(src__style.Style.platform, src__internal_style.InternalStyle); |
+ this[_current] = null; |
+ } |
+ _(style, current) { |
+ this.style = style; |
+ this[_current] = current; |
+ } |
+ get current() { |
+ return this[_current] != null ? this[_current] : path$.current; |
+ } |
+ get separator() { |
+ return this.style.separator; |
+ } |
+ absolute(part1, part2, part3, part4, part5, part6, part7) { |
+ if (part2 === void 0) part2 = null; |
+ if (part3 === void 0) part3 = null; |
+ if (part4 === void 0) part4 = null; |
+ if (part5 === void 0) part5 = null; |
+ if (part6 === void 0) part6 = null; |
+ if (part7 === void 0) part7 = null; |
+ src__context._validateArgList("absolute", dart.list([part1, part2, part3, part4, part5, part6, part7], core.String)); |
+ if (part2 == null && dart.notNull(this.isAbsolute(part1)) && !dart.notNull(this.isRootRelative(part1))) { |
+ return part1; |
+ } |
+ return this.join(this.current, part1, part2, part3, part4, part5, part6, part7); |
+ } |
+ basename(path) { |
+ return this[_parse](path).basename; |
+ } |
+ basenameWithoutExtension(path) { |
+ return this[_parse](path).basenameWithoutExtension; |
+ } |
+ dirname(path) { |
+ let parsed = this[_parse](path); |
+ parsed.removeTrailingSeparators(); |
+ if (dart.notNull(parsed.parts[dartx.isEmpty])) return parsed.root == null ? '.' : parsed.root; |
+ if (parsed.parts[dartx.length] == 1) { |
+ return parsed.root == null ? '.' : parsed.root; |
+ } |
+ parsed.parts[dartx.removeLast](); |
+ parsed.separators[dartx.removeLast](); |
+ parsed.removeTrailingSeparators(); |
+ return dart.toString(parsed); |
+ } |
+ extension(path) { |
+ return this[_parse](path).extension; |
+ } |
+ rootPrefix(path) { |
+ return path[dartx.substring](0, this.style.rootLength(path)); |
+ } |
+ isAbsolute(path) { |
+ return dart.notNull(this.style.rootLength(path)) > 0; |
+ } |
+ isRelative(path) { |
+ return !dart.notNull(this.isAbsolute(path)); |
+ } |
+ isRootRelative(path) { |
+ return this.style.isRootRelative(path); |
+ } |
+ join(part1, part2, part3, part4, part5, part6, part7, part8) { |
+ if (part2 === void 0) part2 = null; |
+ if (part3 === void 0) part3 = null; |
+ if (part4 === void 0) part4 = null; |
+ if (part5 === void 0) part5 = null; |
+ if (part6 === void 0) part6 = null; |
+ if (part7 === void 0) part7 = null; |
+ if (part8 === void 0) part8 = null; |
+ let parts = dart.list([part1, part2, part3, part4, part5, part6, part7, part8], core.String); |
+ src__context._validateArgList("join", parts); |
+ return this.joinAll(parts[dartx.where](dart.fn(part => part != null, core.bool, [core.String]))); |
+ } |
+ joinAll(parts) { |
+ let buffer = new core.StringBuffer(); |
+ let needsSeparator = false; |
+ let isAbsoluteAndNotRootRelative = false; |
+ for (let part of parts[dartx.where](dart.fn(part => part != '', core.bool, [core.String]))) { |
+ if (dart.notNull(this.isRootRelative(part)) && isAbsoluteAndNotRootRelative) { |
+ let parsed = this[_parse](part); |
+ parsed.root = this.rootPrefix(buffer.toString()); |
+ if (dart.notNull(this.style.needsSeparator(parsed.root))) { |
+ parsed.separators[dartx.set](0, this.style.separator); |
+ } |
+ buffer.clear(); |
+ buffer.write(dart.toString(parsed)); |
+ } else if (dart.notNull(this.isAbsolute(part))) { |
+ isAbsoluteAndNotRootRelative = !dart.notNull(this.isRootRelative(part)); |
+ buffer.clear(); |
+ buffer.write(part); |
+ } else { |
+ if (dart.notNull(part[dartx.length]) > 0 && dart.notNull(this.style.containsSeparator(part[dartx.get](0)))) { |
+ } else if (dart.notNull(needsSeparator)) { |
+ buffer.write(this.separator); |
+ } |
+ buffer.write(part); |
+ } |
+ needsSeparator = this.style.needsSeparator(part); |
+ } |
+ return buffer.toString(); |
+ } |
+ split(path) { |
+ let parsed = this[_parse](path); |
+ parsed.parts = parsed.parts[dartx.where](dart.fn(part => !dart.notNull(part[dartx.isEmpty]), core.bool, [core.String]))[dartx.toList](); |
+ if (parsed.root != null) parsed.parts[dartx.insert](0, parsed.root); |
+ return parsed.parts; |
+ } |
+ normalize(path) { |
+ if (!dart.notNull(this[_needsNormalization](path))) return path; |
+ let parsed = this[_parse](path); |
+ parsed.normalize(); |
+ return dart.toString(parsed); |
+ } |
+ [_needsNormalization](path) { |
+ let start = 0; |
+ let codeUnits = path[dartx.codeUnits]; |
+ let previousPrevious = null; |
+ let previous = null; |
+ let root = this.style.rootLength(path); |
+ if (root != 0) { |
+ start = root; |
+ previous = src__characters.SLASH; |
+ if (dart.equals(this.style, src__style.Style.windows)) { |
+ for (let i = 0; i < dart.notNull(root); i++) { |
+ if (codeUnits[dartx.get](i) == src__characters.SLASH) return true; |
+ } |
+ } |
+ } |
+ for (let i = start; dart.notNull(i) < dart.notNull(codeUnits[dartx.length]); i = dart.notNull(i) + 1) { |
+ let codeUnit = codeUnits[dartx.get](i); |
+ if (dart.notNull(this.style.isSeparator(codeUnit))) { |
+ if (dart.equals(this.style, src__style.Style.windows) && codeUnit == src__characters.SLASH) return true; |
+ if (previous != null && dart.notNull(this.style.isSeparator(dart.as(previous, core.int)))) return true; |
+ if (dart.equals(previous, src__characters.PERIOD) && (previousPrevious == null || dart.equals(previousPrevious, src__characters.PERIOD) || dart.notNull(this.style.isSeparator(dart.as(previousPrevious, core.int))))) { |
+ return true; |
+ } |
+ } |
+ previousPrevious = previous; |
+ previous = codeUnit; |
+ } |
+ if (previous == null) return true; |
+ if (dart.notNull(this.style.isSeparator(dart.as(previous, core.int)))) return true; |
+ if (dart.equals(previous, src__characters.PERIOD) && (previousPrevious == null || dart.equals(previousPrevious, src__characters.SLASH) || dart.equals(previousPrevious, src__characters.PERIOD))) { |
+ return true; |
+ } |
+ return false; |
+ } |
+ relative(path, opts) { |
+ let from = opts && 'from' in opts ? opts.from : null; |
+ if (from == null && dart.notNull(this.isRelative(path))) return this.normalize(path); |
+ from = from == null ? this.current : this.absolute(from); |
+ if (dart.notNull(this.isRelative(from)) && dart.notNull(this.isAbsolute(path))) { |
+ return this.normalize(path); |
+ } |
+ if (dart.notNull(this.isRelative(path)) || dart.notNull(this.isRootRelative(path))) { |
+ path = this.absolute(path); |
+ } |
+ if (dart.notNull(this.isRelative(path)) && dart.notNull(this.isAbsolute(from))) { |
+ dart.throw(new src__path_exception.PathException(`Unable to find a path to "${path}" from "${from}".`)); |
+ } |
+ let fromParsed = this[_parse](from); |
+ fromParsed.normalize(); |
+ let pathParsed = this[_parse](path); |
+ pathParsed.normalize(); |
+ if (dart.notNull(fromParsed.parts[dartx.length]) > 0 && fromParsed.parts[dartx.get](0) == '.') { |
+ return pathParsed.toString(); |
+ } |
+ if (fromParsed.root != pathParsed.root && (fromParsed.root == null || pathParsed.root == null || fromParsed.root[dartx.toLowerCase]()[dartx.replaceAll]('/', '\\') != pathParsed.root[dartx.toLowerCase]()[dartx.replaceAll]('/', '\\'))) { |
+ return pathParsed.toString(); |
+ } |
+ while (dart.notNull(fromParsed.parts[dartx.length]) > 0 && dart.notNull(pathParsed.parts[dartx.length]) > 0 && fromParsed.parts[dartx.get](0) == pathParsed.parts[dartx.get](0)) { |
+ fromParsed.parts[dartx.removeAt](0); |
+ fromParsed.separators[dartx.removeAt](1); |
+ pathParsed.parts[dartx.removeAt](0); |
+ pathParsed.separators[dartx.removeAt](1); |
+ } |
+ if (dart.notNull(fromParsed.parts[dartx.length]) > 0 && fromParsed.parts[dartx.get](0) == '..') { |
+ dart.throw(new src__path_exception.PathException(`Unable to find a path to "${path}" from "${from}".`)); |
+ } |
+ pathParsed.parts[dartx.insertAll](0, core.List$(core.String).filled(fromParsed.parts[dartx.length], '..')); |
+ pathParsed.separators[dartx.set](0, ''); |
+ pathParsed.separators[dartx.insertAll](1, core.List$(core.String).filled(fromParsed.parts[dartx.length], this.style.separator)); |
+ if (pathParsed.parts[dartx.length] == 0) return '.'; |
+ if (dart.notNull(pathParsed.parts[dartx.length]) > 1 && pathParsed.parts[dartx.last] == '.') { |
+ pathParsed.parts[dartx.removeLast](); |
+ let _ = pathParsed.separators; |
+ _[dartx.removeLast](); |
+ _[dartx.removeLast](); |
+ _[dartx.add](''); |
+ } |
+ pathParsed.root = ''; |
+ pathParsed.removeTrailingSeparators(); |
+ return pathParsed.toString(); |
+ } |
+ isWithin(parent, child) { |
+ let parentIsAbsolute = this.isAbsolute(parent); |
+ let childIsAbsolute = this.isAbsolute(child); |
+ if (dart.notNull(parentIsAbsolute) && !dart.notNull(childIsAbsolute)) { |
+ child = this.absolute(child); |
+ if (dart.notNull(this.style.isRootRelative(parent))) parent = this.absolute(parent); |
+ } else if (dart.notNull(childIsAbsolute) && !dart.notNull(parentIsAbsolute)) { |
+ parent = this.absolute(parent); |
+ if (dart.notNull(this.style.isRootRelative(child))) child = this.absolute(child); |
+ } else if (dart.notNull(childIsAbsolute) && dart.notNull(parentIsAbsolute)) { |
+ let childIsRootRelative = this.style.isRootRelative(child); |
+ let parentIsRootRelative = this.style.isRootRelative(parent); |
+ if (dart.notNull(childIsRootRelative) && !dart.notNull(parentIsRootRelative)) { |
+ child = this.absolute(child); |
+ } else if (dart.notNull(parentIsRootRelative) && !dart.notNull(childIsRootRelative)) { |
+ parent = this.absolute(parent); |
+ } |
+ } |
+ let fastResult = this[_isWithinFast](parent, child); |
+ if (fastResult != null) return fastResult; |
+ let relative = null; |
+ try { |
+ relative = this.relative(child, {from: parent}); |
+ } catch (_) { |
+ if (dart.is(_, src__path_exception.PathException)) { |
+ return false; |
+ } else |
+ throw _; |
+ } |
+ |
+ let parts = this.split(dart.as(relative, core.String)); |
+ return dart.notNull(this.isRelative(dart.as(relative, core.String))) && parts[dartx.first] != '..' && parts[dartx.first] != '.'; |
+ } |
+ [_isWithinFast](parent, child) { |
+ if (parent == '.') parent = ''; |
+ let parentRootLength = this.style.rootLength(parent); |
+ let childRootLength = this.style.rootLength(child); |
+ if (parentRootLength != childRootLength) return false; |
+ let parentCodeUnits = parent[dartx.codeUnits]; |
+ let childCodeUnits = child[dartx.codeUnits]; |
+ for (let i = 0; i < dart.notNull(parentRootLength); i++) { |
+ let parentCodeUnit = parentCodeUnits[dartx.get](i); |
+ let childCodeUnit = childCodeUnits[dartx.get](i); |
+ if (parentCodeUnit == childCodeUnit) continue; |
+ if (!dart.notNull(this.style.isSeparator(parentCodeUnit)) || !dart.notNull(this.style.isSeparator(childCodeUnit))) { |
+ return false; |
+ } |
+ } |
+ let lastCodeUnit = src__characters.SLASH; |
+ let parentIndex = parentRootLength; |
+ let childIndex = childRootLength; |
+ while (dart.notNull(parentIndex) < dart.notNull(parent[dartx.length]) && dart.notNull(childIndex) < dart.notNull(child[dartx.length])) { |
+ let parentCodeUnit = parentCodeUnits[dartx.get](parentIndex); |
+ let childCodeUnit = childCodeUnits[dartx.get](childIndex); |
+ if (parentCodeUnit == childCodeUnit) { |
+ lastCodeUnit = parentCodeUnit; |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ childIndex = dart.notNull(childIndex) + 1; |
+ continue; |
+ } |
+ let parentIsSeparator = this.style.isSeparator(parentCodeUnit); |
+ let childIsSeparator = this.style.isSeparator(childCodeUnit); |
+ if (dart.notNull(parentIsSeparator) && dart.notNull(childIsSeparator)) { |
+ lastCodeUnit = parentCodeUnit; |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ childIndex = dart.notNull(childIndex) + 1; |
+ continue; |
+ } |
+ if (dart.notNull(parentIsSeparator) && dart.notNull(this.style.isSeparator(lastCodeUnit))) { |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ continue; |
+ } else if (dart.notNull(childIsSeparator) && dart.notNull(this.style.isSeparator(lastCodeUnit))) { |
+ childIndex = dart.notNull(childIndex) + 1; |
+ continue; |
+ } |
+ if (parentCodeUnit == src__characters.PERIOD) { |
+ if (dart.notNull(this.style.isSeparator(lastCodeUnit))) { |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ if (parentIndex == parent[dartx.length]) break; |
+ parentCodeUnit = parentCodeUnits[dartx.get](parentIndex); |
+ if (dart.notNull(this.style.isSeparator(parentCodeUnit))) { |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ continue; |
+ } |
+ if (parentCodeUnit == src__characters.PERIOD) { |
+ parentIndex = dart.notNull(parentIndex) + 1; |
+ if (parentIndex == parent[dartx.length] || dart.notNull(this.style.isSeparator(parentCodeUnits[dartx.get](parentIndex)))) { |
+ return null; |
+ } |
+ } |
+ } |
+ } |
+ if (childCodeUnit == src__characters.PERIOD) { |
+ if (dart.notNull(this.style.isSeparator(lastCodeUnit))) { |
+ childIndex = dart.notNull(childIndex) + 1; |
+ if (childIndex == child[dartx.length]) break; |
+ childCodeUnit = childCodeUnits[dartx.get](childIndex); |
+ if (dart.notNull(this.style.isSeparator(childCodeUnit))) { |
+ childIndex = dart.notNull(childIndex) + 1; |
+ continue; |
+ } |
+ if (childCodeUnit == src__characters.PERIOD) { |
+ childIndex = dart.notNull(childIndex) + 1; |
+ if (childIndex == child[dartx.length] || dart.notNull(this.style.isSeparator(childCodeUnits[dartx.get](childIndex)))) { |
+ return null; |
+ } |
+ } |
+ } |
+ } |
+ let childDirection = this[_pathDirection](childCodeUnits, childIndex); |
+ if (!dart.equals(childDirection, src__context._PathDirection.belowRoot)) return null; |
+ let parentDirection = this[_pathDirection](parentCodeUnits, parentIndex); |
+ if (!dart.equals(parentDirection, src__context._PathDirection.belowRoot)) return null; |
+ return false; |
+ } |
+ if (childIndex == child[dartx.length]) { |
+ let direction = this[_pathDirection](parentCodeUnits, parentIndex); |
+ return dart.equals(direction, src__context._PathDirection.aboveRoot) ? null : false; |
+ } |
+ let direction = this[_pathDirection](childCodeUnits, childIndex); |
+ if (dart.equals(direction, src__context._PathDirection.atRoot)) return false; |
+ if (dart.equals(direction, src__context._PathDirection.aboveRoot)) return null; |
+ return dart.notNull(this.style.isSeparator(childCodeUnits[dartx.get](childIndex))) || dart.notNull(this.style.isSeparator(lastCodeUnit)); |
+ } |
+ [_pathDirection](codeUnits, index) { |
+ let depth = 0; |
+ let reachedRoot = false; |
+ let i = index; |
+ while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length])) { |
+ while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length]) && dart.notNull(this.style.isSeparator(codeUnits[dartx.get](i)))) { |
+ i = dart.notNull(i) + 1; |
+ } |
+ if (i == codeUnits[dartx.length]) break; |
+ let start = i; |
+ while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length]) && !dart.notNull(this.style.isSeparator(codeUnits[dartx.get](i)))) { |
+ i = dart.notNull(i) + 1; |
+ } |
+ if (dart.notNull(i) - dart.notNull(start) == 1 && codeUnits[dartx.get](start) == src__characters.PERIOD) { |
+ } else if (dart.notNull(i) - dart.notNull(start) == 2 && codeUnits[dartx.get](start) == src__characters.PERIOD && codeUnits[dartx.get](dart.notNull(start) + 1) == src__characters.PERIOD) { |
+ depth--; |
+ if (depth < 0) break; |
+ if (depth == 0) reachedRoot = true; |
+ } else { |
+ depth++; |
+ } |
+ if (i == codeUnits[dartx.length]) break; |
+ i = dart.notNull(i) + 1; |
+ } |
+ if (depth < 0) return src__context._PathDirection.aboveRoot; |
+ if (depth == 0) return src__context._PathDirection.atRoot; |
+ if (reachedRoot) return src__context._PathDirection.reachesRoot; |
+ return src__context._PathDirection.belowRoot; |
+ } |
+ withoutExtension(path) { |
+ let parsed = this[_parse](path); |
+ for (let i = dart.notNull(parsed.parts[dartx.length]) - 1; i >= 0; i--) { |
+ if (!dart.notNull(parsed.parts[dartx.get](i)[dartx.isEmpty])) { |
+ parsed.parts[dartx.set](i, parsed.basenameWithoutExtension); |
+ break; |
+ } |
+ } |
+ return dart.toString(parsed); |
+ } |
+ fromUri(uri) { |
+ if (typeof uri == 'string') uri = core.Uri.parse(dart.as(uri, core.String)); |
+ return this.style.pathFromUri(dart.as(uri, core.Uri)); |
+ } |
+ toUri(path) { |
+ if (dart.notNull(this.isRelative(path))) { |
+ return this.style.relativePathToUri(path); |
+ } else { |
+ return this.style.absolutePathToUri(this.join(this.current, path)); |
+ } |
+ } |
+ prettyUri(uri) { |
+ if (typeof uri == 'string') uri = core.Uri.parse(dart.as(uri, core.String)); |
+ if (dart.equals(dart.dload(uri, 'scheme'), 'file') && dart.equals(this.style, src__style.Style.url)) return dart.toString(uri); |
+ if (!dart.equals(dart.dload(uri, 'scheme'), 'file') && !dart.equals(dart.dload(uri, 'scheme'), '') && !dart.equals(this.style, src__style.Style.url)) { |
+ return dart.toString(uri); |
+ } |
+ let path = this.normalize(this.fromUri(uri)); |
+ let rel = this.relative(path); |
+ return dart.notNull(this.split(rel)[dartx.length]) > dart.notNull(this.split(path)[dartx.length]) ? path : rel; |
+ } |
+ [_parse](path) { |
+ return src__parsed_path.ParsedPath.parse(path, this.style); |
+ } |
+ }; |
+ dart.defineNamedConstructor(src__context.Context, '_internal'); |
+ dart.defineNamedConstructor(src__context.Context, '_'); |
+ dart.setSignature(src__context.Context, { |
+ constructors: () => ({ |
+ new: [src__context.Context, [], {style: src__style.Style, current: core.String}], |
+ _internal: [src__context.Context, []], |
+ _: [src__context.Context, [src__internal_style.InternalStyle, core.String]] |
+ }), |
+ methods: () => ({ |
+ absolute: [core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String]], |
+ basename: [core.String, [core.String]], |
+ basenameWithoutExtension: [core.String, [core.String]], |
+ dirname: [core.String, [core.String]], |
+ extension: [core.String, [core.String]], |
+ rootPrefix: [core.String, [core.String]], |
+ isAbsolute: [core.bool, [core.String]], |
+ isRelative: [core.bool, [core.String]], |
+ isRootRelative: [core.bool, [core.String]], |
+ join: [core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String, core.String]], |
+ joinAll: [core.String, [core.Iterable$(core.String)]], |
+ split: [core.List$(core.String), [core.String]], |
+ normalize: [core.String, [core.String]], |
+ [_needsNormalization]: [core.bool, [core.String]], |
+ relative: [core.String, [core.String], {from: core.String}], |
+ isWithin: [core.bool, [core.String, core.String]], |
+ [_isWithinFast]: [core.bool, [core.String, core.String]], |
+ [_pathDirection]: [src__context._PathDirection, [core.List$(core.int), core.int]], |
+ withoutExtension: [core.String, [core.String]], |
+ fromUri: [core.String, [dart.dynamic]], |
+ toUri: [core.Uri, [core.String]], |
+ prettyUri: [core.String, [dart.dynamic]], |
+ [_parse]: [src__parsed_path.ParsedPath, [core.String]] |
+ }) |
+ }); |
+ path$.Context = src__context.Context; |
+ src__path_exception.PathException = class PathException extends core.Object { |
+ PathException(message) { |
+ this.message = message; |
+ } |
+ toString() { |
+ return `PathException: ${this.message}`; |
+ } |
+ }; |
+ src__path_exception.PathException[dart.implements] = () => [core.Exception]; |
+ dart.setSignature(src__path_exception.PathException, { |
+ constructors: () => ({PathException: [src__path_exception.PathException, [core.String]]}) |
+ }); |
+ path$.PathException = src__path_exception.PathException; |
+ src__style.Style = class Style extends core.Object { |
+ static _getPlatformStyle() { |
+ if (core.Uri.base.scheme != 'file') return src__style.Style.url; |
+ if (!dart.notNull(core.Uri.base.path[dartx.endsWith]('/'))) return src__style.Style.url; |
+ if (core.Uri.new({path: 'a/b'}).toFilePath() == 'a\\b') return src__style.Style.windows; |
+ return src__style.Style.posix; |
+ } |
+ get context() { |
+ return src__context.Context.new({style: this}); |
+ } |
+ toString() { |
+ return this.name; |
+ } |
+ }; |
+ dart.setSignature(src__style.Style, { |
+ statics: () => ({_getPlatformStyle: [src__style.Style, []]}), |
+ names: ['_getPlatformStyle'] |
+ }); |
+ dart.defineLazy(src__style.Style, { |
+ get posix() { |
+ return new src__style__posix.PosixStyle(); |
+ }, |
+ get windows() { |
+ return new src__style__windows.WindowsStyle(); |
+ }, |
+ get url() { |
+ return new src__style__url.UrlStyle(); |
+ }, |
+ get platform() { |
+ return src__style.Style._getPlatformStyle(); |
+ } |
+ }); |
+ path$.Style = src__style.Style; |
+ src__context.createInternal = function() { |
+ return new src__context.Context._internal(); |
+ }; |
+ dart.fn(src__context.createInternal, src__context.Context, []); |
+ src__context._validateArgList = function(method, args) { |
+ for (let i = 1; i < dart.notNull(args[dartx.length]); i++) { |
+ if (args[dartx.get](i) == null || args[dartx.get](i - 1) != null) continue; |
+ let numArgs = null; |
+ for (numArgs = args[dartx.length]; dart.notNull(dart.as(dart.dsend(numArgs, '>=', 1), core.bool)); numArgs = dart.dsend(numArgs, '-', 1)) { |
+ if (args[dartx.get](dart.as(dart.dsend(numArgs, '-', 1), core.int)) != null) break; |
+ } |
+ let message = new core.StringBuffer(); |
+ message.write(`${method}(`); |
+ message.write(args[dartx.take](dart.as(numArgs, core.int))[dartx.map](core.String)(dart.fn(arg => arg == null ? "null" : `"${arg}"`, core.String, [core.String]))[dartx.join](", ")); |
+ message.write(`): part ${i - 1} was null, but part ${i} was not.`); |
+ dart.throw(new core.ArgumentError(message.toString())); |
+ } |
+ }; |
+ dart.fn(src__context._validateArgList, dart.dynamic, [core.String, core.List$(core.String)]); |
+ src__context._PathDirection = class _PathDirection extends core.Object { |
+ _PathDirection(name) { |
+ this.name = name; |
+ } |
+ toString() { |
+ return this.name; |
+ } |
+ }; |
+ dart.setSignature(src__context._PathDirection, { |
+ constructors: () => ({_PathDirection: [src__context._PathDirection, [core.String]]}) |
+ }); |
+ dart.defineLazy(src__context._PathDirection, { |
+ get aboveRoot() { |
+ return dart.const(new src__context._PathDirection("above root")); |
+ }, |
+ get atRoot() { |
+ return dart.const(new src__context._PathDirection("at root")); |
+ }, |
+ get reachesRoot() { |
+ return dart.const(new src__context._PathDirection("reaches root")); |
+ }, |
+ get belowRoot() { |
+ return dart.const(new src__context._PathDirection("below root")); |
+ } |
+ }); |
+ src__internal_style.InternalStyle = class InternalStyle extends src__style.Style { |
+ getRoot(path) { |
+ let length = this.rootLength(path); |
+ if (dart.notNull(length) > 0) return path[dartx.substring](0, length); |
+ return dart.notNull(this.isRootRelative(path)) ? path[dartx.get](0) : null; |
+ } |
+ relativePathToUri(path) { |
+ let segments = this.context.split(path); |
+ if (dart.notNull(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[dartx.length]) - 1)))) segments[dartx.add](''); |
+ return core.Uri.new({pathSegments: segments}); |
+ } |
+ }; |
+ dart.setSignature(src__internal_style.InternalStyle, { |
+ methods: () => ({ |
+ getRoot: [core.String, [core.String]], |
+ relativePathToUri: [core.Uri, [core.String]] |
+ }) |
+ }); |
+ src__style__posix.PosixStyle = class PosixStyle extends src__internal_style.InternalStyle { |
+ PosixStyle() { |
+ this.separatorPattern = core.RegExp.new('/'); |
+ this.needsSeparatorPattern = core.RegExp.new('[^/]$'); |
+ this.rootPattern = core.RegExp.new('^/'); |
+ this.name = 'posix'; |
+ this.separator = '/'; |
+ this.separators = dart.const(dart.list(['/'], core.String)); |
+ this.relativeRootPattern = null; |
+ } |
+ containsSeparator(path) { |
+ return path[dartx.contains]('/'); |
+ } |
+ isSeparator(codeUnit) { |
+ return codeUnit == src__characters.SLASH; |
+ } |
+ needsSeparator(path) { |
+ return dart.notNull(path[dartx.isNotEmpty]) && !dart.notNull(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[dartx.length]) - 1))); |
+ } |
+ rootLength(path) { |
+ if (dart.notNull(path[dartx.isNotEmpty]) && dart.notNull(this.isSeparator(path[dartx.codeUnitAt](0)))) return 1; |
+ return 0; |
+ } |
+ isRootRelative(path) { |
+ return false; |
+ } |
+ getRelativeRoot(path) { |
+ return null; |
+ } |
+ pathFromUri(uri) { |
+ if (uri.scheme == '' || uri.scheme == 'file') { |
+ return core.Uri.decodeComponent(uri.path); |
+ } |
+ dart.throw(new core.ArgumentError(`Uri ${uri} must have scheme 'file:'.`)); |
+ } |
+ absolutePathToUri(path) { |
+ let parsed = src__parsed_path.ParsedPath.parse(path, this); |
+ if (dart.notNull(parsed.parts[dartx.isEmpty])) { |
+ parsed.parts[dartx.addAll](dart.list(["", ""], core.String)); |
+ } else if (dart.notNull(parsed.hasTrailingSeparator)) { |
+ parsed.parts[dartx.add](""); |
+ } |
+ return core.Uri.new({scheme: 'file', pathSegments: parsed.parts}); |
+ } |
+ }; |
+ dart.setSignature(src__style__posix.PosixStyle, { |
+ constructors: () => ({PosixStyle: [src__style__posix.PosixStyle, []]}), |
+ methods: () => ({ |
+ containsSeparator: [core.bool, [core.String]], |
+ isSeparator: [core.bool, [core.int]], |
+ needsSeparator: [core.bool, [core.String]], |
+ rootLength: [core.int, [core.String]], |
+ isRootRelative: [core.bool, [core.String]], |
+ getRelativeRoot: [core.String, [core.String]], |
+ pathFromUri: [core.String, [core.Uri]], |
+ absolutePathToUri: [core.Uri, [core.String]] |
+ }) |
+ }); |
+ src__style__url.UrlStyle = class UrlStyle extends src__internal_style.InternalStyle { |
+ UrlStyle() { |
+ this.separatorPattern = core.RegExp.new('/'); |
+ this.needsSeparatorPattern = core.RegExp.new("(^[a-zA-Z][-+.a-zA-Z\\d]*://|[^/])$"); |
+ this.rootPattern = core.RegExp.new("[a-zA-Z][-+.a-zA-Z\\d]*://[^/]*"); |
+ this.relativeRootPattern = core.RegExp.new("^/"); |
+ this.name = 'url'; |
+ this.separator = '/'; |
+ this.separators = dart.const(dart.list(['/'], core.String)); |
+ } |
+ containsSeparator(path) { |
+ return path[dartx.contains]('/'); |
+ } |
+ isSeparator(codeUnit) { |
+ return codeUnit == src__characters.SLASH; |
+ } |
+ needsSeparator(path) { |
+ if (dart.notNull(path[dartx.isEmpty])) return false; |
+ if (!dart.notNull(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[dartx.length]) - 1)))) return true; |
+ return dart.notNull(path[dartx.endsWith]("://")) && this.rootLength(path) == path[dartx.length]; |
+ } |
+ rootLength(path) { |
+ if (dart.notNull(path[dartx.isEmpty])) return 0; |
+ if (dart.notNull(this.isSeparator(path[dartx.codeUnitAt](0)))) return 1; |
+ let index = path[dartx.indexOf]("/"); |
+ if (dart.notNull(index) > 0 && dart.notNull(path[dartx.startsWith]('://', dart.notNull(index) - 1))) { |
+ index = path[dartx.indexOf]('/', dart.notNull(index) + 2); |
+ if (dart.notNull(index) > 0) return index; |
+ return path[dartx.length]; |
+ } |
+ return 0; |
+ } |
+ isRootRelative(path) { |
+ return dart.notNull(path[dartx.isNotEmpty]) && dart.notNull(this.isSeparator(path[dartx.codeUnitAt](0))); |
+ } |
+ getRelativeRoot(path) { |
+ return dart.notNull(this.isRootRelative(path)) ? '/' : null; |
+ } |
+ pathFromUri(uri) { |
+ return dart.toString(uri); |
+ } |
+ relativePathToUri(path) { |
+ return core.Uri.parse(path); |
+ } |
+ absolutePathToUri(path) { |
+ return core.Uri.parse(path); |
+ } |
+ }; |
+ dart.setSignature(src__style__url.UrlStyle, { |
+ constructors: () => ({UrlStyle: [src__style__url.UrlStyle, []]}), |
+ methods: () => ({ |
+ containsSeparator: [core.bool, [core.String]], |
+ isSeparator: [core.bool, [core.int]], |
+ needsSeparator: [core.bool, [core.String]], |
+ rootLength: [core.int, [core.String]], |
+ isRootRelative: [core.bool, [core.String]], |
+ getRelativeRoot: [core.String, [core.String]], |
+ pathFromUri: [core.String, [core.Uri]], |
+ absolutePathToUri: [core.Uri, [core.String]] |
+ }) |
+ }); |
+ src__style__windows.WindowsStyle = class WindowsStyle extends src__internal_style.InternalStyle { |
+ WindowsStyle() { |
+ this.separatorPattern = core.RegExp.new('[/\\\\]'); |
+ this.needsSeparatorPattern = core.RegExp.new('[^/\\\\]$'); |
+ this.rootPattern = core.RegExp.new('^(\\\\\\\\[^\\\\]+\\\\[^\\\\/]+|[a-zA-Z]:[/\\\\])'); |
+ this.relativeRootPattern = core.RegExp.new("^[/\\\\](?![/\\\\])"); |
+ this.name = 'windows'; |
+ this.separator = '\\'; |
+ this.separators = dart.const(dart.list(['/', '\\'], core.String)); |
+ } |
+ containsSeparator(path) { |
+ return path[dartx.contains]('/'); |
+ } |
+ isSeparator(codeUnit) { |
+ return codeUnit == src__characters.SLASH || codeUnit == src__characters.BACKSLASH; |
+ } |
+ needsSeparator(path) { |
+ if (dart.notNull(path[dartx.isEmpty])) return false; |
+ return !dart.notNull(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[dartx.length]) - 1))); |
+ } |
+ rootLength(path) { |
+ if (dart.notNull(path[dartx.isEmpty])) return 0; |
+ if (path[dartx.codeUnitAt](0) == src__characters.SLASH) return 1; |
+ if (path[dartx.codeUnitAt](0) == src__characters.BACKSLASH) { |
+ if (dart.notNull(path[dartx.length]) < 2 || path[dartx.codeUnitAt](1) != src__characters.BACKSLASH) return 1; |
+ let index = path[dartx.indexOf]('\\', 2); |
+ if (dart.notNull(index) > 0) { |
+ index = path[dartx.indexOf]('\\', dart.notNull(index) + 1); |
+ if (dart.notNull(index) > 0) return index; |
+ } |
+ return path[dartx.length]; |
+ } |
+ if (dart.notNull(path[dartx.length]) < 3) return 0; |
+ if (!dart.notNull(src__utils.isAlphabetic(path[dartx.codeUnitAt](0)))) return 0; |
+ if (path[dartx.codeUnitAt](1) != src__characters.COLON) return 0; |
+ if (!dart.notNull(this.isSeparator(path[dartx.codeUnitAt](2)))) return 0; |
+ return 3; |
+ } |
+ isRootRelative(path) { |
+ return this.rootLength(path) == 1; |
+ } |
+ getRelativeRoot(path) { |
+ let length = this.rootLength(path); |
+ if (length == 1) return path[dartx.get](0); |
+ return null; |
+ } |
+ pathFromUri(uri) { |
+ if (uri.scheme != '' && uri.scheme != 'file') { |
+ dart.throw(new core.ArgumentError(`Uri ${uri} must have scheme 'file:'.`)); |
+ } |
+ let path = uri.path; |
+ if (uri.host == '') { |
+ if (dart.notNull(path[dartx.startsWith]('/'))) path = path[dartx.replaceFirst]("/", ""); |
+ } else { |
+ path = `\\\\${uri.host}${path}`; |
+ } |
+ return core.Uri.decodeComponent(path[dartx.replaceAll]("/", "\\")); |
+ } |
+ absolutePathToUri(path) { |
+ let parsed = src__parsed_path.ParsedPath.parse(path, this); |
+ if (dart.notNull(parsed.root[dartx.startsWith]('\\\\'))) { |
+ let rootParts = parsed.root[dartx.split]('\\')[dartx.where](dart.fn(part => part != '', core.bool, [core.String])); |
+ parsed.parts[dartx.insert](0, rootParts[dartx.last]); |
+ if (dart.notNull(parsed.hasTrailingSeparator)) { |
+ parsed.parts[dartx.add](""); |
+ } |
+ return core.Uri.new({scheme: 'file', host: rootParts[dartx.first], pathSegments: parsed.parts}); |
+ } else { |
+ if (parsed.parts[dartx.length] == 0 || dart.notNull(parsed.hasTrailingSeparator)) { |
+ parsed.parts[dartx.add](""); |
+ } |
+ parsed.parts[dartx.insert](0, parsed.root[dartx.replaceAll]("/", "")[dartx.replaceAll]("\\", "")); |
+ return core.Uri.new({scheme: 'file', pathSegments: parsed.parts}); |
+ } |
+ } |
+ }; |
+ dart.setSignature(src__style__windows.WindowsStyle, { |
+ constructors: () => ({WindowsStyle: [src__style__windows.WindowsStyle, []]}), |
+ methods: () => ({ |
+ containsSeparator: [core.bool, [core.String]], |
+ isSeparator: [core.bool, [core.int]], |
+ needsSeparator: [core.bool, [core.String]], |
+ rootLength: [core.int, [core.String]], |
+ isRootRelative: [core.bool, [core.String]], |
+ getRelativeRoot: [core.String, [core.String]], |
+ pathFromUri: [core.String, [core.Uri]], |
+ absolutePathToUri: [core.Uri, [core.String]] |
+ }) |
+ }); |
+ src__utils.isAlphabetic = function(char) { |
+ return dart.notNull(char) >= dart.notNull(src__characters.UPPER_A) && dart.notNull(char) <= dart.notNull(src__characters.UPPER_Z) || dart.notNull(char) >= dart.notNull(src__characters.LOWER_A) && dart.notNull(char) <= dart.notNull(src__characters.LOWER_Z); |
+ }; |
+ dart.fn(src__utils.isAlphabetic, core.bool, [core.int]); |
+ src__utils.isNumeric = function(char) { |
+ return dart.notNull(char) >= dart.notNull(src__characters.ZERO) && dart.notNull(char) <= dart.notNull(src__characters.NINE); |
+ }; |
+ dart.fn(src__utils.isNumeric, core.bool, [core.int]); |
+ src__characters.PLUS = 43; |
+ src__characters.MINUS = 45; |
+ src__characters.PERIOD = 46; |
+ src__characters.SLASH = 47; |
+ src__characters.ZERO = 48; |
+ src__characters.NINE = 57; |
+ src__characters.COLON = 58; |
+ src__characters.UPPER_A = 65; |
+ src__characters.UPPER_Z = 90; |
+ src__characters.LOWER_A = 97; |
+ src__characters.LOWER_Z = 122; |
+ src__characters.BACKSLASH = 92; |
+ const _splitExtension = Symbol('_splitExtension'); |
+ src__parsed_path.ParsedPath = class ParsedPath extends core.Object { |
+ get extension() { |
+ return this[_splitExtension]()[dartx.get](1); |
+ } |
+ get isAbsolute() { |
+ return this.root != null; |
+ } |
+ static parse(path, style) { |
+ let root = style.getRoot(path); |
+ let isRootRelative = style.isRootRelative(path); |
+ if (root != null) path = path[dartx.substring](root[dartx.length]); |
+ let parts = dart.list([], core.String); |
+ let separators = dart.list([], core.String); |
+ let start = 0; |
+ if (dart.notNull(path[dartx.isNotEmpty]) && dart.notNull(style.isSeparator(path[dartx.codeUnitAt](0)))) { |
+ separators[dartx.add](path[dartx.get](0)); |
+ start = 1; |
+ } else { |
+ separators[dartx.add](''); |
+ } |
+ for (let i = start; i < dart.notNull(path[dartx.length]); i++) { |
+ if (dart.notNull(style.isSeparator(path[dartx.codeUnitAt](i)))) { |
+ parts[dartx.add](path[dartx.substring](start, i)); |
+ separators[dartx.add](path[dartx.get](i)); |
+ start = i + 1; |
+ } |
+ } |
+ if (start < dart.notNull(path[dartx.length])) { |
+ parts[dartx.add](path[dartx.substring](start)); |
+ separators[dartx.add](''); |
+ } |
+ return new src__parsed_path.ParsedPath._(style, root, isRootRelative, parts, separators); |
+ } |
+ _(style, root, isRootRelative, parts, separators) { |
+ this.style = style; |
+ this.root = root; |
+ this.isRootRelative = isRootRelative; |
+ this.parts = parts; |
+ this.separators = separators; |
+ } |
+ get basename() { |
+ let copy = this.clone(); |
+ copy.removeTrailingSeparators(); |
+ if (dart.notNull(copy.parts[dartx.isEmpty])) return this.root == null ? '' : this.root; |
+ return copy.parts[dartx.last]; |
+ } |
+ get basenameWithoutExtension() { |
+ return this[_splitExtension]()[dartx.get](0); |
+ } |
+ get hasTrailingSeparator() { |
+ return !dart.notNull(this.parts[dartx.isEmpty]) && (this.parts[dartx.last] == '' || this.separators[dartx.last] != ''); |
+ } |
+ removeTrailingSeparators() { |
+ while (!dart.notNull(this.parts[dartx.isEmpty]) && this.parts[dartx.last] == '') { |
+ this.parts[dartx.removeLast](); |
+ this.separators[dartx.removeLast](); |
+ } |
+ if (dart.notNull(this.separators[dartx.length]) > 0) this.separators[dartx.set](dart.notNull(this.separators[dartx.length]) - 1, ''); |
+ } |
+ normalize() { |
+ let leadingDoubles = 0; |
+ let newParts = dart.list([], core.String); |
+ for (let part of this.parts) { |
+ if (part == '.' || part == '') { |
+ } else if (part == '..') { |
+ if (dart.notNull(newParts[dartx.length]) > 0) { |
+ newParts[dartx.removeLast](); |
+ } else { |
+ leadingDoubles++; |
+ } |
+ } else { |
+ newParts[dartx.add](part); |
+ } |
+ } |
+ if (!dart.notNull(this.isAbsolute)) { |
+ newParts[dartx.insertAll](0, core.List$(core.String).filled(leadingDoubles, '..')); |
+ } |
+ if (newParts[dartx.length] == 0 && !dart.notNull(this.isAbsolute)) { |
+ newParts[dartx.add]('.'); |
+ } |
+ let newSeparators = core.List$(core.String).generate(newParts[dartx.length], dart.fn(_ => this.style.separator, core.String, [core.int]), {growable: true}); |
+ newSeparators[dartx.insert](0, dart.notNull(this.isAbsolute) && dart.notNull(newParts[dartx.length]) > 0 && dart.notNull(this.style.needsSeparator(this.root)) ? this.style.separator : ''); |
+ this.parts = newParts; |
+ this.separators = newSeparators; |
+ if (this.root != null && dart.equals(this.style, src__style.Style.windows)) { |
+ this.root = this.root[dartx.replaceAll]('/', '\\'); |
+ } |
+ this.removeTrailingSeparators(); |
+ } |
+ toString() { |
+ let builder = new core.StringBuffer(); |
+ if (this.root != null) builder.write(this.root); |
+ for (let i = 0; i < dart.notNull(this.parts[dartx.length]); i++) { |
+ builder.write(this.separators[dartx.get](i)); |
+ builder.write(this.parts[dartx.get](i)); |
+ } |
+ builder.write(this.separators[dartx.last]); |
+ return builder.toString(); |
+ } |
+ [_splitExtension]() { |
+ let file = this.parts[dartx.lastWhere](dart.fn(p => p != '', core.bool, [core.String]), {orElse: dart.fn(() => null, core.String, [])}); |
+ if (file == null) return dart.list(['', ''], core.String); |
+ if (file == '..') return dart.list(['..', ''], core.String); |
+ let lastDot = file[dartx.lastIndexOf]('.'); |
+ if (dart.notNull(lastDot) <= 0) return dart.list([file, ''], core.String); |
+ return dart.list([file[dartx.substring](0, lastDot), file[dartx.substring](lastDot)], core.String); |
+ } |
+ clone() { |
+ return new src__parsed_path.ParsedPath._(this.style, this.root, this.isRootRelative, core.List$(core.String).from(this.parts), core.List$(core.String).from(this.separators)); |
+ } |
+ }; |
+ dart.defineNamedConstructor(src__parsed_path.ParsedPath, '_'); |
+ dart.setSignature(src__parsed_path.ParsedPath, { |
+ constructors: () => ({ |
+ parse: [src__parsed_path.ParsedPath, [core.String, src__internal_style.InternalStyle]], |
+ _: [src__parsed_path.ParsedPath, [src__internal_style.InternalStyle, core.String, core.bool, core.List$(core.String), core.List$(core.String)]] |
+ }), |
+ methods: () => ({ |
+ removeTrailingSeparators: [dart.void, []], |
+ normalize: [dart.void, []], |
+ [_splitExtension]: [core.List$(core.String), []], |
+ clone: [src__parsed_path.ParsedPath, []] |
+ }) |
+ }); |
+ // Exports: |
+ exports.path = path$; |
+ exports.src__context = src__context; |
+ exports.src__style = src__style; |
+ exports.src__style__posix = src__style__posix; |
+ exports.src__style__url = src__style__url; |
+ exports.src__style__windows = src__style__windows; |
+ exports.src__utils = src__utils; |
+ exports.src__characters = src__characters; |
+ exports.src__parsed_path = src__parsed_path; |
+ exports.src__path_exception = src__path_exception; |
+ exports.src__internal_style = src__internal_style; |
+}); |