コード例 #1
0
ファイル: walk.go プロジェクト: datatonic/Dominator
func addRegularFile(dirent *filesystem.DirectoryEntry,
	fileSystem, oldFS *FileSystem,
	directoryPathName string, stat *syscall.Stat_t) error {
	if inode, ok := fileSystem.InodeTable[stat.Ino]; ok {
		if inode, ok := inode.(*filesystem.RegularInode); ok {
			dirent.SetInode(inode)
			return nil
		}
		return errors.New("Inode changed type: " + dirent.Name)
	}
	inode := makeRegularInode(stat)
	if inode.Size > 0 {
		err := scanRegularInode(inode, fileSystem,
			path.Join(directoryPathName, dirent.Name))
		if err != nil {
			return err
		}
	}
	if oldFS != nil && oldFS.InodeTable != nil {
		if oldInode, found := oldFS.InodeTable[stat.Ino]; found {
			if oldInode, ok := oldInode.(*filesystem.RegularInode); ok {
				if filesystem.CompareRegularInodes(inode, oldInode, nil) {
					inode = oldInode
				}
			}
		}
	}
	dirent.SetInode(inode)
	fileSystem.InodeTable[stat.Ino] = inode
	return nil
}
コード例 #2
0
ファイル: walk.go プロジェクト: wxdublin/Dominator
func addRegularFile(directory *filesystem.Directory,
	fileSystem, oldFS *FileSystem,
	name string, directoryPathName string, stat *syscall.Stat_t) error {
	inode, isNewInode := fileSystem.getRegularInode(stat)
	var file filesystem.RegularFile
	file.Name = name
	file.InodeNumber = stat.Ino
	file.SetInode(inode)
	if isNewInode {
		if inode.Size > 0 {
			err := scanRegularFile(&file, fileSystem, directoryPathName)
			if err != nil {
				return err
			}
		}
		if oldFS != nil && oldFS.RegularInodeTable != nil {
			if oldInode, found := oldFS.RegularInodeTable[stat.Ino]; found {
				if filesystem.CompareRegularInodes(inode, oldInode, nil) {
					inode = oldInode
					file.SetInode(inode)
					fileSystem.RegularInodeTable[stat.Ino] = inode
				}
			}
		}
	}
	directory.RegularFileList = append(directory.RegularFileList, &file)
	return nil
}