1/* 2 * Copyright (c) 2015 3 * 4 * This file is licensed under the Affero General Public License version 3 5 * or later. 6 * 7 * See the COPYING-README file. 8 * 9 */ 10 11(function(OC) { 12 13 /** 14 * @class OC.Files.FileInfo 15 * @classdesc File information 16 * 17 * @param {Object} data file data, see attributes for details 18 * 19 * @since 8.2 20 */ 21 var FileInfo = function(data) { 22 var self = this; 23 _.each(data, function(value, key) { 24 if (!_.isFunction(value)) { 25 self[key] = value; 26 } 27 }); 28 29 if (!_.isUndefined(this.id)) { 30 this.id = parseInt(data.id, 10); 31 } 32 33 // TODO: normalize path 34 this.path = data.path || ''; 35 36 if (this.type === 'dir') { 37 this.mimetype = 'httpd/unix-directory'; 38 } else { 39 this.mimetype = this.mimetype || 'application/octet-stream'; 40 } 41 42 if (!this.type) { 43 if (this.mimetype === 'httpd/unix-directory') { 44 this.type = 'dir'; 45 } else { 46 this.type = 'file'; 47 } 48 } 49 }; 50 51 /** 52 * @memberof OC.Files 53 */ 54 FileInfo.prototype = { 55 /** 56 * File id 57 * 58 * @type int 59 */ 60 id: null, 61 62 /** 63 * File name 64 *
65 * @type String 66 */ 67 name: null, 68 69 /** 70 * Path leading to the file, without the file name, 71 * and with a leading slash. 72 * 73 * @type String 74 */ 75 path: null, 76 77 /** 78 * Mime type 79 * 80 * @type String 81 */ 82 mimetype: null, 83 84 /** 85 * Icon URL. 86 * 87 * Can be used to override the mime type icon. 88 * 89 * @type String 90 */ 91 icon: null, 92 93 /** 94 * File type. 'file' for files, 'dir' for directories. 95 * 96 * @type String 97 * @deprecated rely on mimetype instead 98 */ 99 type: null, 100 101 /** 102 * Permissions. 103 * 104 * @see OC#PERMISSION_ALL for permissions 105 * @type int 106 */ 107 permissions: null, 108 109 /** 110 * Modification time 111 * 112 * @type int 113 */ 114 mtime: null, 115 116 /** 117 * Etag 118 * 119 * @type String 120 */ 121 etag: null, 122 123 /** 124 * Mount type. 125 * 126 * One of null, "external-root", "shared" or "shared-root" 127 * 128 * @type string 129 */ 130 mountType: null 131 }; 132 133 if (!OC.Files) { 134 OC.Files = {}; 135 } 136 OC.Files.FileInfo = FileInfo; 137})(OC); 138
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.