@@ -411,11 +411,9 @@ - (NSNumber*)checkFreeDiskSpace:(NSString*)appPath
411411
412412- (void )requestFileSystem : (CDVInvokedUrlCommand*)command
413413{
414- NSArray * arguments = command.arguments ;
415-
416414 // arguments
417- NSString * strType = [arguments objectAtIndex :0 ];
418- unsigned long long size = [[arguments objectAtIndex :1 ] longLongValue ];
415+ NSString * strType = [command argumentAtIndex :0 ];
416+ unsigned long long size = [[command argumentAtIndex :1 ] longLongValue ];
419417
420418 int type = [strType intValue ];
421419 CDVPluginResult* result = nil ;
@@ -536,7 +534,7 @@ - (NSDictionary *)makeEntryForURL:(NSURL *)URL
536534- (void )resolveLocalFileSystemURI : (CDVInvokedUrlCommand*)command
537535{
538536 // arguments
539- NSString * localURIstr = [command.arguments objectAtIndex :0 ];
537+ NSString * localURIstr = [command argumentAtIndex :0 ];
540538 CDVPluginResult* result;
541539
542540 localURIstr = [self encodePath: localURIstr]; // encode path before resolving
@@ -584,7 +582,7 @@ - (void)getDirectory:(CDVInvokedUrlCommand*)command
584582 NSMutableDictionary * options = nil ;
585583
586584 if ([arguments count ] >= 3 ) {
587- options = [arguments objectAtIndex :2 withDefault: nil ];
585+ options = [command argumentAtIndex :2 withDefault: nil ];
588586 }
589587 // add getDir to options and call getFile()
590588 if (options != nil ) {
@@ -622,10 +620,10 @@ - (void)getDirectory:(CDVInvokedUrlCommand*)command
622620 */
623621- (void )getFile : (CDVInvokedUrlCommand*)command
624622{
625- NSString * baseURIstr = [command.arguments objectAtIndex :0 ];
623+ NSString * baseURIstr = [command argumentAtIndex :0 ];
626624 CDVFilesystemURL* baseURI = [self fileSystemURLforArg: baseURIstr];
627- NSString * requestedPath = [command.arguments objectAtIndex :1 ];
628- NSDictionary * options = [command.arguments objectAtIndex :2 withDefault: nil ];
625+ NSString * requestedPath = [command argumentAtIndex :1 ];
626+ NSDictionary * options = [command argumentAtIndex :2 withDefault: nil ];
629627
630628 NSObject <CDVFileSystem> *fs = [self filesystemForURL: baseURI];
631629 CDVPluginResult* result = [fs getFileForURL: baseURI requestedPath: requestedPath options: options];
@@ -662,7 +660,7 @@ - (void)setMetadata:(CDVInvokedUrlCommand*)command
662660{
663661 // arguments
664662 CDVFilesystemURL* localURI = [self fileSystemURLforArg: command.arguments[0 ]];
665- NSDictionary * options = [command.arguments objectAtIndex :1 withDefault: nil ];
663+ NSDictionary * options = [command argumentAtIndex :1 withDefault: nil ];
666664 NSObject <CDVFileSystem> *fs = [self filesystemForURL: localURI];
667665 CDVPluginResult* result = [fs setMetadataForURL: localURI withObject: options];
668666
@@ -741,8 +739,8 @@ - (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy
741739 NSArray * arguments = command.arguments ;
742740
743741 // arguments
744- NSString * srcURLstr = [arguments objectAtIndex :0 ];
745- NSString * destURLstr = [arguments objectAtIndex :1 ];
742+ NSString * srcURLstr = [command argumentAtIndex :0 ];
743+ NSString * destURLstr = [command argumentAtIndex :1 ];
746744
747745 CDVPluginResult *result;
748746
@@ -760,7 +758,7 @@ - (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy
760758 NSObject <CDVFileSystem> *destFs = [self filesystemForURL: destURL];
761759
762760 // optional argument; use last component from srcFullPath if new name not provided
763- NSString * newName = ([arguments count ] > 2 ) ? [arguments objectAtIndex :2 ] : [srcURL.url lastPathComponent ];
761+ NSString * newName = ([arguments count ] > 2 ) ? [command argumentAtIndex :2 ] : [srcURL.url lastPathComponent ];
764762 if ([newName rangeOfString: @" :" ].location != NSNotFound ) {
765763 // invalid chars in new name
766764 result = [CDVPluginResult resultWithStatus: CDVCommandStatus_IO_EXCEPTION messageAsInt: ENCODING_ERR];
@@ -870,8 +868,8 @@ - (void)readAsDataURL:(CDVInvokedUrlCommand*)command
870868 [fs readFileAtURL: localURI start: start end: end callback: ^(NSData * data, NSString * mimeType, CDVFileError errorCode) {
871869 CDVPluginResult* result = nil ;
872870 if (data != nil ) {
873- // TODO: Would be faster to base64 encode directly to the final string.
874- NSString * output = [NSString stringWithFormat: @" data:%@ ;base64,%@ " , mimeType, [data base64EncodedString ] ];
871+ NSString * b64str = [data base64EncodedStringWithOptions: 0 ];
872+ NSString * output = [NSString stringWithFormat: @" data:%@ ;base64,%@ " , mimeType, b64str ];
875873 result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: output];
876874 } else {
877875 result = [CDVPluginResult resultWithStatus: CDVCommandStatus_IO_EXCEPTION messageAsInt: errorCode];
@@ -941,7 +939,7 @@ - (void)truncate:(CDVInvokedUrlCommand*)command
941939{
942940 // arguments
943941 CDVFilesystemURL* localURI = [self fileSystemURLforArg: command.arguments[0 ]];
944- unsigned long long pos = (unsigned long long )[[command.arguments objectAtIndex :1 ] longLongValue ];
942+ unsigned long long pos = (unsigned long long )[[command argumentAtIndex :1 ] longLongValue ];
945943
946944 NSObject <CDVFileSystem> *fs = [self filesystemForURL: localURI];
947945 CDVPluginResult *result = [fs truncateFileAtURL: localURI atPosition: pos];
@@ -960,12 +958,11 @@ - (void)write:(CDVInvokedUrlCommand*)command
960958{
961959 [self .commandDelegate runInBackground: ^ {
962960 NSString * callbackId = command.callbackId ;
963- NSArray * arguments = command.arguments ;
964961
965962 // arguments
966963 CDVFilesystemURL* localURI = [self fileSystemURLforArg: command.arguments[0 ]];
967- id argData = [arguments objectAtIndex :1 ];
968- unsigned long long pos = (unsigned long long )[[arguments objectAtIndex :2 ] longLongValue ];
964+ id argData = [command argumentAtIndex :1 ];
965+ unsigned long long pos = (unsigned long long )[[command argumentAtIndex :2 ] longLongValue ];
969966
970967 NSObject <CDVFileSystem> *fs = [self filesystemForURL: localURI];
971968
@@ -1003,7 +1000,7 @@ - (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURL
10031000- (void )testFileExists : (CDVInvokedUrlCommand*)command
10041001{
10051002 // arguments
1006- NSString * argPath = [command.arguments objectAtIndex :0 ];
1003+ NSString * argPath = [command argumentAtIndex :0 ];
10071004
10081005 // Get the file manager
10091006 NSFileManager * fMgr = [NSFileManager defaultManager ];
@@ -1018,7 +1015,7 @@ - (void)testFileExists:(CDVInvokedUrlCommand*)command
10181015- (void )testDirectoryExists : (CDVInvokedUrlCommand*)command
10191016{
10201017 // arguments
1021- NSString * argPath = [command.arguments objectAtIndex :0 ];
1018+ NSString * argPath = [command argumentAtIndex :0 ];
10221019
10231020 // Get the file manager
10241021 NSFileManager * fMgr = [[NSFileManager alloc ] init ];
0 commit comments