Basically all methods branch out to "if windows?" inside them currently. Moving each of them to their own methods would be a little bit of an overkill IMO. 

Ideally we would create sub-components that do the locking based on the run_lock API (sharing the code which manages the file) but there is not much code IMO to refactor here.