Ensure directories exist before touching stamp file