lice-comb.files
Functionality related to combing files, directories, and ZIP format archives for license information.
dir->expressions
(dir->expressions dir)
(dir->expressions dir opts)
Returns a set of SPDX expressions (String
s) for dir
. See dir->expressions-info for details.
dir->expressions-info
(dir->expressions-info dir)
(dir->expressions-info dir {:keys [include-hidden-dirs? include-zips?], :or {include-hidden-dirs? false, include-zips? false}, :as opts})
Returns an expressions-info map for dir
(a String
or File
, which must refer to a readable directory), or nil
if or no expressions were found.
The optional opts
map has these keys: * include-hidden-dirs?
(boolean, default false
) - controls whether hidden directories (as defined by java.io.File.isHidden()
) are included in the search or not. * include-zips?
(boolean, default false
) - controls whether zip compressed files found in the directory are recursively included in the scan or not
Note: logs and ignores errors (XML parsing errors, ZIP file errors, etc.)
file->expressions
(file->expressions f)
(file->expressions f filepath)
Returns a set of SPDX expressions (String
s) for f
. See file->expressions-info for details.
file->expressions-info
(file->expressions-info f)
(file->expressions-info f filepath)
Returns an expressions-info map for f
(an InputStream
or something that can have an clojure.java.io/input-stream
opened on it), or nil
if no expressions were found.
If an InputStream
is provided, it is the caller’s responsibility to open and close it, and a filepath associated with the InputStream
must be provided as the second parameter (it is not required for other types of input).
init!
(init!)
Initialises this namespace upon first call (and does nothing on subsequent calls), returning nil
. Consumers of this namespace are not required to call this fn, as initialisation will occur implicitly anyway; it is provided to allow explicit control of the cost of initialisation to callers who need it.
Note: this method may have a substantial performance cost.
probable-license-file?
(probable-license-file? f)
Returns true
if the given file-like thing (String
containing a filename, File
, ZipEntry
) is a probable license file, false otherwise.
probable-license-files
(probable-license-files dir)
(probable-license-files dir {:keys [include-hidden-dirs?], :or {include-hidden-dirs? false}})
Returns all probable license files in the given directory, recursively, as a set of File
objects. dir
may be a String
or a File
, either of which must refer to a readable directory.
The optional opts
map has these keys: * include-hidden-dirs?
(boolean, default false
) - controls whether hidden directories (as defined by java.io.File.isHidden()
) are included in the search or not.
zip->expressions
(zip->expressions zip)
Returns a set of SPDX expressions (String
s) for zip
. See zip->expressions-info for details.
zip->expressions-info
(zip->expressions-info zip)
Returns an expressions-info map for zip
(a String
or File
, which must refer to a ZIP-format compressed file), or nil
if no expressions were found.
Throws various Java IO exceptions if the file is not a valid ZIP-format file.