Added temp_dir check and read/write access checks