| 105 | }, |
| 106 | |
| 107 | async stats(uri) { |
| 108 | const storageList = helpers.parseJSON(localStorage.getItem("storageList")); |
| 109 | |
| 110 | if (Array.isArray(storageList)) { |
| 111 | const storage = storageList.find((s) => s.uri === uri); |
| 112 | if (storage) { |
| 113 | const stat = { |
| 114 | size: 0, |
| 115 | name: storage.name, |
| 116 | type: "dir", |
| 117 | canRead: true, |
| 118 | canWrite: true, |
| 119 | modifiedDate: new Date(), |
| 120 | isDirectory: true, |
| 121 | isFile: false, |
| 122 | url: uri, |
| 123 | }; |
| 124 | |
| 125 | helpers.defineDeprecatedProperty( |
| 126 | stat, |
| 127 | "uri", |
| 128 | function () { |
| 129 | return this.url; |
| 130 | }, |
| 131 | function (val) { |
| 132 | this.url = val; |
| 133 | }, |
| 134 | ); |
| 135 | |
| 136 | return stat; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | uri = await this.formatUri(uri); |
| 141 | return new Promise((resolve, reject) => { |
| 142 | sdcard.stats( |
| 143 | uri, |
| 144 | (stats) => { |
| 145 | helpers.defineDeprecatedProperty( |
| 146 | stats, |
| 147 | "uri", |
| 148 | function () { |
| 149 | return this.url; |
| 150 | }, |
| 151 | function (val) { |
| 152 | this.url = val; |
| 153 | }, |
| 154 | ); |
| 155 | resolve(stats); |
| 156 | }, |
| 157 | reject, |
| 158 | ); |
| 159 | }); |
| 160 | }, |
| 161 | |
| 162 | /** |
| 163 | * Format the virtual uri to a real uri |