cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject git commit: [CB-3720] [BlackBerry10] Add BB10 File implementation
Date Tue, 02 Jul 2013 13:25:03 GMT
Updated Branches:
  refs/heads/bb10 d0170d0d9 -> c409079de (forced update)


[CB-3720] [BlackBerry10] Add BB10 File implementation


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/c409079d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/c409079d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/c409079d

Branch: refs/heads/bb10
Commit: c409079deeb221b13b40635da5f34b9fa14222e1
Parents: d673737
Author: Bryan Higgins <bhiggins@blackberry.com>
Authored: Thu Jun 27 17:07:59 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Tue Jul 2 09:24:43 2013 -0400

----------------------------------------------------------------------
 plugin.xml                                    |  35 ++++++
 www/blackberry10/DirectoryEntry.js            |  57 ++++++++++
 www/blackberry10/DirectoryReader.js           |  47 ++++++++
 www/blackberry10/Entry.js                     | 112 +++++++++++++++++++
 www/blackberry10/FileEntry.js                 |  47 ++++++++
 www/blackberry10/FileReader.js                |  90 ++++++++++++++++
 www/blackberry10/FileSystem.js                |  27 +++++
 www/blackberry10/FileWriter.js                | 120 +++++++++++++++++++++
 www/blackberry10/fileUtils.js                 |  47 ++++++++
 www/blackberry10/requestFileSystem.js         |  38 +++++++
 www/blackberry10/resolveLocalFileSystemURI.js |  55 ++++++++++
 11 files changed, 675 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 86bbb1f..03e29d6 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -138,4 +138,39 @@ id="org.apache.cordova.core.FileUtils" version="0.1.0">
 
     </platform>
 
+    <!-- blackberry10 -->
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="File" value="File" />
+        </config-file>
+        <js-module src="www/blackberry10/fileUtils.js" name="BB10Utils" />
+        <js-module src="www/blackberry10/DirectoryEntry.js" name="BB10DirectoryEntry">
+            <clobbers target="window.DirectoryEntry" />
+        </js-module>
+        <js-module src="www/blackberry10/DirectoryReader.js" name="BB10DirectoryReader">
+            <clobbers target="window.DirectoryReader" />
+        </js-module>
+        <js-module src="www/blackberry10/Entry.js" name="BB10Entry">
+            <clobbers target="window.Entry" />
+        </js-module>       
+        <js-module src="www/blackberry10/FileEntry.js" name="BB10FileEntry">
+            <clobbers target="window.FileEntry" />
+        </js-module>
+        <js-module src="www/blackberry10/FileReader.js" name="BB10FileReader">
+            <clobbers target="window.FileReader" />
+        </js-module>
+        <js-module src="www/blackberry10/FileSystem.js" name="BB10FileSystem">
+            <clobbers target="window.FileSystem" />
+        </js-module>
+        <js-module src="www/blackberry10/FileWriter.js" name="BB10FileWriter">
+            <clobbers target="window.FileWriter" />
+        </js-module>
+        <js-module src="www/blackberry10/requestFileSystem.js" name="BB10requestFileSystem">
+            <clobbers target="window.requestFileSystem" />
+        </js-module>
+        <js-module src="www/blackberry10/resolveLocalFileSystemURI.js" name="BB10resolveLocalFileSystemURI">
+            <clobbers target="window.resolveLocalFileSystemURI" />
+        </js-module>
+    </platform>
+
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/DirectoryEntry.js b/www/blackberry10/DirectoryEntry.js
new file mode 100644
index 0000000..86fc7ea
--- /dev/null
+++ b/www/blackberry10/DirectoryEntry.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var argscheck = require('cordova/argscheck'),
+    utils = require('cordova/utils'),
+    Entry = require('org.apache.cordova.core.FileUtils.BB10Entry'),
+    FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    DirectoryReader = require('org.apache.cordova.core.FileUtils.DirectoryReader'),
+    fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils'),
+    DirectoryEntry = function (name, fullPath) {
+        DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
+    };
+
+utils.extend(DirectoryEntry, Entry);
+
+DirectoryEntry.prototype.createReader = function () {
+    return new DirectoryReader(this.fullPath);
+};
+
+DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback)
{
+    argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
+    this.nativeEntry.getDirectory(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
+};
+
+DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
+    this.nativeEntry.removeRecursively(successCallback, errorCallback);
+};
+
+DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback)
{
+    argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
+    this.nativeEntry.getFile(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
+};
+
+module.exports = DirectoryEntry;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/DirectoryReader.js b/www/blackberry10/DirectoryReader.js
new file mode 100644
index 0000000..bce6df1
--- /dev/null
+++ b/www/blackberry10/DirectoryReader.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils');
+
+function DirectoryReader(path) {
+    this.path = path;
+}
+
+DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
+    var win = typeof successCallback !== 'function' ? null : function(result) {
+            var retVal = [];
+            for (var i=0; i<result.length; i++) {
+                retVal.push(fileUtils.createEntry(result[i]));
+            }
+            successCallback(retVal);
+        },
+        fail = typeof errorCallback !== 'function' ? null : function(code) {
+            errorCallback(new FileError(code));
+        };
+    fileUtils.getEntryForURI(this.path, function (entry) {
+        entry.nativeEntry.createReader().readEntries(win, fail);
+    }, function () {
+        fail(FileError.NOT_FOUND_ERR);
+    });
+};
+
+module.exports = DirectoryReader;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/Entry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/Entry.js b/www/blackberry10/Entry.js
new file mode 100644
index 0000000..94bf079
--- /dev/null
+++ b/www/blackberry10/Entry.js
@@ -0,0 +1,112 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var argscheck = require('cordova/argscheck'),
+    FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    Metadata = require('org.apache.cordova.core.FileUtils.Metadata'),
+    fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils');
+
+function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
+    this.isFile = !!isFile;
+    this.isDirectory = !!isDirectory;
+    this.name = name || '';
+    this.fullPath = fullPath || '';
+    this.filesystem = fileSystem || null;
+}
+
+Entry.prototype.getMetadata = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
+    var success = function(lastModified) {
+        var metadata = new Metadata(lastModified);
+        if (typeof successCallback === 'function') {
+            successCallback(metadata);
+        }
+    };
+    this.nativeEntry.getMetadata(success, errorCallback);
+};
+
+Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
+    argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
+    errorCallback("Not supported by platform");
+};
+
+Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
+    argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
+    var srcPath = this.fullPath,
+        name = newName || this.name,
+        success = function(entry) {
+            if (entry) {
+                if (typeof successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
+                }
+            }
+            else {
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
+                }
+            }
+        };
+    this.nativeEntry.moveTo(parent.nativeEntry, newName, success, errorCallback);
+};
+
+
+Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
+    argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
+    var srcPath = this.fullPath,
+        name = newName || this.name,
+        success = function(entry) {
+            if (entry) {
+                if (typeof successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
+                }
+            }
+            else {
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
+                }
+            }
+        };
+    this.nativeEntry.copyTo(parent.nativeEntry, newName, success, errorCallback);
+};
+
+Entry.prototype.toURL = function() {
+    return this.fullPath;
+};
+
+Entry.prototype.toURI = function(mimeType) {
+    console.log("DEPRECATED: Update your code to use 'toURL'");
+    return this.toURL();
+};
+
+Entry.prototype.remove = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.remove', arguments);
+    this.nativeEntry.remove(successCallback, errorCallback);
+};
+
+Entry.prototype.getParent = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.getParent', arguments);
+    var win = successCallback && function(result) {
+        successCallback(fileUtils.createEntry(result));
+    };
+    this.nativeEntry.getParent(win, errorCallback);
+};
+
+module.exports = Entry;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/FileEntry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileEntry.js b/www/blackberry10/FileEntry.js
new file mode 100644
index 0000000..4b9a690
--- /dev/null
+++ b/www/blackberry10/FileEntry.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var utils = require('cordova/utils'),
+    Entry = require('org.apache.cordova.core.FileUtils.BB10Entry'),
+    FileWriter = require('org.apache.cordova.core.FileUtils.BB10FileWriter'),
+    File = require('org.apache.cordova.core.FileUtils.File'),
+    FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    FileEntry = function (name, fullPath) {
+        FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
+    };
+
+utils.extend(FileEntry, Entry);
+
+FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
+    this.file(function (file) {
+        successCallback(new FileWriter(file));
+    }, errorCallback);
+};
+
+FileEntry.prototype.file = function(successCallback, errorCallback) {
+    var fullPath = this.fullPath,
+        success = function (file) {
+            successCallback(new File(file.name, fullPath, file.type, file.lastModifiedDate,
file.size));
+        };
+    this.nativeEntry.file(success, errorCallback);
+};
+
+module.exports = FileEntry;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/FileReader.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileReader.js b/www/blackberry10/FileReader.js
new file mode 100644
index 0000000..51c0634
--- /dev/null
+++ b/www/blackberry10/FileReader.js
@@ -0,0 +1,90 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var origFileReader = window.FileReader,
+    fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils'),
+    utils = require('cordova/utils');
+
+var FileReader = function() {
+    this.nativeReader = new origFileReader();
+};
+
+utils.defineGetter(FileReader.prototype, 'readyState', function() {
+    return this.nativeReader.readyState;
+});
+
+utils.defineGetter(FileReader.prototype, 'error', function() {
+    return this.nativeReader.error;
+});
+
+utils.defineGetter(FileReader.prototype, 'result', function() {
+    return this.nativeReader.result;
+});
+
+function defineEvent(eventName) {
+    utils.defineGetterSetter(FileReader.prototype, eventName, function() {
+        return this.nativeReader[eventName] || null;
+    }, function(value) {
+        this.nativeReader[eventName] = value;
+    });
+}
+
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onload');
+defineEvent('onloadend');
+defineEvent('onloadstart');
+defineEvent('onprogress');
+
+FileReader.prototype.abort = function() {
+    return this.nativeReader.abort();
+};
+
+function read(method, context, file, encoding) {
+    if (file.fullPath) {
+         fileUtils.getEntryForURI(file.fullPath, function (entry) {
+            entry.nativeEntry.file(function (nativeFile) {
+                context.nativeReader[method].call(context.nativeReader, nativeFile, encoding);
+            }, context.onerror);
+        }, context.onerror);
+    } else {
+        context.nativeReader[method](file, encoding);
+    }
+}
+
+FileReader.prototype.readAsText = function(file, encoding) {
+    read("readAsText", this, file, encoding);
+};
+
+FileReader.prototype.readAsDataURL = function(file) {
+    read("readAsDataURL", this, file);
+};
+
+FileReader.prototype.readAsBinaryString = function(file) {
+    read("readAsBinaryString", this, file);
+};
+
+FileReader.prototype.readAsArrayBuffer = function(file) {
+    read("readAsArrayBuffer", this, file);
+};
+
+window.FileReader = FileReader;
+module.exports = FileReader;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/FileSystem.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileSystem.js b/www/blackberry10/FileSystem.js
new file mode 100644
index 0000000..d1432d6
--- /dev/null
+++ b/www/blackberry10/FileSystem.js
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = function(name, root) {
+    this.name = name || null;
+    if (root) {
+        this.root = root;
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/FileWriter.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileWriter.js b/www/blackberry10/FileWriter.js
new file mode 100644
index 0000000..f4c3e5f
--- /dev/null
+++ b/www/blackberry10/FileWriter.js
@@ -0,0 +1,120 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    ProgressEvent = require('org.apache.cordova.core.FileUtils.ProgressEvent'),
+    fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils'),
+    utils = require('cordova/utils');
+
+function FileWriter (file) {
+    var that = this;
+    this.file = file;
+    this.events = {};
+    this.pending = [];
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.createWriter(function (writer) {
+            var i,
+                event;
+            that.nativeWriter = writer;
+            for (event in that.events) {
+                if (that.events.hasOwnProperty(event)) {
+                    that.nativeWriter[event] = that.events[event];
+                }
+            }
+            for (i = 0; i < that.pending.length; i++) {
+                that.pending[i]();
+            }
+        });
+    });
+    this.events = {};
+    this.pending = [];
+}
+
+utils.defineGetter(FileWriter.prototype, 'error', function() {
+    return this.nativeWriter ? this.nativeWriter.error : null;
+});
+
+utils.defineGetter(FileWriter.prototype, 'fileName', function() {
+    return this.nativeWriter ? this.nativeWriter.fileName : this.file.name;
+});
+
+utils.defineGetter(FileWriter.prototype, 'length', function() {
+    return this.nativeWriter ? this.nativeWriter.length : this.file.size;
+});
+
+utils.defineGetter(FileWriter.prototype, 'position', function() {
+    return this.nativeWriter ? this.nativeWriter.position : 0;
+});
+
+utils.defineGetter(FileWriter.prototype, 'readyState', function() {
+    return this.nativeWriter ? this.nativeWriter.readyState : 0;
+});
+
+function defineEvent(eventName) {
+    utils.defineGetterSetter(FileWriter.prototype, eventName, function() {
+        return this.nativeWriter ? this.nativeWriter[eventName] || null : this.events[eventName]
|| null;
+    }, function(value) {
+        if (this.nativeWriter) {
+            this.nativeWriter[eventName] = value;
+        }
+        else {
+            this.events[eventName] = value;
+        }
+    });
+}
+
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onprogress');
+defineEvent('onwrite');
+defineEvent('onwriteend');
+defineEvent('onwritestart');
+
+FileWriter.prototype.abort = function() {
+    this.nativeWriter.abort();
+};
+
+FileWriter.prototype.write = function(text) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.write(new Blob([text]));
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+
+};
+
+FileWriter.prototype.seek = function(offset) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.seek(offset);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+};
+
+FileWriter.prototype.truncate = function(size) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.truncate(size);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+};
+
+module.exports = FileWriter;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/fileUtils.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/fileUtils.js b/www/blackberry10/fileUtils.js
new file mode 100644
index 0000000..e26e4e9
--- /dev/null
+++ b/www/blackberry10/fileUtils.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+function convertPath(url) {
+    return decodeURI(url).substring(11).replace(/\/$/, '');
+}
+
+module.exports = {
+
+    createEntry: function (entry) {
+        var cordovaEntry;
+        if (entry.isFile) {
+            cordovaEntry = new window.FileEntry(entry.name, convertPath(entry.toURL()));
+        } else {
+            cordovaEntry = new window.DirectoryEntry(entry.name, convertPath(entry.toURL()));
+        }
+        cordovaEntry.nativeEntry = entry;
+        return cordovaEntry;
+    },
+
+    getEntryForURI: function (uri, success, fail) {
+        //TODO: account for local vs file system
+        window.resolveLocalFileSystemURI(uri, success, fail);
+    },
+
+    getFileSystemName: function (fs) {
+        return (fs.name.indexOf('Persistent') != -1) ? 'persistent' : 'temporary';
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/requestFileSystem.js b/www/blackberry10/requestFileSystem.js
new file mode 100644
index 0000000..df37264
--- /dev/null
+++ b/www/blackberry10/requestFileSystem.js
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils'),
+    FileError = require('org.apache.cordova.core.FileUtils.FileError'),
+    FileSystem = require('org.apache.cordova.core.FileUtils.BB10FileSystem');
+
+module.exports = function (type, size, success, fail) {
+    if (size >= 1000000000000000) {
+        fail(new FileError(FileError.QUOTA_EXCEEDED_ERR));
+    } else if (type !== 1 && type !== 0) {
+        fail(new FileError(FileError.SYNTAX_ERR));
+    } else {
+        window.webkitRequestFileSystem(type, size, function (fs) {
+            success((new FileSystem(fileUtils.getFileSystemName(fs), fileUtils.createEntry(fs.root))));
+        }, function (error) {
+            fail(new FileError(error));
+        });
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/c409079d/www/blackberry10/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/resolveLocalFileSystemURI.js b/www/blackberry10/resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..57bda95
--- /dev/null
+++ b/www/blackberry10/resolveLocalFileSystemURI.js
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var fileUtils = require('org.apache.cordova.core.FileUtils.BB10Utils'),
+    FileError = require('org.apache.cordova.core.FileUtils.FileError');
+
+module.exports = function (uri, success, fail) {
+    var type,
+        path,
+        paramPath;
+    if (!uri || uri.indexOf("/") === 0) {
+        fail(new FileError(FileError.ENCODING_ERR));
+    } else {
+        type = uri.indexOf("persistent") === -1 ? 0 : 1;
+        path = uri.substring(type === 1 ? uri.indexOf("persistent") + 11 : uri.indexOf("temporary")
+ 10);
+        if (path.substring(0,1) == "/") {
+            path = path.substring(1);
+        }
+        paramPath = path.indexOf("?");
+        if (paramPath > -1) {
+            path = path.substring(0, paramPath);
+        }
+        window.webkitRequestFileSystem(type, 25*1024*1024, function (fs) {
+            if (path === "") {
+                success(fileUtils.createEntry(fs.root));
+            } else {
+                fs.root.getDirectory(path, {}, function (entry) {
+                    success(fileUtils.createEntry(entry));
+                }, function () {
+                    fs.root.getFile(path, {}, function (entry) {
+                        success(fileUtils.createEntry(entry));
+                    }, fail);
+                });
+            }
+        }, fail);
+    }
+};


Mime
View raw message