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

GetDataFile() public method

public GetDataFile ( FileMode mode, string path ) : DataFile
mode FileMode
path string
return DataFile
        public DataFile GetDataFile(FileMode mode, string path)
        {
            if (mode == FileMode.Open)
            {
                // Search all paths when opening existing files
                foreach (var searchPath in searchPaths)
                {
                    string tryPath = Path.Combine(searchPath, path);
                    if (File.Exists(tryPath))
                        return new DataFile(this, mode, tryPath, path);
                }

                // When not found give path to file in data folder
                // Opening the data file will fail as it should because the file does not exist
                return new DataFile(this, mode, Path.Combine(dataFolder, path), path);
            }
            else
            {
                // Every new file will be created in the overwite folder
                return new DataFile(this, mode, Path.Combine(moOverwritePath, path), path);
            }
        }