toAbsolutePath method

String toAbsolutePath()

converts to absolute file path

Implementation

String toAbsolutePath() {
  String result = this
      .replaceAll('/', Platform.pathSeparator)
      .replaceAll('\\', Platform.pathSeparator);

  if (result.startsWith(Platform.pathSeparator)) {
    result = result.substring(Platform.pathSeparator.length);
  }

  if (result.endsWith(Platform.pathSeparator)) {
    result =
        result.substring(0, result.length - Platform.pathSeparator.length);
  }

  return Directory.current.path + Platform.pathSeparator + result;
}