-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.go
More file actions
37 lines (30 loc) · 874 Bytes
/
file.go
File metadata and controls
37 lines (30 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package filesystree
import (
"fmt"
)
// File struct which contains name, path, directory and optional metadata.
type File struct {
name string
path string
directory *Directory
metadata Metadata
}
// Metadata can be used to store addidional metadata for files.
type Metadata map[string]interface{}
// GetName returns the name of the file.
func (file *File) GetName() string {
return file.name
}
// GetFullName returns the name of the path + file.
func (file *File) GetFullName() string {
return fmt.Sprintf("%s/%s", file.path, file.name)
}
// GetDirectory returns the the directory which contains this file.
func (file *File) GetDirectory() *Directory {
return file.directory
}
// GetMetadata returns the attached metadata of the file.
// If no metadata is defined nil is returned.
func (file *File) GetMetadata() Metadata {
return file.metadata
}