Function: org-babel-generate-file-param
org-babel-generate-file-param is a byte-compiled function defined in
ob-core.el.gz.
Signature
(org-babel-generate-file-param SRC-NAME PARAMS)
Documentation
Calculate the filename for source block results.
The directory is calculated from the :output-dir property of the source block; if not specified, use the current directory.
If the source block has a #+NAME and the :file parameter does not contain any period characters, then the :file parameter is treated as an extension, and the output file name is the concatenation of the directory (as calculated above), the block name, a period, and the parameter value as a file extension. Otherwise, the :file parameter is treated as a full file name, and the output file name is the directory (as calculated above) plus the parameter value.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
(defun org-babel-generate-file-param (src-name params)
"Calculate the filename for source block results.
The directory is calculated from the :output-dir property of the
source block; if not specified, use the current directory.
If the source block has a #+NAME and the :file parameter does not
contain any period characters, then the :file parameter is
treated as an extension, and the output file name is the
concatenation of the directory (as calculated above), the block
name, a period, and the parameter value as a file extension.
Otherwise, the :file parameter is treated as a full file name,
and the output file name is the directory (as calculated above)
plus the parameter value."
(let* ((file-cons (assq :file params))
(file-ext-cons (assq :file-ext params))
(file-ext (cdr-safe file-ext-cons))
(dir (cdr-safe (assq :output-dir params)))
fname)
;; create the output-dir if it does not exist
(when dir
(make-directory dir t))
(if file-cons
;; :file given; add :output-dir if given
(when dir
(setcdr file-cons (concat (file-name-as-directory dir) (cdr file-cons))))
;; :file not given; compute from name and :file-ext if possible
(when (and src-name file-ext)
(if dir
(setq fname (concat (file-name-as-directory (or dir ""))
src-name "." file-ext))
(setq fname (concat src-name "." file-ext)))
(setq params (cons (cons :file fname) params))))
params))