Improve files API. Relative path check added. Create dir for new file if missing

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>