* 文件类 * @class File * @constructor 构造函数 * @grammar new File( source ) => File * @param {Lib.File} source [lib.File](#Lib.File)实例, 此source对象是带有Runtime信息的。
( source )
| 1976 | * @param {Lib.File} source [lib.File](#Lib.File)实例, 此source对象是带有Runtime信息的。 |
| 1977 | */ |
| 1978 | function WUFile( source ) { |
| 1979 | |
| 1980 | /** |
| 1981 | * 文件名,包括扩展名(后缀) |
| 1982 | * @property name |
| 1983 | * @type {string} |
| 1984 | */ |
| 1985 | this.name = source.name || 'Untitled'; |
| 1986 | |
| 1987 | /** |
| 1988 | * 文件体积(字节) |
| 1989 | * @property size |
| 1990 | * @type {uint} |
| 1991 | * @default 0 |
| 1992 | */ |
| 1993 | this.size = source.size || 0; |
| 1994 | |
| 1995 | /** |
| 1996 | * 文件MIMETYPE类型,与文件类型的对应关系请参考[http://t.cn/z8ZnFny](http://t.cn/z8ZnFny) |
| 1997 | * @property type |
| 1998 | * @type {string} |
| 1999 | * @default 'application/octet-stream' |
| 2000 | */ |
| 2001 | this.type = source.type || 'application/octet-stream'; |
| 2002 | |
| 2003 | /** |
| 2004 | * 文件最后修改日期 |
| 2005 | * @property lastModifiedDate |
| 2006 | * @type {int} |
| 2007 | * @default 当前时间戳 |
| 2008 | */ |
| 2009 | this.lastModifiedDate = source.lastModifiedDate || (new Date() * 1); |
| 2010 | |
| 2011 | /** |
| 2012 | * 文件ID,每个对象具有唯一ID,与文件名无关 |
| 2013 | * @property id |
| 2014 | * @type {string} |
| 2015 | */ |
| 2016 | this.id = gid(); |
| 2017 | |
| 2018 | /** |
| 2019 | * 文件扩展名,通过文件名获取,例如test.png的扩展名为png |
| 2020 | * @property ext |
| 2021 | * @type {string} |
| 2022 | */ |
| 2023 | this.ext = rExt.exec( this.name ) ? RegExp.$1 : ''; |
| 2024 | |
| 2025 | |
| 2026 | /** |
| 2027 | * 状态文字说明。在不同的status语境下有不同的用途。 |
| 2028 | * @property statusText |
| 2029 | * @type {string} |
| 2030 | */ |
| 2031 | this.statusText = ''; |
| 2032 | |
| 2033 | // 存储文件状态,防止通过属性直接修改 |
| 2034 | statusMap[ this.id ] = WUFile.Status.INITED; |
| 2035 |