ensure the makedirs creates all parent directories and not just the one one level above the path parameter

The file.makedirs command currently only attempts to create the directory one level above the given path. In the case the directory two or more levels above the path does not exist, the command will fail.

This behavior affects the file-state and is also described in pull request #4469