You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/06/11 19:40:52 UTC
[2/3] git commit: CB-6922: Remove unused getMetadata native code
CB-6922: Remove unused getMetadata native code
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/090979e9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/090979e9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/090979e9
Branch: refs/heads/master
Commit: 090979e9d4dfcd2d696489033f28f31003f2b918
Parents: 71ff2e4
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Jun 11 13:35:30 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Jun 11 13:35:30 2014 -0400
----------------------------------------------------------------------
src/android/FileUtils.java | 2 +-
src/ios/CDVAssetLibraryFilesystem.m | 31 ------------------------------
src/ios/CDVFile.h | 6 ++----
src/ios/CDVFile.m | 15 ---------------
src/ios/CDVLocalFilesystem.m | 33 --------------------------------
5 files changed, 3 insertions(+), 84 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/090979e9/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 9233a62..3f1c817 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -369,7 +369,7 @@ public class FileUtils extends CordovaPlugin {
}
},callbackContext);
}
- else if (action.equals("getMetadata") || action.equals("getFileMetadata")) {
+ else if (action.equals("getFileMetadata")) {
final String fname=args.getString(0);
threadhelper( new FileOp( ){
public void run() throws FileNotFoundException, JSONException, MalformedURLException {
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/090979e9/src/ios/CDVAssetLibraryFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVAssetLibraryFilesystem.m b/src/ios/CDVAssetLibraryFilesystem.m
index 965251a..1197f06 100644
--- a/src/ios/CDVAssetLibraryFilesystem.m
+++ b/src/ios/CDVAssetLibraryFilesystem.m
@@ -124,37 +124,6 @@ NSString* const kCDVAssetsLibraryScheme = @"assets-library";
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
}
-- (void)getMetadataForURL:(CDVFilesystemURL *)url callback:(void (^)(CDVPluginResult *))callback
-{
- __block CDVPluginResult* result = nil;
-
- // In this case, we need to use an asynchronous method to retrieve the file.
- // Because of this, we can't just assign to `result` and send it at the end of the method.
- // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
- ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
- if (asset) {
- // We have the asset! Retrieve the metadata and send it off.
- NSDate* date = [asset valueForProperty:ALAssetPropertyDate];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[date timeIntervalSince1970] * 1000];
- callback(result);
- } else {
- // We couldn't find the asset. Send the appropriate error.
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- callback(result);
- }
- };
- // TODO(maxw): Consider making this a class variable since it's the same every time.
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
- // Retrieving the asset failed for some reason. Send the appropriate error.
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
- callback(result);
- };
-
- ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
- [assetsLibrary assetForURL:[self assetLibraryURLForLocalURL:url] resultBlock:resultBlock failureBlock:failureBlock];
- return;
-}
-
- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options
{
// setMetadata doesn't make sense for asset library files
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/090979e9/src/ios/CDVFile.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.h b/src/ios/CDVFile.h
index c37fb44..74c0146 100644
--- a/src/ios/CDVFile.h
+++ b/src/ios/CDVFile.h
@@ -65,9 +65,8 @@ typedef int CDVFileError;
@protocol CDVFileSystem
- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url;
- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options;
-- (CDVPluginResult*)getParentForURL:(CDVFilesystemURL *)localURI;
-- (void)getMetadataForURL:(CDVFilesystemURL *)url callback:(void (^)(CDVPluginResult *))callback;
-- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;
+- (CDVPluginResult *)getParentForURL:(CDVFilesystemURL *)localURI;
+- (CDVPluginResult *)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;
- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI;
- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI;
- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI;
@@ -115,7 +114,6 @@ typedef int CDVFileError;
- (void)getDirectory:(CDVInvokedUrlCommand*)command;
- (void)getFile:(CDVInvokedUrlCommand*)command;
- (void)getParent:(CDVInvokedUrlCommand*)command;
-- (void)getMetadata:(CDVInvokedUrlCommand*)command;
- (void)removeRecursively:(CDVInvokedUrlCommand*)command;
- (void)remove:(CDVInvokedUrlCommand*)command;
- (void)copyTo:(CDVInvokedUrlCommand*)command;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/090979e9/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index dd6bfd3..0975340 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -646,21 +646,6 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
}
/*
- * get MetaData of entry
- * Currently MetaData only includes modificationTime.
- */
-- (void)getMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];
- NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];
- [fs getMetadataForURL:localURI callback:^(CDVPluginResult* result) {
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-
-}
-
-/*
* set MetaData of entry
* Currently we only support "com.apple.MobileBackup" (boolean)
*/
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/090979e9/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index 861ce6f..d1576ad 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -262,39 +262,6 @@
return result;
}
-- (void)getMetadataForURL:(CDVFilesystemURL *)url callback:(void (^)(CDVPluginResult *))callback
-{
-
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing error = nil;
-
- CDVPluginResult *result;
- NSDictionary* fileAttribs = [fileMgr attributesOfItemAtPath:[self filesystemPathForURL:url] error:&error];
-
- if (fileAttribs) {
- // Ensure that directories (and other non-regular files) report size of 0
- unsigned long long size = ([fileAttribs fileType] == NSFileTypeRegular ? [fileAttribs fileSize] : 0);
- NSDate* modDate = [fileAttribs fileModificationDate];
- if (modDate) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"modificationTime": @([modDate timeIntervalSince1970] * 1000), @"size": @(size)}];
- }
- } else {
- // didn't get fileAttribs
- CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [error localizedDescription]);
- if ([error code] == NSFileNoSuchFileError) {
- errorCode = NOT_FOUND_ERR;
- }
- // log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];
- }
- if (!result) {
- // invalid path or file does not exist
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION];
- }
- callback(result);
-}
-
- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options
{
BOOL ok = NO;