testfile static method

bool? testfile(
  1. String file,
  2. String test
)

Performs specified test on file and returns true if success; otherwise returns false;

Available test: directory: file exists and is a directory. exists: file exists. file: file exists and is a regular file. link: file exists and is a symbolic link.

Implementation

static bool? testfile(String file, String test) {
  file = FilePath.expand(file);
  switch (test) {
    case 'directory':
      return Directory(file).existsSync();
    case 'exists':
      return FileStat.statSync(file).type != FileSystemEntityType.notFound;
    case 'file':
      return File(file).existsSync();
    case 'link':
      return Link(file).existsSync();
    default:
      return null;
  }
}