~hristoast/openmw-validator

4550d618633a3fea6a3d6a5ad6948185ef3de3be — Hristos N. Triantafillou 2 months ago bb21046
Don't count fallback archives or content files found in subdirs
M files/main.go => files/main.go +2 -0
@@ 40,6 40,8 @@ func DefaultCfgAndLog(userOS string) (string, string) {
	return cfg, log
}

// ReadCfg gives back data that was read directly from the given CFG file.
// No validations or reading of any kind has been done beyond this.
func ReadCfg(filePath string) (*config.CfgData, error) {
	d := &config.CfgData{
		Content:     []string{},

M problems-openmw.cfg.in => problems-openmw.cfg.in +4 -0
@@ 7,6 7,8 @@ fallback-archive=Test1.bsa
fallback-archive=Test2.bsa
# Bad fallback archive
fallback-archive=Test3.bsa
# This one is in a subdir, it shouldn't be found!
fallback-archive=TestSubDir.bsa

data="_ROOT_PATH_/test-data/path1"
data="_ROOT_PATH_/test-data/path2"


@@ 26,6 28,8 @@ content=Test1.esp
content=Test2.esp
content=Test1.omwaddon
content=Test1.omwscripts
# This one is in a subdir, it shouldn't be found!
content=TestSubDir.omwaddon

groundcover=Groundcover1.omwaddon
groundcover=Groundcover2.omwaddon

A test-data/path5/subdir/TestSubDir.bsa => test-data/path5/subdir/TestSubDir.bsa +0 -0
A test-data/path5/subdir/TestSubDir.omwaddon => test-data/path5/subdir/TestSubDir.omwaddon +0 -0
M validations/datafiles.go => validations/datafiles.go +19 -0
@@ 152,6 152,16 @@ func checkDataDirs(path *datafiles.Path, gameCfg *game.GameConfig, pathNum int) 
func handleFile(df string, path *datafiles.Path, g *game.GameConfig, fileCount, pathNum int) int {
	file := datafiles.NewFile(df, path)
	if file.IsContent() {

		// Don't count content files found in subdirs, just give a warning about it
		if strings.Contains(file.FileName(), string(filepath.Separator)) {
			splitup := strings.Split(file.FileName(), string(filepath.Separator))
			if len(splitup) > 1 {
				g.Logger.Emit(fmt.Sprintf("WARNING: Content file found in subdir: %s", file.FullPath()))
				return fileCount
			}
		}

		var contentFile string
		if g.RunConfig.CaseSensitive {
			contentFile = filepath.Base(file.FileName())


@@ 170,6 180,15 @@ func handleFile(df string, path *datafiles.Path, g *game.GameConfig, fileCount, 
		path.Content(file)

	} else if file.IsFallbackArchive() {
		// Don't count fallback archives found in subdirs, just give a warning about it
		if strings.Contains(file.FileName(), string(filepath.Separator)) {
			splitup := strings.Split(file.FileName(), string(filepath.Separator))
			if len(splitup) > 1 {
				g.Logger.Emit(fmt.Sprintf("WARNING: Fallback archive found in subdir: %s", file.FullPath()))
				return fileCount
			}
		}

		faFile := filepath.Base(file.FileName())
		if pathNum > 1 {
			if replaced, ok := g.FallbackArchives[faFile]; ok {