Implement more portable file locking