ensure directory exists only on write