예제 #1
0
func (w *traverse) walkFn(path string, info os.FileInfo, err error) error {
	rel := getRelative(w.basePath, path)

	if rel == "" || info.IsDir() {
		return nil
	}

	if common.ContainsFolderName(rel) {
		return nil
	}

	var imgWidth, imgHeight int
	ext := strings.ToLower(filepath.Ext(rel))
	switch ext {
	case ".jpg", ".jpeg", ".png", ".gif":
		imgWidth, imgHeight = getImageDimension(path)
		//	default:
		//		log.Println(rel, ext)
	}

	w.workerRec <- record.Record{
		Path:    rel,
		ModTime: info.ModTime(),
		Width:   imgWidth,
		Height:  imgHeight,
	}
	return nil
}
예제 #2
0
func (w *walkCount) walkFn(path string, info os.FileInfo, err error) error {
	rel := getRelative(w.basePath, path)

	if rel == "" || info.IsDir() || common.ContainsFolderName(rel) {
		return nil
	}

	w.mu.Lock()
	w.fileCount++
	w.mu.Unlock()

	return nil
}