LMConsolidator // Simplify the process of fixing EOFs.

This commit is contained in:
ShikiSuen 2022-05-04 18:12:30 +08:00
parent 871c8ac08f
commit f69e5c859b
1 changed files with 9 additions and 2 deletions

View File

@ -59,8 +59,15 @@ extension vChewing {
strIncoming += try String(contentsOf: urlPath, encoding: .utf8) strIncoming += try String(contentsOf: urlPath, encoding: .utf8)
if !strIncoming.hasSuffix("\n") { if !strIncoming.hasSuffix("\n") {
IME.prtDebugIntel("EOF Fix Necessity Confirmed, Start Fixing.") IME.prtDebugIntel("EOF Fix Necessity Confirmed, Start Fixing.")
strIncoming += "\n" if let writeFile = FileHandle(forUpdatingAtPath: path),
try strIncoming.write(to: urlPath, atomically: false, encoding: .utf8) let endl = "\n".data(using: .utf8)
{
writeFile.seekToEndOfFile()
writeFile.write(endl)
writeFile.closeFile()
} else {
return false
}
} }
} catch { } catch {
IME.prtDebugIntel("EOF Fix Failed w/ File: \(path)") IME.prtDebugIntel("EOF Fix Failed w/ File: \(path)")