本文整理汇总了Golang中github.com/Symantec/Dominator/lib/filesystem.DirectoryEntry.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang DirectoryEntry.Name方法的具体用法?Golang DirectoryEntry.Name怎么用?Golang DirectoryEntry.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Symantec/Dominator/lib/filesystem.DirectoryEntry
的用法示例。
在下文中一共展示了DirectoryEntry.Name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addEntry
func (decoderData *decoderData) addEntry(parent *filesystem.DirectoryInode,
fullName, name string, inode filesystem.GenericInode) {
var newEntry filesystem.DirectoryEntry
newEntry.Name = name
newEntry.InodeNumber = decoderData.nextInodeNumber
newEntry.SetInode(inode)
parent.EntryList = append(parent.EntryList, &newEntry)
decoderData.addInode(fullName, inode)
}
示例2: addHardlink
func (decoderData *decoderData) addHardlink(header *tar.Header,
parent *filesystem.DirectoryInode, name string) error {
header.Linkname = normaliseFilename(header.Linkname)
if inum, ok := decoderData.inodeTable[header.Linkname]; ok {
var newEntry filesystem.DirectoryEntry
newEntry.Name = name
newEntry.InodeNumber = inum
parent.EntryList = append(parent.EntryList, &newEntry)
} else {
return errors.New(fmt.Sprintf("missing hardlink target: %s",
header.Linkname))
}
return nil
}
示例3: scanDirectory
func scanDirectory(directory, oldDirectory *filesystem.DirectoryInode,
fileSystem, oldFS *FileSystem, myPathName string) (error, bool) {
file, err := os.Open(path.Join(fileSystem.rootDirectoryName, myPathName))
if err != nil {
return err, false
}
names, err := file.Readdirnames(-1)
file.Close()
if err != nil {
return err, false
}
sort.Strings(names)
entryList := make([]*filesystem.DirectoryEntry, 0, len(names))
var copiedDirents int
for _, name := range names {
if directory == &fileSystem.DirectoryInode && name == ".subd" {
continue
}
filename := path.Join(myPathName, name)
if fileSystem.configuration.ScanFilter.Match(filename) {
continue
}
var stat syscall.Stat_t
err := syscall.Lstat(path.Join(fileSystem.rootDirectoryName, filename),
&stat)
if err != nil {
if err == syscall.ENOENT {
continue
}
return err, false
}
if stat.Dev != fileSystem.dev {
continue
}
if checkScanDisableRequest() {
return errors.New("DisableScan"), false
}
myGC()
dirent := new(filesystem.DirectoryEntry)
dirent.Name = name
dirent.InodeNumber = stat.Ino
var oldDirent *filesystem.DirectoryEntry
if oldDirectory != nil {
index := len(entryList)
if len(oldDirectory.EntryList) > index &&
oldDirectory.EntryList[index].Name == name {
oldDirent = oldDirectory.EntryList[index]
}
}
if stat.Mode&syscall.S_IFMT == syscall.S_IFDIR {
err = addDirectory(dirent, oldDirent, fileSystem, oldFS, myPathName,
&stat)
} else if stat.Mode&syscall.S_IFMT == syscall.S_IFREG {
err = addRegularFile(dirent, fileSystem, oldFS, myPathName, &stat)
} else if stat.Mode&syscall.S_IFMT == syscall.S_IFLNK {
err = addSymlink(dirent, fileSystem, oldFS, myPathName, &stat)
} else if stat.Mode&syscall.S_IFMT == syscall.S_IFSOCK {
continue
} else {
err = addSpecialFile(dirent, fileSystem, oldFS, &stat)
}
if err != nil {
if err == syscall.ENOENT {
continue
}
return err, false
}
if oldDirent != nil && *dirent == *oldDirent {
dirent = oldDirent
copiedDirents++
}
entryList = append(entryList, dirent)
}
if oldDirectory != nil && len(entryList) == copiedDirents &&
len(entryList) == len(oldDirectory.EntryList) {
directory.EntryList = oldDirectory.EntryList
return nil, true
} else {
directory.EntryList = entryList
return nil, false
}
}
示例4: compareDirectories
// Returns true if there is a failure due to missing computed files.
func (sub *Sub) compareDirectories(request *subproto.UpdateRequest,
subDirectory, requiredDirectory *filesystem.DirectoryInode,
myPathName string, deleteMissingComputedFiles bool,
logger *log.Logger) bool {
// First look for entries that should be deleted.
if sub.filter != nil && subDirectory != nil {
for name := range subDirectory.EntriesByName {
pathname := path.Join(myPathName, name)
if sub.filter.Match(pathname) {
continue
}
if _, ok := requiredDirectory.EntriesByName[name]; !ok {
request.PathsToDelete = append(request.PathsToDelete, pathname)
}
}
}
for name, requiredEntry := range requiredDirectory.EntriesByName {
pathname := path.Join(myPathName, name)
if sub.filter != nil && sub.filter.Match(pathname) {
continue
}
var subEntry *filesystem.DirectoryEntry
if subDirectory != nil {
if se, ok := subDirectory.EntriesByName[name]; ok {
subEntry = se
}
}
requiredInode := requiredEntry.Inode()
if _, ok := requiredInode.(*filesystem.ComputedRegularInode); ok {
// Replace with computed file.
inode, ok := sub.ComputedInodes[pathname]
if !ok {
if deleteMissingComputedFiles {
if subEntry != nil {
request.PathsToDelete = append(request.PathsToDelete,
pathname)
}
continue
}
logger.Printf(
"compareDirectories(%s): missing computed file: %s\n",
sub, pathname)
return true
}
setComputedFileMtime(inode, subEntry)
newEntry := new(filesystem.DirectoryEntry)
newEntry.Name = name
newEntry.InodeNumber = requiredEntry.InodeNumber
newEntry.SetInode(inode)
requiredEntry = newEntry
}
if subEntry == nil {
sub.addEntry(request, requiredEntry, pathname)
} else {
sub.compareEntries(request, subEntry, requiredEntry, pathname)
}
// If a directory: descend (possibly with the directory for the sub).
if requiredInode, ok := requiredInode.(*filesystem.DirectoryInode); ok {
var subInode *filesystem.DirectoryInode
if subEntry != nil {
if si, ok := subEntry.Inode().(*filesystem.DirectoryInode); ok {
subInode = si
}
}
sub.compareDirectories(request, subInode, requiredInode, pathname,
deleteMissingComputedFiles, logger)
}
}
return false
}