* 文件类 * @class File * @constructor 构造函数 * @grammar new File( source ) => File * @param {Lib.File} source [lib.File](#Lib.File)实例, 此source对象是带有Runtime信息的。
( source )
| 2399 | * @param {Lib.File} source [lib.File](#Lib.File)实例, 此source对象是带有Runtime信息的。 |
| 2400 | */ |
| 2401 | function WUFile( source ) { |
| 2402 | |
| 2403 | /** |
| 2404 | * 文件名,包括扩展名(后缀) |
| 2405 | * @property name |
| 2406 | * @type {string} |
| 2407 | */ |
| 2408 | this.name = source.name || 'Untitled'; |
| 2409 | |
| 2410 | /** |
| 2411 | * 文件体积(字节) |
| 2412 | * @property size |
| 2413 | * @type {uint} |
| 2414 | * @default 0 |
| 2415 | */ |
| 2416 | this.size = source.size || 0; |
| 2417 | |
| 2418 | /** |
| 2419 | * 文件MIMETYPE类型,与文件类型的对应关系请参考[http://t.cn/z8ZnFny](http://t.cn/z8ZnFny) |
| 2420 | * @property type |
| 2421 | * @type {string} |
| 2422 | * @default 'application/octet-stream' |
| 2423 | */ |
| 2424 | this.type = source.type || 'application/octet-stream'; |
| 2425 | |
| 2426 | /** |
| 2427 | * 文件最后修改日期 |
| 2428 | * @property lastModifiedDate |
| 2429 | * @type {int} |
| 2430 | * @default 当前时间戳 |
| 2431 | */ |
| 2432 | this.lastModifiedDate = source.lastModifiedDate || (new Date() * 1); |
| 2433 | |
| 2434 | /** |
| 2435 | * 文件ID,每个对象具有唯一ID,与文件名无关 |
| 2436 | * @property id |
| 2437 | * @type {string} |
| 2438 | */ |
| 2439 | this.id = gid(); |
| 2440 | |
| 2441 | /** |
| 2442 | * 文件扩展名,通过文件名获取,例如test.png的扩展名为png |
| 2443 | * @property ext |
| 2444 | * @type {string} |
| 2445 | */ |
| 2446 | this.ext = rExt.exec( this.name ) ? RegExp.$1 : ''; |
| 2447 | |
| 2448 | |
| 2449 | /** |
| 2450 | * 状态文字说明。在不同的status语境下有不同的用途。 |
| 2451 | * @property statusText |
| 2452 | * @type {string} |
| 2453 | */ |
| 2454 | this.statusText = ''; |
| 2455 | |
| 2456 | // 存储文件状态,防止通过属性直接修改 |
| 2457 | statusMap[ this.id ] = WUFile.Status.INITED; |
| 2458 |