Clean up file handling
FossilOrigin-Name: 3d55e077f74fc1c036e856cc4fdf0ae3c308c58f7d37eb9392f1a15f10cc237d
This commit is contained in:
parent
c6eebefd77
commit
ab582d3745
14 changed files with 278 additions and 231 deletions
|
@ -557,13 +557,17 @@ bool
|
|||
execfile(OFString *cfgfile)
|
||||
{
|
||||
@autoreleasepool {
|
||||
string s;
|
||||
strcpy_s(s, cfgfile.UTF8String);
|
||||
char *buf = loadfile(path(s), NULL);
|
||||
if (!buf)
|
||||
OFMutableData *data;
|
||||
@try {
|
||||
data = [OFMutableData dataWithContentsOfFile:cfgfile];
|
||||
} @catch (id e) {
|
||||
return false;
|
||||
execute(buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
// Ensure \0 termination.
|
||||
[data addItem:""];
|
||||
|
||||
execute((char *)data.mutableItems);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue