Dealing with issue #355; magic bit file detection on the c++ code

skip ci
Don't mix POSIX methods with with gz or bz2 functions