joinPath function

String joinPath(
  1. String fDir,
  2. String fPath
)

Implementation

String joinPath(String fDir, String fPath) {
  String value = '';
  String path = Platform.isWindows
      ? fPath.replaceAll("/", Platform.pathSeparator)
      : fPath;
  String dir =
      Platform.isWindows ? fDir.replaceAll("/", Platform.pathSeparator) : fDir;
  if (dir.endsWith(Platform.pathSeparator) &&
      path.startsWith(Platform.pathSeparator)) {
    value = dir + path.substring(1);
  } else if (!dir.endsWith(Platform.pathSeparator) &&
      !path.startsWith(Platform.pathSeparator)) {
    value = dir + Platform.pathSeparator + path;
  } else {
    value = dir + path;
  }
  return value;
}