[#2148] Raise OSError with consistent code for file and folder operations.

Problem
----------

Errors raised when trying to perform a folder specific or file specific action on  a non folder of non file return different errors in Windows and Unix.

The point of compat is to provide the same behavior on all systems.


Changes
----------

Update error handling on Windows, Linux and AIX to have same errors and error codes.


How to test
------------

reviewers: @alibotean 

check that changes make sense.

Thanks!