Used paths functions instead of the missing sys functions

Some functions are now not present in the 'sys' package.
I used the 'paths' package instead.

I haven't found an alternative to sys.fstat().
So the cache directory will be now always recreated.