touch static method

bool touch(
  1. List<String> files, {
  2. bool create = true,
})

Changes the modification time of the specified files. Returns true if the operation was successful; otherwise false.

If create is set to true creates files that do not exist, reports failure if the files can not be created.

If create is set to false do not creates files that do not exist and do not reports failure about files that do not exist.

Implementation

static bool touch(List<String> files, {bool create = true}) {
  if (files.isEmpty) {
    return false;
  }

  var result = true;
  for (var file in files) {
    file = file.toString();
    if (file.isEmpty) {
      result = false;
      continue;
    }

    file = FilePath.expand(file);
    if (_isWindows) {
      if (!_touchOnWindows(file, create)) {
        result = false;
      }
    } else {
      if (!_touchOnPosix(file, create)) {
        result = false;
      }
    }
  }

  return result;
}