fix system root access

This commit is contained in:
criyle 2019-06-26 00:24:54 -07:00
parent 354f690e3e
commit 6dc2eb3b5d

View File

@ -59,15 +59,23 @@ func (s *FileSet) IsInSetSmart(name string) bool {
// Add adds a single file path into the FileSet // Add adds a single file path into the FileSet
func (s *FileSet) Add(name string) { func (s *FileSet) Add(name string) {
if name == "/" {
s.SystemRoot = true
} else {
s.Set[name] = true s.Set[name] = true
} }
}
// AddRange adds multiple files into the FileSet // AddRange adds multiple files into the FileSet
// If path is relative path, add according to the workPath // If path is relative path, add according to the workPath
func (s *FileSet) AddRange(names []string, workPath string) { func (s *FileSet) AddRange(names []string, workPath string) {
for _, n := range names { for _, n := range names {
if filepath.IsAbs(n) { if filepath.IsAbs(n) {
if n == "/" {
s.SystemRoot = true
} else {
s.Set[n] = true s.Set[n] = true
}
} else { } else {
s.Set[filepath.Join(workPath, n)+"/"] = true s.Set[filepath.Join(workPath, n)+"/"] = true
} }