isCivilized method

Future<bool> isCivilized(
  1. String path
)

Returns true if file streams can be manipulated independently of their paths. This is typically true for systems like Mac, Unix, and Linux that use inodes in their file system interface. It is typically false on Windows.

If this returns false we won't permit simultaneous reads and writes. When writes commit we need to delete the previous snapshots, and that won't succeed if the file is open. (We do permit multiple simultaneous reads.)

Implementation

Future<bool> isCivilized(String path) =>
    openSink(path, recursive: true).then((e) async {
      try {
        await delete(path);
        return true;
      } catch (_) {
      } finally {
        try {
          await e.close();
        } catch (_) {}
      }
      return false;
    }).whenComplete(() async {
      await delete(path, mustExist: false);
    });