sync creates directories if nonexistent.