You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/06/07 22:40:44 UTC
[36/48] js commit: removed comments and cleaning stuff up
removed comments and cleaning stuff up
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/107b951b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/107b951b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/107b951b
Branch: refs/heads/master
Commit: 107b951bd1f37ca318cde805ebed555d78c0a8e9
Parents: 00e7bbe
Author: Tim Kim <ti...@adobe.com>
Authored: Thu May 10 16:23:43 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jun 7 13:40:22 2012 -0700
----------------------------------------------------------------------
lib/common/plugin/FileEntry.js | 2 -
lib/playbook/plugin/playbook/DirectoryEntry.js | 11 ---
lib/playbook/plugin/playbook/Entry.js | 63 ++++++++++++++-
lib/playbook/plugin/playbook/FileEntry.js | 26 +++---
lib/playbook/plugin/playbook/FileReader.js | 6 +-
.../plugin/playbook/resolveLocalFileSystemURI.js | 4 +-
6 files changed, 79 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/common/plugin/FileEntry.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileEntry.js b/lib/common/plugin/FileEntry.js
index 2e41888..fb6cfaa 100644
--- a/lib/common/plugin/FileEntry.js
+++ b/lib/common/plugin/FileEntry.js
@@ -56,9 +56,7 @@ FileEntry.prototype.file = function(successCallback, errorCallback) {
var fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(new FileError(code));
};
- console.log('this is messing it up');
exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
- console.log('ya');
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/playbook/plugin/playbook/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/DirectoryEntry.js b/lib/playbook/plugin/playbook/DirectoryEntry.js
index 7d4b542..e261e53 100644
--- a/lib/playbook/plugin/playbook/DirectoryEntry.js
+++ b/lib/playbook/plugin/playbook/DirectoryEntry.js
@@ -54,11 +54,9 @@ module.exports = {
// determine if directory exists
try {
// will return true if path exists AND is a directory
- console.log('exists :' + exists);
exists = blackberry.io.dir.exists(path);
} catch (e) {
// invalid path
- console.log('invalid path');
fail(FileError.ENCODING_ERR);
return;
}
@@ -179,18 +177,9 @@ module.exports = {
// path does not exist, create it
else if (create) {
// create empty file
- console.log('making file');
var emptyBlob = blackberry.utils.stringToBlob('');
blackberry.io.file.saveFile(path,emptyBlob);
createEntry();
- /*
- exec(
- function(result) {
- // file created
- createEntry();
- },
- fail, "File", "write", [ path, "", 0 ]);
- */
}
// path does not exist, don't create
else {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/playbook/plugin/playbook/Entry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/Entry.js b/lib/playbook/plugin/playbook/Entry.js
index 52b1fd5..21a0408 100644
--- a/lib/playbook/plugin/playbook/Entry.js
+++ b/lib/playbook/plugin/playbook/Entry.js
@@ -1,9 +1,68 @@
var FileError = require('cordova/plugin/FileError'),
LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
- resolveLocalFileSystemURI = require('cordova/plugin/resolveLocalFileSystemURI'),
- exec = require('cordova/exec');
+ resolveLocalFileSystemURI = require('cordova/plugin/resolveLocalFileSystemURI');
module.exports = {
+ getMetadata : function(successCallback, errorCallback){
+ var success = typeof successCallback !== 'function' ? null : function(lastModified) {
+ var metadata = new Metadata(lastModified);
+ successCallback(metadata);
+ };
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ errorCallback(new FileError(code));
+ };
+
+ if(this.isFile){
+ if(blackberry.io.file.exists(this.fullPath)){
+ var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
+ success(theFileProperties.dateModified)
+ }
+ }else{
+ console.log('Unsupported for directories')
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }
+ },
+
+ moveTo : function(parent, newName, successCallback, errorCallback){
+ var fail = function(code) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(code));
+ }
+ };
+ // user must specify parent Entry
+ if (!parent) {
+ fail(FileError.NOT_FOUND_ERR);
+ return;
+ }
+ // source path
+ var srcPath = this.fullPath,
+ // entry name
+ name = newName || this.name,
+ success = function(entry) {
+ if (entry) {
+ if (typeof successCallback === 'function') {
+ // create appropriate Entry object
+ var result = (entry.isDirectory) ? new (require('cordova/plugin/playbook/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/playbook/FileEntry'))(entry.name, entry.fullPath);
+ try {
+ successCallback(result);
+ }
+ catch (e) {
+ console.log('Error invoking callback: ' + e);
+ }
+ }
+ }
+ else {
+ // no Entry object returned
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ };
+
+ },
+
+ copyTo : function(parent, newName, successCallback, errorCallback) {
+
+ },
+
remove : function(successCallback, errorCallback) {
var path = this.fullPath,
// directory contents
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/playbook/plugin/playbook/FileEntry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/FileEntry.js b/lib/playbook/plugin/playbook/FileEntry.js
index 5edfa37..42bedb8 100644
--- a/lib/playbook/plugin/playbook/FileEntry.js
+++ b/lib/playbook/plugin/playbook/FileEntry.js
@@ -41,19 +41,19 @@ module.exports = {
var fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(new FileError(code));
};
- console.log('getting file properties');
- // TODO Need to set up win/fail callbacks
- var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
- var theFile = {};
- console.log(this.fullPath);
- console.log(this.name);
- //theFile.name =
- theFile.fullPath = this.fullPath;
- theFile.type = theFileProperties.fileExtension;
- theFile.lastModifiedDate = theFileProperties.dateModified;
- theFile.size = theFileProperties.size;
- win(theFile);
- //exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
+
+ if(blackberry.io.file.exists(this.fullPath)){
+ var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
+ var theFile = {};
+
+ theFile.fullPath = this.fullPath;
+ theFile.type = theFileProperties.fileExtension;
+ theFile.lastModifiedDate = theFileProperties.dateModified;
+ theFile.size = theFileProperties.size;
+ win(theFile);
+ }else{
+ fail(FileError.NOT_FOUND_ERR);
+ }
}
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/playbook/plugin/playbook/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/FileReader.js b/lib/playbook/plugin/playbook/FileReader.js
index 0fa4918..7d6d20d 100644
--- a/lib/playbook/plugin/playbook/FileReader.js
+++ b/lib/playbook/plugin/playbook/FileReader.js
@@ -93,14 +93,14 @@ FileReader.prototype.readAsText = function(file, encoding) {
var theText = '';
var getFileContents = function(path,blob){
if(blob){
-
+
theText = blackberry.utils.blobToString(blob);
me.result = theText;
-
+
if (typeof me.onload === "function") {
me.onload(new ProgressEvent("load", {target:me}));
}
-
+
me.readyState = FileReader.DONE;
if (typeof me.onloadend === "function") {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/107b951b/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js b/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
index e02cfc3..5e30537 100644
--- a/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
+++ b/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
@@ -49,7 +49,7 @@ module.exports = function(uri, successCallback, errorCallback) {
theEntry.fullPath = uri;
success(theEntry);
}else{
- // TODO: Throw error
+ fail(FileError.NOT_FOUND_ERR);
}
- //exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
+
};