• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vl
        • Syntax
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Vl-loadstate
          • Lexer
          • Parser
          • Vl-load-merge-descriptions
          • Vl-find-basename/extension
          • Vl-load-file
          • Vl-loadresult
          • Vl-find-file
            • Vl-slow-find-file-aux
            • Vl-cache-find-file-aux
            • Vl-extend-pathname
            • Vl-file-exists-p
            • Vl-ends-with-directory-separatorp
            • Vl-dirlist-cache
            • Vl-dircache
          • Scope-of-defines
          • Vl-flush-out-descriptions
          • Vl-description
          • Vl-read-file
          • Vl-includeskips-report-gather
          • Vl-load-main
          • Extended-characters
          • Vl-load
          • Vl-load-description
          • Vl-preprocess-debug
          • Vl-descriptions-left-to-load
          • Inject-warnings
          • Vl-read-file-report-gather
          • Vl-write-preprocessor-debug-file
          • Vl-load-descriptions
          • Vl-load-files
          • Translate-off
          • Vl-load-read-file-hook
          • Vl-loadstate-pad
          • Vl-read-file-report
          • Vl-load-summary
          • Vl-collect-modules-from-descriptions
          • Vl-loadstate->warnings
          • Vl-iskips-report
          • Vl-descriptionlist
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Testing-utilities
    • Math
  • Loader

Vl-find-file

Determine where to load a file from, given its (absolute or relative) name and a list of directories to search.

Signature
(vl-find-file filename searchcache state) 
  → 
(mv realpath state)
Arguments
filename — Absolute or relative name of the file you want to load.
    Guard (stringp filename).
searchcache — Directories to search, with cached file lists.
    Guard (vl-dirlist-cache-p searchcache).
Returns
realpath — On success, the full dirname/filename path to the first found file. Otherwise NIL to indicate that no such file is found in any of these directories.
    Type (maybe-stringp realpath).
state — Type (state-p1 state), given (force (state-p1 state)).

Definitions and Theorems

Function: vl-find-file

(defun
     vl-find-file
     (filename searchcache state)
     (declare (xargs :stobjs (state)))
     (declare (xargs :guard (and (stringp filename)
                                 (vl-dirlist-cache-p searchcache))))
     (let ((__function__ 'vl-find-file))
          (declare (ignorable __function__))
          (b* ((filename (string-fix filename))
               ((when (acl2::absolute-pathname-string-p
                           filename nil (acl2::os (w state))))
                (mv filename state))
               ((when (or (str::substrp "/" filename)
                          (str::substrp "\\" filename)))
                (vl-slow-find-file-aux filename searchcache state)))
              (mv (vl-cache-find-file-aux filename searchcache)
                  state))))

Theorem: maybe-stringp-of-vl-find-file.realpath

(defthm maybe-stringp-of-vl-find-file.realpath
        (b* (((mv ?realpath acl2::?state)
              (vl-find-file filename searchcache state)))
            (maybe-stringp realpath))
        :rule-classes :type-prescription)

Theorem: state-p1-of-vl-find-file.state

(defthm state-p1-of-vl-find-file.state
        (implies (force (state-p1 state))
                 (b* (((mv ?realpath acl2::?state)
                       (vl-find-file filename searchcache state)))
                     (state-p1 state)))
        :rule-classes :rewrite)

Theorem: vl-find-file-of-str-fix-filename

(defthm vl-find-file-of-str-fix-filename
        (equal (vl-find-file (str-fix filename)
                             searchcache state)
               (vl-find-file filename searchcache state)))

Theorem: vl-find-file-streqv-congruence-on-filename

(defthm
   vl-find-file-streqv-congruence-on-filename
   (implies (streqv filename filename-equiv)
            (equal (vl-find-file filename searchcache state)
                   (vl-find-file filename-equiv searchcache state)))
   :rule-classes :congruence)

Theorem: vl-find-file-of-vl-dirlist-cache-fix-searchcache

(defthm vl-find-file-of-vl-dirlist-cache-fix-searchcache
        (equal (vl-find-file filename
                             (vl-dirlist-cache-fix searchcache)
                             state)
               (vl-find-file filename searchcache state)))

Theorem: vl-find-file-vl-dirlist-cache-equiv-congruence-on-searchcache

(defthm
   vl-find-file-vl-dirlist-cache-equiv-congruence-on-searchcache
   (implies (vl-dirlist-cache-equiv searchcache searchcache-equiv)
            (equal (vl-find-file filename searchcache state)
                   (vl-find-file filename searchcache-equiv state)))
   :rule-classes :congruence)

Subtopics

Vl-slow-find-file-aux
Look for a file in a list of search directories (without using the cache).
Vl-cache-find-file-aux
Alternative to vl-slow-find-file-aux using a vl-dirlist-cache-p.
Vl-extend-pathname
(vl-extend-pathname dir filename) concatenates dir and filename, adding a slash to between them only if dir does not end with a slash.
Vl-file-exists-p
Vl-ends-with-directory-separatorp
Vl-dirlist-cache
Slow alist mapping directories names to their vl-dircaches.
Vl-dircache
Fast alist mapping file names to T.