Creates parent directories before creates file

Change-Id: I124f7ce2b731b100e9572d7c5d95206e243ee316
Signed-off-by: Roger Chen <cxr514033970@gmail.com>
(cherry picked from commit 70e94740daa83c80bc76a0c57d4d8b86cf329c1e)