Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package vars |
||
2 | |||
3 | import ( |
||
4 | "github.com/vvval/go-metadata-scanner/vars/metadata" |
||
5 | "path/filepath" |
||
6 | ) |
||
7 | |||
8 | type File struct { |
||
9 | filename string //parsed with filepath.ToSlashes |
||
10 | relPath string |
||
11 | tags metadata.Tags |
||
12 | } |
||
13 | |||
14 | func NewFile(filename string, tags metadata.Tags) File { |
||
15 | return File{ |
||
16 | filename: filename, |
||
17 | tags: tags, |
||
18 | } |
||
19 | } |
||
20 | |||
21 | func (f *File) Filename() string { |
||
22 | return f.filename |
||
23 | } |
||
24 | |||
25 | func (f *File) WithRelPath(base string) { |
||
26 | rel, err := filepath.Rel(base, f.filename) |
||
27 | if err != nil { |
||
28 | f.relPath = f.filename |
||
29 | } else { |
||
30 | f.relPath = rel |
||
31 | } |
||
32 | } |
||
33 | |||
34 | func (f *File) RelPath() string { |
||
35 | return f.relPath |
||
36 | } |
||
37 | |||
38 | func (f *File) Tags() metadata.Tags { |
||
39 | return f.tags |
||
40 | } |
||
41 |