Patcher.Data.ModOrganizerDataFileProvider.ModOrganizerDataFileProvider C# (CSharp) Method

ModOrganizerDataFileProvider() public method

public ModOrganizerDataFileProvider ( string dataFolder, string moProfilePath, string moModPath ) : System
dataFolder string
moProfilePath string
moModPath string
return System
        public ModOrganizerDataFileProvider(string dataFolder, string moProfilePath, string moModPath)
        {
            this.dataFolder = Path.GetFullPath(dataFolder);

            moProfilePath = Path.GetFullPath(moProfilePath);

            // Ensure plugin.txt exists
            pluginListFilePath = Path.Combine(moProfilePath, "plugins.txt");
            if (!File.Exists(pluginListFilePath))
                throw new InvalidDataException("File plugins.txt not found in Mod Organizer profile folder.");
            //Log.Fine("Plugin list file from Mod Organize will be used: {0}", pluginListFilePath);

            // Validate or assume modpath
            if (string.IsNullOrEmpty(moModPath))
            {
                moModPath = Path.GetFullPath(Path.Combine(moProfilePath, "..", "..", "mods"));
                //Log.Fine("Assumed Mod Organizer 'mods' folder: {0}", moModPath);
            }
            else
            {
                moModPath = Path.GetFullPath(moModPath);
            }

            // Assume overwrite folder
            moOverwritePath = Path.GetFullPath(Path.Combine(moProfilePath, "..", "..", "overwrite"));
            if (!Directory.Exists(moOverwritePath))
                throw new InvalidDataException("Could not find Mod Organizer 'overwrite' folder: " + moOverwritePath);
            //Log.Fine("Assumed Mod Organizer 'overwrite' folder: {0}", moOverwritePath);

            // Overwrite folder will be search first
            searchPaths.Add(moOverwritePath);

            // Read modlist.txt
            string modListFilePath = Path.Combine(moProfilePath, "modlist.txt");
            using (var reader = new StreamReader(modListFilePath))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    // Ignore lines that do not start with '+'
                    // '+' means a mod is active in given profile
                    if (line.StartsWith("+"))
                    {
                        string modName = line.Substring(1);
                        string path = Path.Combine(moModPath, modName);
                        if (!Directory.Exists(path))
                            throw new InvalidDataException("Could not find Mod Organizer mod folder: " + path);

                        searchPaths.Add(path);
                    }
                }
            }

            // Data Folder will be searched last
            searchPaths.Add(dataFolder);
        }