xref: /aosp_15_r20/external/licenseclassifier/licenses/embed.go (revision 46c4c49da23cae783fa41bf46525a6505638499a)
1*46c4c49dSIbrahim Kanouchepackage licenses
2*46c4c49dSIbrahim Kanouche
3*46c4c49dSIbrahim Kanoucheimport (
4*46c4c49dSIbrahim Kanouche	"embed"
5*46c4c49dSIbrahim Kanouche	"io/fs"
6*46c4c49dSIbrahim Kanouche)
7*46c4c49dSIbrahim Kanouche
8*46c4c49dSIbrahim Kanouche// go:embed *.db *.txt
9*46c4c49dSIbrahim Kanouchevar licenseFS embed.FS
10*46c4c49dSIbrahim Kanouche
11*46c4c49dSIbrahim Kanouche// ReadLicenseFile locates and reads the license archive file.  Absolute paths are used unmodified.  Relative paths are expected to be in the licenses directory of the licenseclassifier package.
12*46c4c49dSIbrahim Kanouchefunc ReadLicenseFile(filename string) ([]byte, error) {
13*46c4c49dSIbrahim Kanouche	return licenseFS.ReadFile(filename)
14*46c4c49dSIbrahim Kanouche}
15*46c4c49dSIbrahim Kanouche
16*46c4c49dSIbrahim Kanouche// ReadLicenseDir reads directory containing the license files.
17*46c4c49dSIbrahim Kanouchefunc ReadLicenseDir() ([]fs.DirEntry, error) {
18*46c4c49dSIbrahim Kanouche	return licenseFS.ReadDir(".")
19*46c4c49dSIbrahim Kanouche}
20