예제 #1
0
// NewArchive instanciates a new Archive
func NewArchive(s *System, filePath string, output string, options *core.Options) *Archive {
	result := &Archive{
		System:       s,
		Path:         filePath,
		Output:       output,
		Options:      options,
		Games:        map[string]*rom.Game{},
		RegionsStats: map[string]int{},
	}

	result.WorkingDir = path.Join(options.Tmp, helpers.FileBase(filePath))

	return result
}
예제 #2
0
// processGameArchive processes game archive at given path
func (a *Archive) processGameArchive(filePath string) error {
	gamesDir := path.Join(a.WorkingDir, helpers.FileBase(filePath))

	// extract game archive
	if err := a.extractFile(filePath, gamesDir); err != nil {
		return err
	}

	// select one rom from game archive
	if err := a.selectGameArchiveRom(gamesDir); err != nil {
		return err
	}

	// delete extracted game archive
	if err := a.deleteDir(gamesDir); err != nil {
		return err
	}

	return nil
}