using System.Collections.Generic; using System.IO; namespace Amanotes.Core { internal static class CscRspFile { private const string DefaultPath = "Assets/csc.rsp"; internal static HashSet Parse(string path = DefaultPath) { var result = new HashSet(); if (!File.Exists(path)) return result; var lines = File.ReadAllLines(path); for (int i = 0; i < lines.Length; i++) { var trimmed = lines[i].Trim(); if (!trimmed.StartsWith("-define:")) continue; var symbols = trimmed.Substring(8).Split(';'); for (int j = 0; j < symbols.Length; j++) { var s = symbols[j].Trim(); if (s.Length > 0) result.Add(s); } } return result; } internal static void Write(HashSet symbols, string path = DefaultPath) { string content = symbols.Count > 0 ? "-define:" + string.Join(";", symbols) : string.Empty; File.WriteAllText(path, content); } internal static bool Exists(string path = DefaultPath) => File.Exists(path); } }