mirror of https://github.com/mpv-player/mpv
macosx_application: refactor filename escape
Use Objective-C's new literal syntax to make the code simpler.
This commit is contained in:
parent
3789e1bebf
commit
8b40494e93
|
@ -58,22 +58,16 @@ static pthread_t playback_thread_id;
|
||||||
@synthesize keyFIFO = _key_fifo;
|
@synthesize keyFIFO = _key_fifo;
|
||||||
@synthesize menuItems = _menu_items;
|
@synthesize menuItems = _menu_items;
|
||||||
|
|
||||||
struct escape_couple {
|
|
||||||
NSString *in;
|
|
||||||
NSString *out;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct escape_couple escapes[] = {
|
|
||||||
{ @"\\", @"\\\\" },
|
|
||||||
{ @"\"", @"\\\"" },
|
|
||||||
{ NULL, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
static NSString *escape_loadfile_name(NSString *input)
|
static NSString *escape_loadfile_name(NSString *input)
|
||||||
{
|
{
|
||||||
for (int i = 0; escapes[i].out; i++) {
|
NSArray *mappings = @[
|
||||||
input = [input stringByReplacingOccurrencesOfString:escapes[i].in
|
@{ @"in": @"\\", @"out": @"\\\\" },
|
||||||
withString:escapes[i].out];
|
@{ @"in": @"\"", @"out": @"\\\"" },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (NSDictionary *mapping in mappings) {
|
||||||
|
input = [input stringByReplacingOccurrencesOfString:mapping[@"in"]
|
||||||
|
withString:mapping[@"out"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
|
|
Loading…
Reference in New Issue