Q:

How to make emacs execute function only a specific dir/file doesn't exist

I want Emacs to execute a function if and only if a specific directory or file under .emacs.d doesn't exist. What should I add to init.el?
Suppose that the dir or file name is dir, and the function name is fun.

A:

I am a beginner Lisp programmer but probably something like this:
(setq dir "~/.emacs.d")

(defun fun()
  (message "fun called")
  )

(defun funp(dir fn)
  (if (not (file-exists-p dir)) (funcall fn))
  )

Set dir to what you need. Usage:
(funp dir 'fun)

