chdir static method

bool chdir(
  1. String name
)

Changes the current directory to name. Returns true if the operation was successful; otherwise false.

Implementation

static bool chdir(String name) {
  if (name.isEmpty) {
    return false;
  }

  name = FilePath.expand(name);
  final directory = Directory(name);
  if (!directory.existsSync()) {
    return false;
  }

  try {
    Directory.current = directory;
  } catch (e) {
    return false;
  }

  return true;
}