stat method

int stat(
  1. String pathname,
  2. Stat statbuf
)

Get file status.

Implementation

int stat(String pathname, Stat statbuf) {
  try {
    final stat = io.FileStat.statSync(pathname);
    if (stat.type == io.FileSystemEntityType.notFound) return -1;

    statbuf.st_mode = stat.mode;
    statbuf.st_size = stat.size;
    statbuf.st_atime = stat.accessed.millisecondsSinceEpoch ~/ 1000;
    statbuf.st_mtime = stat.modified.millisecondsSinceEpoch ~/ 1000;
    statbuf.st_ctime = stat.changed.millisecondsSinceEpoch ~/ 1000;
    return 0;
  } catch (_) {
    return -1;
  }
}