I am working on a compression program, where I would like to make sure that none of the files that I want to compress are in use.

But, is this the best possible option.

As there may be over a thousand files that I need to compress.

If I have to check each file by opening in a binary mode, wouldn't it make it slow??