isHeld static method
Whether any holder, in this process or another, has the lock on
file. Tries a shared lock on a descriptor of its own and releases it
at once, so it never disturbs a holder, and tryExclusive does not
mistake it for one. False when file is missing.
Implementation
static Future<bool> isHeld(File file) async {
final _Handle handle;
try {
handle = await _open(file, create: false);
} on PathNotFoundException {
return false;
}
try {
return !await handle.tryLock(exclusive: false);
} finally {
await handle.close();
}
}