I want to check that file is opened by another process. How can I implement such functionality?
In Windows I can write something like
try {
openFileWriter(file);
// File not locked => not opened by another process
} catch (IOException) {
// File is locked => opened by another process
}
In Linux I can use lsof.
But is there any common solution for both Linux and Windows?