mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-11-04 14:49:53 +08:00
fix system root access
This commit is contained in:
parent
354f690e3e
commit
6dc2eb3b5d
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user