Reset // Deprecating Zonble's On-Write EOF Fixer.

This commit is contained in:
ShikiSuen 2022-02-09 13:09:51 +08:00
parent 2f978ee056
commit bed730f9f1
1 changed files with 21 additions and 21 deletions

View File

@ -231,31 +231,31 @@ static void LTLoadAssociatedPhrases(vChewingLM &lm)
return NO; return NO;
} }
BOOL addLineBreakAtFront = NO; // BOOL addLineBreakAtFront = NO;
NSString *path = [self userPhrasesDataPath:mode]; NSString *path = [self userPhrasesDataPath:mode];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { // if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSError *error = nil; // NSError *error = nil;
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error]; // NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error];
unsigned long long fileSize = [attr fileSize]; // unsigned long long fileSize = [attr fileSize];
if (!error && fileSize) { // if (!error && fileSize) {
NSFileHandle *readFile = [NSFileHandle fileHandleForReadingAtPath:path]; // NSFileHandle *readFile = [NSFileHandle fileHandleForReadingAtPath:path];
if (readFile) { // if (readFile) {
[readFile seekToFileOffset:fileSize - 1]; // [readFile seekToFileOffset:fileSize - 1];
NSData *data = [readFile readDataToEndOfFile]; // NSData *data = [readFile readDataToEndOfFile];
const void *bytes = [data bytes]; // const void *bytes = [data bytes];
if (*(char *)bytes != '\n') { // if (*(char *)bytes != '\n') {
addLineBreakAtFront = YES; // addLineBreakAtFront = YES;
} // }
[readFile closeFile]; // [readFile closeFile];
} // }
} // }
} // }
NSMutableString *currentMarkedPhrase = [NSMutableString string]; NSMutableString *currentMarkedPhrase = [NSMutableString string];
if (addLineBreakAtFront) { // if (addLineBreakAtFront) {
[currentMarkedPhrase appendString:@"\n"]; // [currentMarkedPhrase appendString:@"\n"];
} // }
[currentMarkedPhrase appendString:userPhrase]; [currentMarkedPhrase appendString:userPhrase];
[currentMarkedPhrase appendString:@"\n"]; [currentMarkedPhrase appendString:@"\n"];