(path: string, isLstat: boolean, cb: BFSCallback<Stats>)
| 209 | } |
| 210 | |
| 211 | public stat(path: string, isLstat: boolean, cb: BFSCallback<Stats>): void { |
| 212 | const inode = this._index.getInode(path); |
| 213 | if (inode === null) { |
| 214 | return cb(ApiError.ENOENT(path)); |
| 215 | } |
| 216 | let stats: Stats; |
| 217 | if (isFileInode<Stats>(inode)) { |
| 218 | stats = inode.getData(); |
| 219 | // At this point, a non-opened file will still have default stats from the listing. |
| 220 | if (stats.size < 0) { |
| 221 | this._requestFileSizeAsync(path, function(e: ApiError, size?: number) { |
| 222 | if (e) { |
| 223 | return cb(e); |
| 224 | } |
| 225 | stats.size = size!; |
| 226 | cb(null, stats.clone()); |
| 227 | }); |
| 228 | } else { |
| 229 | cb(null, stats.clone()); |
| 230 | } |
| 231 | } else if (isDirInode(inode)) { |
| 232 | stats = inode.getStats(); |
| 233 | cb(null, stats); |
| 234 | } else { |
| 235 | cb(ApiError.FileError(ErrorCode.EINVAL, path)); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | public statSync(path: string, isLstat: boolean): Stats { |
| 240 | const inode = this._index.getInode(path); |
nothing calls this directly
no test coverage detected