Function: ede-expand-filename
ede-expand-filename is a byte-compiled function defined in
files.el.gz.
Signature
(ede-expand-filename ARG &rest ARGS)
Implementations
(ede-expand-filename (THIS ede-target) FILENAME &optional FORCE) in `ede/files.el'.
Return a fully qualified file name based on target THIS. FILENAME should be a filename which occurs in a directory in which THIS works. Optional argument FORCE forces the default filename to be provided even if it doesn't exist.
(ede-expand-filename (THIS ede-project) FILENAME &optional FORCE) in `ede/files.el'.
Return a fully qualified file name based on project THIS. FILENAME should be just a filename which occurs in a directory controlled by this project. Optional argument FORCE forces the default filename to be provided even if it doesn't exist. If FORCE equals `newfile', then the cache is ignored and a new file in THIS is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/ede/files.el.gz
(cl-defmethod ede-expand-filename ((this ede-project) filename &optional force)
"Return a fully qualified file name based on project THIS.
FILENAME should be just a filename which occurs in a directory controlled
by this project.
Optional argument FORCE forces the default filename to be provided even if it
doesn't exist.
If FORCE equals `newfile', then the cache is ignored and a new file in THIS
is returned."
(require 'ede/locate)
(let* ((loc (ede-get-locator-object this))
(ha (ede-locate-file-in-hash loc filename))
(ans nil)
)
;; NOTE: This function uses a locator object, which keeps a hash
;; table of files it has found in the past. The hash table is
;; used to make commonly found file very fast to location. Some
;; complex routines, such as smart completion asks this question
;; many times, so doing this speeds things up, especially on NFS
;; or other remote file systems.
;; As such, special care is needed to use the hash, and also obey
;; the FORCE option, which is needed when trying to identify some
;; new file that needs to be created, such as a Makefile.
(cond
;; We have a hash-table match, AND that match wasn't the 'nomatch
;; flag, we can return it.
((and ha (not (eq ha 'nomatch)))
(setq ans ha))
;; If we had a match, and it WAS no match, then we need to look
;; at the force-option to see what to do. Since ans is already
;; nil, then we do nothing.
((and (eq ha 'nomatch) (not (eq force 'newfile)))
nil)
;; We had no hash table match, so we have to look up this file
;; using the usual EDE file expansion rules.
(t
(let ((calc (ede-expand-filename-impl this filename)))
(if calc
(progn
(ede-locate-add-file-to-hash loc filename calc)
(setq ans calc))
;; If we failed to calculate something, we
;; should add it to the hash, but ONLY if we are not
;; going to FORCE the file into existence.
(when (not force)
(ede-locate-add-file-to-hash loc filename 'nomatch))))
))
;; Now that all options have been queried, if the FORCE option is
;; true, but ANS is still nil, then we can make up a file name.
;; Is it forced?
(when (and force (not ans))
(let ((dir (ede-project-root-directory this)))
(setq ans (expand-file-name filename dir))))
ans))