arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
openEventsPlatformApp/plugins/cordova-plugin-file/www/blackberry10/getFile.js
plugins/cordova-plugin-file/www/blackberry10/getFile.jsRaw
 1/*
 2 *
 3 * Licensed to the Apache Software Foundation (ASF) under one
 4 * or more contributor license agreements.  See the NOTICE file
 5 * distributed with this work for additional information
 6 * regarding copyright ownership.  The ASF licenses this file
 7 * to you under the Apache License, Version 2.0 (the
 8 * "License"); you may not use this file except in compliance
 9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22/* 
23 * getFile
24 *
25 * IN:
26 *  args
27 *   0 - local filesytem URI for the base directory to search
28 *   1 - file to be created/returned; may be absolute path or relative path
29 *   2 - options object
30 * OUT:
31 *  success - FileEntry
32 *  fail - FileError code
33 */
34
35var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy');
36
37module.exports = function (success, fail, args) {
38    var uri = args[0] === "/" ? "" : args[0] + "/" + args[1],
39        options = args[2],
40        onSuccess = function (entry) {
41            if (typeof(success) === 'function') {
42                success(entry);
43            }
44        },
45        onFail = function (code) {
46            if (typeof(fail) === 'function') {
47                fail(code);
48            }
49        };
50    resolve(function (entry) {
51        if (!entry.isFile) {
52            onFail(FileError.TYPE_MISMATCH_ERR);
53        } else {
54            onSuccess(entry);
55        }
56    }, onFail, [uri, options]);
57};