1cordova.define("cordova-plugin-file.DirectoryReader", function(require, exports, module) { /* 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 22const exec = require('cordova/exec'); 23const FileError = require('./FileError'); 24 25/** 26 * An interface that lists the files and directories in a directory. 27 */ 28function DirectoryReader (localURL) { 29 this.localURL = localURL || null; 30 this.hasReadEntries = false; 31} 32 33/** 34 * Returns a list of entries from a directory. 35 * 36 * @param {Function} successCallback is called with a list of entries 37 * @param {Function} errorCallback is called with a FileError 38 */ 39DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) { 40 // If we've already read and passed on this directory's entries, return an empty list. 41 if (this.hasReadEntries) { 42 successCallback([]); 43 return; 44 } 45 const reader = this; 46 const win = typeof successCallback !== 'function' 47 ? null 48 : function (result) { 49 const retVal = []; 50 for (let i = 0; i < result.length; i++) { 51 let entry = null; 52 if (result[i].isDirectory) { 53 entry = new (require('./DirectoryEntry'))(); 54 } else if (result[i].isFile) { 55 entry = new (require('./FileEntry'))(); 56 } 57 entry.isDirectory = result[i].isDirectory; 58 entry.isFile = result[i].isFile; 59 entry.name = result[i].name; 60 entry.fullPath = result[i].fullPath; 61 entry.filesystem = new (require('./FileSystem'))(result[i].filesystemName); 62 entry.nativeURL = result[i].nativeURL; 63 retVal.push(entry); 64 } 65 reader.hasReadEntries = true; 66 successCallback(retVal); 67 }; 68 const fail = typeof errorCallback !== 'function' 69 ? null 70 : function (code) { 71 errorCallback(new FileError(code)); 72 }; 73 exec(win, fail, 'File', 'readEntries', [this.localURL]); 74}; 75 76module.exports = DirectoryReader; 77 78});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.