public static List <LogInfo> IniDeleteSectionOp(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(); CodeInfo_IniDeleteSectionOp infoOp = cmd.Info.Cast <CodeInfo_IniDeleteSectionOp>(); string fileName = StringEscaper.Preprocess(s, infoOp.Infos[0].FileName); Debug.Assert(fileName != null, $"{nameof(fileName)} != null"); if (!StringEscaper.PathSecurityCheck(fileName, out string errorMsg)) { return(LogInfo.LogErrorMessage(logs, errorMsg)); } string[] sections = new string[infoOp.Cmds.Count]; for (int i = 0; i < sections.Length; i++) { CodeInfo_IniDeleteSection info = infoOp.Infos[i]; string sectionName = StringEscaper.Preprocess(s, info.Section); // WB082 : 여기 값은 변수 Expand 안한다. if (sectionName.Length == 0) { return(LogInfo.LogErrorMessage(logs, "Section name cannot be empty")); } sections[i] = sectionName; } bool[] results = IniReadWriter.DeleteSections(fileName, sections); int success = results.Count(x => x); int failure = results.Count(x => !x); for (int i = 0; i < sections.Length; i++) { if (results[i]) { logs.Add(new LogInfo(LogState.Success, $"Section [{sections[i]}] deleted", infoOp.Cmds[i])); } else { logs.Add(new LogInfo(LogState.Error, $"Could not delete section [{sections[i]}]", infoOp.Cmds[i])); } } if (0 < success) { logs.Add(new LogInfo(LogState.Success, $"Deleted [{success}] sections from [{fileName}]", cmd)); } if (0 < failure) { logs.Add(new LogInfo(LogState.Error, $"Could not delete [{failure}] sections from [{fileName}]", cmd)); } return(logs); }