package file

import (
	"os"
	"path/filepath"
)

func GetFileAndDirCount(dir string) (int, int, error) {
	var fileCount, dirCount int

	err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if path == dir {
			return nil // 跳过当前目录
		}
		if info.IsDir() {
			dirCount++
		} else {
			fileCount++
		}
		return nil
	})

	return fileCount, dirCount, err
}
