├── settings.gradle ├── config ├── application.properties ├── fileServer.properties └── logback.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── src └── main │ └── java │ └── com │ └── fileup │ ├── bitsyntax │ ├── function │ │ ├── package-info.java │ │ ├── FromBytes.java │ │ ├── ToBytes.java │ │ └── BitConvertLib.java │ ├── CCBytes.java │ ├── bean │ │ ├── Boundary.java │ │ ├── BaseBean.java │ │ └── Bitem.java │ ├── CCFLib.java │ ├── CCDataView.java │ ├── CCBitmap.java │ └── CCBitsyntax.java │ ├── bean │ ├── CommandType.java │ ├── BSet.java │ ├── UploadCommand.java │ └── FileTarget.java │ ├── util │ ├── PropertyLoadUtil.java │ ├── RocksDbUtil.java │ ├── Paths.java │ ├── BtxUtil.java │ ├── StringUtil.java │ └── BytesUtil.java │ ├── LogbackInit.java │ ├── WebSocketServer.java │ ├── Config.java │ ├── FileServerApp.java │ └── netty │ ├── WebSocketChannelInitializer.java │ └── BinaryWebSocketFrameHandler.java ├── .gitignore ├── .project ├── .classpath └── public ├── index.html └── js ├── crypto-min.js ├── hashWorker.min.js ├── md5Worker.min.js ├── CCFileUp.min.js ├── hashWorker.js ├── md5Worker.js ├── bst.min.js ├── CCFileUp.js ├── FileUtil.min.js └── FileUtil.js /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FileServer' -------------------------------------------------------------------------------- /config/application.properties: -------------------------------------------------------------------------------- 1 | logging.config=config/logback.xml 2 | #logging.level.root=info 3 | server.port=8091 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCLooMi/FileServer/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /config/fileServer.properties: -------------------------------------------------------------------------------- 1 | server.port=8899 2 | server.zimg.types=jpeg,jpg,png,gif,webp 3 | server.file.zimg.path=/usr/local/zimg/img 4 | server.file.save.path=upload -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FileServer 2 | 用HTML5的websocket技术实现的文件上传服务 3 | * 支持断点续传 4 | * 支持秒传 5 | * 连接断开或异常自动重连,自动继续断点上传 6 | * 同一个文件上传的客户端越多上传越快 7 | * 支持超大文件上传 8 | * 图片支持上传到zimg目录(非windows平台) 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/function/package-info.java: -------------------------------------------------------------------------------- 1 | /**© 2015-2017 Chenxj Copyright 2 | * 类 名:package-info 3 | * 类 描 述: 4 | * 作 者:chenxj 5 | * 邮 箱:chenios@foxmail.com 6 | * 日 期:2017年9月15日-下午6:53:04 7 | */ 8 | package com.fileup.bitsyntax.function; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .DS_Store 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.war 8 | *.ear 9 | 10 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 11 | hs_err_pid* 12 | .gradle/ 13 | .settings/ 14 | bin/ 15 | build/ 16 | db/ 17 | upload/ 18 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/function/FromBytes.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.function; 2 | 3 | /**© 2015-2017 Chenxj Copyright 4 | * 类 名:FromBytes 5 | * 类 描 述: 6 | * 作 者:chenxj 7 | * 邮 箱:chenios@foxmail.com 8 | * 日 期:2017年9月16日-下午2:18:53 9 | */ 10 | @FunctionalInterface 11 | public interface FromBytes{ 12 | public Object apply(Object o); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/function/ToBytes.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.function; 2 | 3 | /**© 2015-2017 Chenxj Copyright 4 | * 类 名:ToBytes 5 | * 类 描 述: 6 | * 作 者:chenxj 7 | * 邮 箱:chenios@foxmail.com 8 | * 日 期:2017年9月16日-下午2:19:01 9 | */ 10 | @FunctionalInterface 11 | public interface ToBytes{ 12 | public byte[] apply(Object o,Integer l); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bean/CommandType.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bean; 2 | 3 | /**© 2015-2019 Chenxj Copyright 4 | * 类 名:CommandType 5 | * 类 描 述: 6 | * 作 者:chenxj 7 | * 邮 箱:chenios@foxmail.com 8 | * 日 期:2019年1月15日-下午8:34:22 9 | */ 10 | public interface CommandType { 11 | public static int UPLOAD_FILE=0; 12 | public static int UPLOAD_COMMAND=1; 13 | public static int UPLOAD_DATA=2; 14 | public static int UPLOAD_COMPLETE=3; 15 | } 16 | -------------------------------------------------------------------------------- /config/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | %d{yyyy-MM-dd HH:mm:ss.SSS}[%thread]%-5level %logger{5} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FileServer 4 | Project FileServer 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.springsource.ide.eclipse.gradle.core.nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/util/PropertyLoadUtil.java: -------------------------------------------------------------------------------- 1 | package com.fileup.util; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | /**@类名 PropertyLoadUtil 9 | * @说明 10 | * @作者 Chenxj 11 | * @邮箱 chenios@foxmail.com 12 | * @日期 2016年10月28日-下午3:58:00 13 | */ 14 | public class PropertyLoadUtil { 15 | public static Properties loadProperties(String name) { 16 | Properties p=new Properties(); 17 | FileInputStream fin=null; 18 | try { 19 | File pFile=Paths.getUserDirFile("config",name.endsWith(".properties")?name:name+".properties"); 20 | if(pFile.exists()) { 21 | fin = new FileInputStream(pFile); 22 | p.load(fin); 23 | } 24 | } catch (Exception e) {} 25 | finally { 26 | if(fin!=null) {try {fin.close();}catch (IOException e) {}} 27 | } 28 | return p; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/CCBytes.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.util.Collection; 6 | 7 | /**© 2015-2017 Chenxj Copyright 8 | * 类 名:CCBytes 9 | * 类 描 述: 10 | * 作 者:chenxj 11 | * 邮 箱:chenios@foxmail.com 12 | * 日 期:2017年9月16日-下午5:09:24 13 | */ 14 | public class CCBytes { 15 | private ByteArrayOutputStream bout; 16 | public CCBytes(){ 17 | this.bout=new ByteArrayOutputStream(); 18 | } 19 | 20 | public CCBytes addAll(Collectioncbs){ 21 | for(byte[]bs:cbs){ 22 | this.addAll(bs); 23 | } 24 | return this; 25 | } 26 | public CCBytes addAll(byte[]bs){ 27 | try { 28 | this.bout.write(bs); 29 | } catch (IOException e) { 30 | e.printStackTrace(); 31 | } 32 | return this; 33 | } 34 | public byte[]getBytes(){ 35 | return bout.toByteArray(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/bean/Boundary.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.bean; 2 | 3 | /**© 2015-2017 Chenxj Copyright 4 | * 类 名:Boundary 5 | * 类 描 述: 6 | * 作 者:chenxj 7 | * 邮 箱:chenios@foxmail.com 8 | * 日 期:2017年9月15日-下午3:21:54 9 | */ 10 | public class Boundary extends BaseBean{ 11 | private static final long serialVersionUID = 5568731424046832313L; 12 | private int index; 13 | private int offset; 14 | public Boundary(){ 15 | 16 | } 17 | public Boundary(int index,int offset){ 18 | this.index=index; 19 | this.offset=offset; 20 | } 21 | /**获取 index*/ 22 | public int getIndex() { 23 | return index; 24 | } 25 | /**设置 index*/ 26 | public void setIndex(int index) { 27 | this.index = index; 28 | } 29 | /**获取 offset*/ 30 | public int getOffset() { 31 | return offset; 32 | } 33 | /**设置 offset*/ 34 | public void setOffset(int offset) { 35 | this.offset = offset; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/LogbackInit.java: -------------------------------------------------------------------------------- 1 | package com.fileup; 2 | 3 | import java.io.File; 4 | 5 | import org.slf4j.LoggerFactory; 6 | 7 | import ch.qos.logback.classic.LoggerContext; 8 | import ch.qos.logback.classic.joran.JoranConfigurator; 9 | import ch.qos.logback.core.util.StatusPrinter; 10 | 11 | public class LogbackInit { 12 | public static void initLogback(String configFilepathName) { 13 | File file = new File(configFilepathName); 14 | LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); 15 | JoranConfigurator joranConfigurator = new JoranConfigurator(); 16 | joranConfigurator.setContext(loggerContext); 17 | loggerContext.reset(); 18 | try { 19 | joranConfigurator.doConfigure(file); 20 | } catch (Exception e) { 21 | System.out.println(String.format("Load logback config file error. Message: ", e.getMessage())); 22 | } 23 | StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/util/RocksDbUtil.java: -------------------------------------------------------------------------------- 1 | package com.fileup.util; 2 | 3 | import org.rocksdb.RocksDB; 4 | import org.rocksdb.RocksDBException; 5 | 6 | public class RocksDbUtil { 7 | private static RocksDB rDb; 8 | static { 9 | try { 10 | rDb=RocksDB.open(Paths.getBaseUserDir("db")); 11 | } catch (RocksDBException e) { 12 | e.printStackTrace(); 13 | } 14 | } 15 | public static void put(byte[]key,byte[]value) { 16 | try { 17 | rDb.put(key, value); 18 | } catch (RocksDBException e) { 19 | } 20 | } 21 | public static void put(String id,byte[]value) { 22 | put(BytesUtil.hexStringToBytes(id), value); 23 | } 24 | public static byte[] get(byte[]key) { 25 | try { 26 | return rDb.get(key); 27 | } catch (RocksDBException e) { 28 | } 29 | return null; 30 | } 31 | public static byte[] get(String id) { 32 | return get(BytesUtil.hexStringToBytes(id)); 33 | } 34 | public static void delete(byte[]key) { 35 | try { 36 | rDb.delete(key); 37 | } catch (RocksDBException e) { 38 | } 39 | } 40 | public static void delete(String id) { 41 | delete(BytesUtil.hexStringToBytes(id)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/util/Paths.java: -------------------------------------------------------------------------------- 1 | package com.fileup.util; 2 | 3 | import java.io.File; 4 | 5 | /**© 2015-2018 Chenxj Copyright 6 | * 类 名:Paths 7 | * 类 描 述: 8 | * 作 者:chenxj 9 | * 邮 箱:chenios@foxmail.com 10 | * 日 期:2018年12月24日-下午8:36:44 11 | */ 12 | public class Paths { 13 | public static String get(String base,String...sa) { 14 | StringBuilder sb=new StringBuilder(); 15 | sb.append(base); 16 | for(String s:sa) { 17 | if(sb.length()>0&&sb.charAt(sb.length()-1)=='/') { 18 | if(s.charAt(0)=='/') { 19 | sb.append(new String(s.substring(1, s.length()))); 20 | }else { 21 | sb.append(s); 22 | } 23 | }else { 24 | if(s.charAt(0)=='/') { 25 | sb.append(s); 26 | }else { 27 | sb.append('/').append(s); 28 | } 29 | } 30 | } 31 | return sb.toString(); 32 | } 33 | public static String getBaseUserDir(String...sa) { 34 | return get(System.getProperty("user.dir"), sa); 35 | } 36 | public static File getFile(String base,String...sa) { 37 | return new File(get(base, sa)); 38 | } 39 | public static File getUserDirFile(String...sa) { 40 | return new File(getBaseUserDir(sa)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/util/BtxUtil.java: -------------------------------------------------------------------------------- 1 | package com.fileup.util; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Arrays; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.fileup.bitsyntax.CCBitsyntax; 9 | 10 | import io.netty.buffer.ByteBuf; 11 | import io.netty.buffer.Unpooled; 12 | 13 | 14 | public class BtxUtil { 15 | private static CCBitsyntax btx=new CCBitsyntax("hd:1/I,(hd){0:{id:16/HEX,size:8/L,suffix/U8,'#',type/U8,'#',name/U8},1:{indexStart:8/L,indexEnd:8/L,completePercent:4/I},2:{data}}"); 16 | public static CCBitsyntax btx() { 17 | return btx; 18 | } 19 | public static void main(String[] args) { 20 | ByteBuf bf=Unpooled.buffer(21); 21 | bf.writeByte(1); 22 | bf.writeLong(0); 23 | bf.writeLong(1024); 24 | bf.writeInt(1024); 25 | 26 | Mapm=new HashMap<>(); 27 | m.put("hd", 1); 28 | m.put("indexStart", 0l); 29 | m.put("indexEnd", 1024l); 30 | m.put("completePercent", 1024); 31 | System.out.println(Arrays.toString(btx.convertToByteArray(m))); 32 | 33 | ByteBuffer bb=ByteBuffer.allocate(21); 34 | bb.put((byte)1); 35 | bb.putLong(0l); 36 | bb.putLong(1024l); 37 | bb.putInt(1024); 38 | System.out.println(Arrays.toString(bb.array())); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/WebSocketServer.java: -------------------------------------------------------------------------------- 1 | package com.fileup; 2 | 3 | import java.net.InetSocketAddress; 4 | 5 | import com.fileup.netty.WebSocketChannelInitializer; 6 | import com.fileup.util.Paths; 7 | 8 | import io.netty.bootstrap.ServerBootstrap; 9 | import io.netty.channel.ChannelFuture; 10 | import io.netty.channel.EventLoopGroup; 11 | import io.netty.channel.nio.NioEventLoopGroup; 12 | import io.netty.channel.socket.nio.NioServerSocketChannel; 13 | 14 | public class WebSocketServer { 15 | public static void main(String[] args) throws Exception{ 16 | LogbackInit.initLogback(Paths.getBaseUserDir("config","logback.xml")); 17 | System.setProperty("io.netty.noUnsafe","true"); 18 | EventLoopGroup boss=new NioEventLoopGroup(); 19 | EventLoopGroup woker=new NioEventLoopGroup(); 20 | try { 21 | ServerBootstrap boot=new ServerBootstrap(); 22 | boot.group(boss, woker) 23 | .channel(NioServerSocketChannel.class) 24 | .childHandler(new WebSocketChannelInitializer()); 25 | 26 | ChannelFuture cf=boot 27 | .bind(new InetSocketAddress(Config 28 | .getConfigAsInteger("server.port",8899))) 29 | .sync(); 30 | cf.channel().closeFuture().sync(); 31 | }finally { 32 | boss.shutdownGracefully(); 33 | woker.shutdownGracefully(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/Config.java: -------------------------------------------------------------------------------- 1 | package com.fileup; 2 | 3 | import java.util.HashSet; 4 | import java.util.Properties; 5 | import java.util.Set; 6 | 7 | import com.fileup.util.PropertyLoadUtil; 8 | 9 | public class Config { 10 | public static final int blobSize=512*1024; 11 | public static Properties p; 12 | public static boolean decktopWindow=false; 13 | public static Set zimgTypes; 14 | static { 15 | p=PropertyLoadUtil.loadProperties("fileServer"); 16 | decktopWindow="windows".equalsIgnoreCase(System.getProperty("sun.desktop")); 17 | zimgTypes=new HashSet<>(); 18 | String[] ztypes=p.getProperty("server.zimg.types", "").split(","); 19 | for(String t:ztypes) { 20 | zimgTypes.add(t); 21 | zimgTypes.add('.'+t); 22 | } 23 | } 24 | public static boolean isZimgTypes(String s) { 25 | return zimgTypes.contains(s); 26 | } 27 | public static String getConfig(String key){ 28 | return p.getProperty(key); 29 | } 30 | public static String getConfig(String key,String defaultValue){ 31 | return p.getProperty(key, defaultValue); 32 | } 33 | public static Integer getConfigAsInteger(String key) { 34 | return Integer.valueOf(p.getProperty(key)); 35 | } 36 | public static Integer getConfigAsInteger(String key,Integer defaultValue) { 37 | try { 38 | return Integer.valueOf(p.getProperty(key)); 39 | }catch (Exception e) { 40 | return defaultValue; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/FileServerApp.java: -------------------------------------------------------------------------------- 1 | package com.fileup; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.util.Properties; 6 | 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 10 | 11 | import com.fileup.util.Paths; 12 | 13 | @SpringBootApplication(exclude={DataSourceAutoConfiguration.class}) 14 | public class FileServerApp { 15 | 16 | public static Class getAppClass() { 17 | return new Object() { 18 | public Class getSuperObjectClass() { 19 | String className=getClass().getName(); 20 | className=className.substring(0, className.lastIndexOf("$")); 21 | try { 22 | return Class.forName(className); 23 | } catch (ClassNotFoundException e) { 24 | return null; 25 | } 26 | } 27 | }.getSuperObjectClass(); 28 | } 29 | public static void main(String[] args) { 30 | Properties properties=new Properties(); 31 | File pfile=Paths.getUserDirFile("config","application.properties"); 32 | try { 33 | FileInputStream fin=new FileInputStream(pfile); 34 | properties.load(fin); 35 | fin.close(); 36 | SpringApplication app=new SpringApplication(getAppClass()); 37 | app.setDefaultProperties(properties); 38 | app.run(args); 39 | 40 | WebSocketServer.main(args); 41 | }catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/netty/WebSocketChannelInitializer.java: -------------------------------------------------------------------------------- 1 | package com.fileup.netty; 2 | 3 | import com.fileup.Config; 4 | 5 | import io.netty.channel.ChannelInitializer; 6 | import io.netty.channel.ChannelPipeline; 7 | import io.netty.channel.socket.SocketChannel; 8 | import io.netty.handler.codec.http.HttpObjectAggregator; 9 | import io.netty.handler.codec.http.HttpServerCodec; 10 | import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; 11 | import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; 12 | import io.netty.handler.stream.ChunkedWriteHandler; 13 | 14 | public class WebSocketChannelInitializer extends ChannelInitializer{ 15 | 16 | @Override 17 | protected void initChannel(SocketChannel ch) throws Exception { 18 | ChannelPipeline pipeline=ch.pipeline(); 19 | //websocket协议本身是基于http协议的,所以这边也要使用http解编码器 20 | pipeline.addLast(new HttpServerCodec()); 21 | //以块的方式来写的处理器 22 | pipeline.addLast(new ChunkedWriteHandler()); 23 | //netty是基于分段请求的,HttpObjectAggregator的作用是将请求分段再聚合,参数是聚合字节的最大长度 24 | pipeline.addLast(new HttpObjectAggregator(8192)); 25 | //用于将websocketFrame分段聚合 26 | pipeline.addLast(new WebSocketFrameAggregator(Config.blobSize+1)); 27 | //ws://server:port/context_path 28 | //ws://localhost:9999/ws 29 | //参数指的是contex_path 30 | pipeline.addLast(new WebSocketServerProtocolHandler("/ws",null,false,Config.blobSize+1)); 31 | //websocket定义了传递数据的6中frame类型 32 | pipeline.addLast(new BinaryWebSocketFrameHandler()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bean/BSet.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bean; 2 | 3 | /**@desc Bit Set 4 | * @date 2019年2月15日 下午3:04:36 5 | * @author chenxianjun 6 | */ 7 | public class BSet { 8 | private byte[]bs; 9 | private int length; 10 | public BSet(int length) { 11 | this.length=length; 12 | int i=length>>3; 13 | int r=(i<<3)^length; 14 | if(r>0) { 15 | i++; 16 | } 17 | this.bs=new byte[i+1]; 18 | //save r in the end byte 19 | this.bs[i]|=r; 20 | } 21 | public BSet(byte[]bs) { 22 | this.bs=bs; 23 | //reset length from end byte 24 | if(bs[bs.length-1]>0) { 25 | this.length=((bs.length-1)<<3)-(8-bs[bs.length-1]); 26 | }else { 27 | this.length=(bs.length-1)<<3; 28 | } 29 | } 30 | public BSet setBit(int index) { 31 | this.bs[index>>3]|=(1<<(8-(((index>>3)<<3)^index))); 32 | return this; 33 | } 34 | public BSet unsetBit(int index) { 35 | this.bs[index>>3]^=(1<<(8-(((index>>3)<<3)^index))); 36 | return this; 37 | } 38 | public int getBit(int index) { 39 | return (this.bs[index>>3]&(1<<(8-(((index>>3)<<3)^index))))>0?1:0; 40 | } 41 | public boolean bit(int index) { 42 | return (this.bs[index>>3]&(1<<(8-(((index>>3)<<3)^index))))>0; 43 | } 44 | public int getLength() { 45 | return this.length; 46 | } 47 | public byte[] toBytes() { 48 | return this.bs; 49 | } 50 | public static void main(String[] args) { 51 | BSet bSet=new BSet(56); 52 | BSet bSet2=new BSet(bSet.toBytes()); 53 | 54 | System.out.println(bSet2.length); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/CCFLib.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax; 2 | 3 | import static com.fileup.bitsyntax.function.BitConvertLib.*; 4 | import static com.fileup.util.BytesUtil.*; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import com.fileup.bitsyntax.function.FromBytes; 8 | import com.fileup.bitsyntax.function.ToBytes; 9 | 10 | /**© 2015-2017 Chenxj Copyright 11 | * 类 名:CCFLib 12 | * 类 描 述: 13 | * 作 者:chenxj 14 | * 邮 箱:chenios@foxmail.com 15 | * 日 期:2017年9月16日-上午10:31:05 16 | */ 17 | public abstract class CCFLib { 18 | public static final MapfromLib=new HashMap<>(); 19 | public static final MaptoLib=new HashMap<>(); 20 | static { 21 | fromLib.put("I", (o)->{return bytes2integer((byte[]) o);}); 22 | fromLib.put("U8", (o)->{return bytes2utf8((byte[]) o);}); 23 | fromLib.put("CCID", (o)->{return bytesToCCString((byte[]) o);}); 24 | fromLib.put("HEX", (o)->{return bytesToHexString((byte[]) o);}); 25 | fromLib.put("L", (o)->{return bytes2long((byte[]) o);}); 26 | fromLib.put("F", (o)->{return bytes2float((byte[]) o);}); 27 | fromLib.put("D", (o)->{return bytes2double((byte[]) o);}); 28 | toLib.put("I", (o,l)->{if(l==null||l<1) {l=4;}return integer2bytes(o, l);}); 29 | toLib.put("U8", (o,l)->{return utf82bytes(o);}); 30 | toLib.put("CCID", (o,l)->{return ccStringToBytes((String)o);}); 31 | toLib.put("HEX", (o,l)->{return hexStringToBytes((String)o);}); 32 | toLib.put("L", (o,l)->{if(l==null||l<1) {l=8;}return long2bytes(o, l);}); 33 | toLib.put("F", (o,l)->{if(l==null||l<1) {l=4;}return float2bytes(o, l);}); 34 | toLib.put("D", (o,l)->{if(l==null||l<1) {l=8;}return double2bytes(o, l);}); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/bean/BaseBean.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.bean; 2 | 3 | import java.io.Serializable; 4 | import java.lang.reflect.Method; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | 11 | /** 12 | * 类名:BaseBean 13 | * 描述:Bean基类 14 | * 作者: Chenxj 15 | * 日期:2015年6月23日 - 下午4:06:47 16 | */ 17 | public abstract class BaseBean implements Serializable{ 18 | private static final long serialVersionUID = 5295720500778299760L; 19 | protected Logger log=LoggerFactory.getLogger(getClass()); 20 | 21 | @SuppressWarnings("unchecked") 22 | public T getObjectPropertyValue(Object obj,String property){ 23 | String mName=property.substring(0,1).toUpperCase()+property.substring(1); 24 | String getMethodName="get"+mName; 25 | try { 26 | Method m=obj.getClass().getMethod(getMethodName); 27 | if(m!=null){ 28 | return (T) m.invoke(obj); 29 | } 30 | } catch (Exception e) { 31 | } 32 | return null; 33 | } 34 | @SuppressWarnings("unchecked") 35 | public T getObjectPropertyValue(Object obj,String property,Classclazz){ 36 | String mName=property.substring(0,1).toUpperCase()+property.substring(1); 37 | String getMethodName="get"+mName; 38 | try { 39 | Method m=obj.getClass().getMethod(getMethodName); 40 | if(m!=null){ 41 | return (T) m.invoke(obj); 42 | } 43 | } catch (Exception e) { 44 | } 45 | return null; 46 | } 47 | /** 48 | * 方法描述:转化为JSON字符串 49 | * 作 者:Chenxj 50 | * 日 期:2015年6月23日-下午3:28:27 51 | */ 52 | @Override 53 | public String toString(){ 54 | ObjectMapper om=new ObjectMapper(); 55 | try { 56 | return om.writeValueAsString(this); 57 | } catch (Exception e) { 58 | return super.toString(); 59 | }finally{ 60 | om=null; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bean/UploadCommand.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bean; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; 5 | 6 | /**© 2015-2019 Chenxj Copyright 7 | * 类 名:UploadCommand 8 | * 类 描 述: 9 | * 作 者:chenxj 10 | * 邮 箱:chenios@foxmail.com 11 | * 日 期:2019年1月15日-下午9:03:58 12 | */ 13 | public class UploadCommand implements CommandType{ 14 | private int hd; 15 | private String id; 16 | private long indexStart; 17 | private long indexEnd; 18 | private int index; 19 | private float completePercent; 20 | 21 | /**获取 hd*/ 22 | public int getHd() { 23 | return hd; 24 | } 25 | /**设置 hd*/ 26 | public UploadCommand setHd(int hd) { 27 | this.hd = hd; 28 | return this; 29 | } 30 | /**获取 id*/ 31 | public String getId() { 32 | return id; 33 | } 34 | /**设置 id*/ 35 | public UploadCommand setId(String id) { 36 | this.id = id; 37 | return this; 38 | } 39 | /**获取 indexStart*/ 40 | public long getIndexStart() { 41 | return indexStart; 42 | } 43 | /**设置 indexStart*/ 44 | public UploadCommand setIndexStart(long indexStart) { 45 | this.indexStart = indexStart; 46 | return this; 47 | } 48 | /**获取 indexEnd*/ 49 | public long getIndexEnd() { 50 | return indexEnd; 51 | } 52 | /**设置 indexEnd*/ 53 | public UploadCommand setIndexEnd(long indexEnd) { 54 | this.indexEnd = indexEnd; 55 | return this; 56 | } 57 | /**获取 index*/ 58 | public int getIndex() { 59 | return index; 60 | } 61 | /**设置 index*/ 62 | public UploadCommand setIndex(int index) { 63 | this.index = index; 64 | return this; 65 | } 66 | /**获取 completePercent*/ 67 | public float getCompletePercent() { 68 | return completePercent; 69 | } 70 | /**设置 completePercent*/ 71 | public UploadCommand setCompletePercent(float completePercent) { 72 | this.completePercent = completePercent; 73 | return this; 74 | } 75 | public long blobSize() { 76 | return indexEnd-indexStart; 77 | } 78 | public BinaryWebSocketFrame toBinaryWebSocketFrame() { 79 | switch (hd) { 80 | case UPLOAD_COMMAND: 81 | return new BinaryWebSocketFrame(Unpooled.buffer(21) 82 | .writeByte(UPLOAD_COMMAND) 83 | .writeLong(indexStart) 84 | .writeLong(indexEnd) 85 | .writeInt((int)(completePercent*100000000))); 86 | case UPLOAD_COMPLETE: 87 | return new BinaryWebSocketFrame(Unpooled.buffer(1) 88 | .writeByte(UPLOAD_COMPLETE)); 89 | default: 90 | return null; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.fileup.util; 2 | 3 | import java.util.Arrays; 4 | 5 | public class StringUtil { 6 | 7 | public static long strtol(String str,int base){ 8 | return strtol((str+"\0").toCharArray(),base); 9 | } 10 | public static long strtoul(String str,int base){ 11 | return strtoul((str+"\0").toCharArray(),base); 12 | } 13 | 14 | //##################################################################################### 15 | //# 16 | //## 17 | //### 一下所有为私有方法 18 | //## 19 | //# 20 | //##################################################################################### 21 | 22 | /** 23 | * 描述:此方法只返回非负数 24 | * 作者:Chenxj 25 | * 日期:2016年7月20日 - 下午10:35:28 26 | * @param cp 27 | * @param base 28 | * @return 29 | */ 30 | private static long strtoul(char[] cp,int base){ 31 | long result=0,value; 32 | int i=0; 33 | if(base==0){ 34 | base=10; 35 | if(cp[i]=='0'){ 36 | base=8; 37 | i++; 38 | if(Character.toLowerCase(cp[i])=='x'&&isxdigit(cp[1])){ 39 | i++; 40 | base=16; 41 | } 42 | } 43 | }else if(base==16){ 44 | if(cp[0]=='0'&&Character.toLowerCase(cp[1])=='x') 45 | i+=2; 46 | } 47 | while(isxdigit(cp[i])&&(value = isdigit(cp[i]) ? cp[i]-'0' : Character.toLowerCase(cp[i])-'a'+10) < base){ 48 | result=result*base+value; 49 | i++; 50 | } 51 | return result; 52 | } 53 | /** 54 | * 描述:此会返回有符号数 55 | * 作者:Chenxj 56 | * 日期:2016年7月20日 - 下午10:36:08 57 | * @param cp 58 | * @param base 59 | * @return 60 | */ 61 | private static long strtol(char[]cp,int base){ 62 | if(cp[0]=='-'){ 63 | return -strtoul(subChars(cp, 1),base); 64 | } 65 | return strtoul(cp, base); 66 | } 67 | /** 68 | * 判断char是否是16进制以内的数 69 | * @param c 70 | * @return 71 | */ 72 | private static boolean isxdigit(char c){ 73 | return ('0' <= c && c <= '9')||('a' <= c && c <= 'f')||('A' <= c && c <= 'F'); 74 | } 75 | /** 76 | * 判断char是否是10进制的数 77 | * @param c 78 | * @return 79 | */ 80 | private static boolean isdigit(char c){ 81 | return '0' <= c && c <= '9'; 82 | } 83 | /** 84 | * 描述:char数组切分 85 | * 作者:Chenxj 86 | * 日期:2016年7月20日 - 下午10:37:59 87 | * @param cp 88 | * @param indexs 89 | * @return 90 | */ 91 | private static char[] subChars(char[]cp,int...indexs){ 92 | if(indexs.length==1){ 93 | return Arrays.copyOfRange(cp, indexs[0], cp.length); 94 | }else if(indexs.length>1){ 95 | return Arrays.copyOfRange(cp, indexs[0], indexs[0]+indexs[1]); 96 | } 97 | return cp; 98 | } 99 | public static void main(String[] args) { 100 | String md5="b1c5553067e312ff7f9fe0c456d1752b"; 101 | System.out.println(strtol(md5.substring(0, 3),16)/4); 102 | System.out.println(strtol(md5.substring(3, 3+3),16)/4); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 21 | 22 | 23 | 24 | 25 |
    26 | 43 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/CCDataView.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /**© 2015-2017 Chenxj Copyright 6 | * 类 名:CCDataView 7 | * 类 描 述: 8 | * 作 者:chenxj 9 | * 邮 箱:chenios@foxmail.com 10 | * 日 期:2017年9月15日-下午1:37:52 11 | */ 12 | public class CCDataView { 13 | private byte[] buffer; 14 | private int pos; 15 | private int lim; 16 | public CCDataView(ByteBuffer buffer){ 17 | this.buffer=new byte[buffer.limit()]; 18 | buffer.get(this.buffer); 19 | this.pos=0; 20 | this.lim=buffer.limit(); 21 | } 22 | public CCDataView(byte[] buffer){ 23 | this.buffer=buffer; 24 | this.pos=0; 25 | this.lim=buffer.length; 26 | } 27 | public int position(){ 28 | return this.pos; 29 | } 30 | public void position(int position){ 31 | this.pos=position; 32 | } 33 | public int limit(){ 34 | return this.lim; 35 | } 36 | public void limit(int limit){ 37 | this.lim=limit; 38 | } 39 | public boolean isArrayMatchAt(int p,byte[]a){ 40 | boolean ismatch=true; 41 | for(int i=0;i=this.pos;i--){ 80 | mr=this.matchsAt(i, as); 81 | if((boolean)mr[0]){ 82 | return index-((byte[])mr[1]).length; 83 | }else{ 84 | index++; 85 | } 86 | } 87 | } 88 | return index; 89 | } 90 | public int arrayMatch(byte[][]as){ 91 | return arrayMatch(as, false); 92 | } 93 | public byte[] getArray(Object l,boolean d){ 94 | byte[]a=null; 95 | int al; 96 | if(!d){//正序 97 | if(l instanceof byte[][]){ 98 | al=this.arrayMatch((byte[][])l); 99 | }else if(l==null){ 100 | al=this.lim-this.pos; 101 | }else{ 102 | al=(int)l; 103 | } 104 | a=new byte[al]; 105 | System.arraycopy(this.buffer, this.pos, a, 0, al); 106 | this.pos+=al; 107 | }else{//逆序 108 | if(l instanceof byte[][]){ 109 | al=this.arrayMatch((byte[][])l,d); 110 | }else if(l==null){ 111 | al=this.lim-this.pos; 112 | }else{ 113 | al=(int)l; 114 | } 115 | a=new byte[al]; 116 | System.arraycopy(this.buffer, this.lim-al, a, 0, al); 117 | this.lim-=al; 118 | } 119 | return a; 120 | } 121 | public byte[] getArray(Object l){ 122 | return getArray(l,false); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /public/js/crypto-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.5.1 3 | * http://code.google.com/p/crypto-js/ 4 | * (c) 2009-2011 by Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | /*global Crypto, self*/ 8 | (typeof Crypto == "undefined" || !Crypto.util) && function () { 9 | var e = self.Crypto = {}, g = e.util = { 10 | rotl: function (a, b) { 11 | return a << b | a >>> 32 - b 12 | }, rotr: function (a, b) { 13 | return a << 32 - b | a >>> b 14 | }, endian: function (a) { 15 | if (a.constructor == Number) return g.rotl(a, 8) & 16711935 | g.rotl(a, 24) & 4278255360; 16 | for (var b = 0; b < a.length; b++) a[b] = g.endian(a[b]); 17 | return a 18 | }, randomBytes: function (a) { 19 | for (var b = []; a > 0; a--) b.push(Math.floor(Math.random() * 256)); 20 | return b 21 | }, bytesToWords: function (a) { 22 | for (var b = [], c = 0, d = 0; c < a.length; c++, d += 8) b[d >>> 5] |= a[c] << 24 - 23 | d % 32; 24 | return b 25 | }, wordsToBytes: function (a) { 26 | for (var b = [], c = 0; c < a.length * 32; c += 8) b.push(a[c >>> 5] >>> 24 - c % 32 & 255); 27 | return b 28 | }, bytesToHex: function (a) { 29 | for (var b = [], c = 0; c < a.length; c++) b.push((a[c] >>> 4).toString(16)), b.push((a[c] & 15).toString(16)); 30 | return b.join("") 31 | }, hexToBytes: function (a) { 32 | for (var b = [], c = 0; c < a.length; c += 2) b.push(parseInt(a.substr(c, 2), 16)); 33 | return b 34 | }, bytesToBase64: function (a) { 35 | if (typeof btoa == "function") return btoa(f.bytesToString(a)); 36 | for (var b = [], c = 0; c < a.length; c += 3) for (var d = a[c] << 16 | a[c + 1] << 8 | 37 | a[c + 2], e = 0; e < 4; e++) c * 8 + e * 6 <= a.length * 8 ? b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >>> 6 * (3 - e) & 63)) : b.push("="); 38 | return b.join("") 39 | }, base64ToBytes: function (a) { 40 | if (typeof atob == "function") return f.stringToBytes(atob(a)); 41 | for (var a = a.replace(/[^A-Z0-9+\/]/ig, ""), b = [], c = 0, d = 0; c < a.length; d = ++c % 4) d != 0 && b.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c - 1)) & Math.pow(2, -2 * d + 8) - 1) << d * 2 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c)) >>> 42 | 6 - d * 2); 43 | return b 44 | } 45 | }, e = e.charenc = {}; 46 | e.UTF8 = { 47 | stringToBytes: function (a) { 48 | return f.stringToBytes(unescape(encodeURIComponent(a))) 49 | }, bytesToString: function (a) { 50 | return decodeURIComponent(escape(f.bytesToString(a))) 51 | } 52 | }; 53 | var f = e.Binary = { 54 | stringToBytes: function (a) { 55 | for (var b = [], c = 0; c < a.length; c++) b.push(a.charCodeAt(c) & 255); 56 | return b 57 | }, bytesToString: function (a) { 58 | for (var b = [], c = 0; c < a.length; c++) b.push(String.fromCharCode(a[c])); 59 | return b.join("") 60 | } 61 | } 62 | }(); 63 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/netty/BinaryWebSocketFrameHandler.java: -------------------------------------------------------------------------------- 1 | package com.fileup.netty; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.fileup.bean.CommandType; 10 | import com.fileup.bean.FileTarget; 11 | import com.fileup.bean.UploadCommand; 12 | import com.fileup.util.BtxUtil; 13 | import com.fileup.util.BytesUtil; 14 | 15 | import io.netty.buffer.ByteBuf; 16 | import io.netty.channel.ChannelHandlerContext; 17 | import io.netty.channel.SimpleChannelInboundHandler; 18 | import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; 19 | 20 | 21 | public class BinaryWebSocketFrameHandler extends SimpleChannelInboundHandler 22 | implements CommandType{ 23 | private static final Mapftm=new ConcurrentHashMap<>(); 24 | private Logger log=LoggerFactory.getLogger(getClass()); 25 | private UploadCommand command=new UploadCommand(); 26 | private String sid; 27 | @Override 28 | protected void channelRead0(ChannelHandlerContext ctx, BinaryWebSocketFrame msg) throws Exception { 29 | FileTarget ft=null; 30 | ByteBuf buf=msg.content(); 31 | switch (buf.getByte(0)) { 32 | case UPLOAD_FILE: 33 | //有未完成的command需要先cancel 34 | this.cancelCommand(); 35 | Mapm=BtxUtil.btx().convertToMap(buf.nioBuffer()); 36 | if(FileTarget.fileExist((String)m.get("id"),(String)m.get("suffix"))) { 37 | ctx.channel().writeAndFlush(FileTarget 38 | .commandSuccess() 39 | .toBinaryWebSocketFrame()); 40 | break; 41 | } 42 | ft=ftm.get(m.get("id")); 43 | if(ft==null) { 44 | ft=new FileTarget(m); 45 | ftm.put(ft.getId(), ft); 46 | } 47 | ft.addUploadServer(sid); 48 | ft.nextUploadCommand(this.command); 49 | ctx.channel().writeAndFlush(command.toBinaryWebSocketFrame()); 50 | break; 51 | case UPLOAD_DATA: 52 | ft=ftm.get(command.getId()); 53 | if(ft!=null) { 54 | buf.readByte();//跳过第一个字节 55 | ft.commandComplete(command,buf); 56 | ft.nextUploadCommand(this.command); 57 | ctx.channel().writeAndFlush(command.toBinaryWebSocketFrame()); 58 | } 59 | break; 60 | default: 61 | break; 62 | } 63 | } 64 | @Override 65 | public void handlerAdded(ChannelHandlerContext ctx) throws Exception { 66 | this.sid=BytesUtil.bytesToCCString(BytesUtil 67 | .hexStringToBytes(ctx.channel() 68 | .id().asLongText() 69 | .replaceAll("-", ""))); 70 | log.debug("handlerAdded sId:\t{}",sid); 71 | } 72 | 73 | @Override 74 | public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { 75 | log.debug("handlerRemoved sid:\t{}",sid); 76 | cancelCommand(); 77 | } 78 | 79 | @Override 80 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 81 | cancelCommand(); 82 | log.debug( "",cause); 83 | ctx.close(); 84 | } 85 | private void cancelCommand() { 86 | if(null==command.getId()) { 87 | return; 88 | } 89 | FileTarget ft=ftm.get(command.getId()); 90 | if(ft!=null) { 91 | if(UPLOAD_COMPLETE==command.getHd()) { 92 | ftm.remove(command.getId()); 93 | }else { 94 | ft.cancelCommand(command); 95 | ft.removeUploadServer(sid); 96 | if(ft.isUploadServerEmpty()) { 97 | //如果没有其他的上传客户端则需要移除并保存状态且释放占用资源 98 | ftm.remove(command.getId()) 99 | .saveStatus() 100 | .releaseResource(); 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/function/BitConvertLib.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.function; 2 | 3 | import java.nio.charset.Charset; 4 | 5 | public interface BitConvertLib { 6 | public static final Charset utf8=Charset.forName("UTF-8"); 7 | public static final Charset utf16=Charset.forName("UTF-16"); 8 | public static final Charset utf32=Charset.forName("UTF-32"); 9 | 10 | //to byte[] 11 | 12 | //Big-endian 13 | public static byte[] integer2bytes(Object o,int length){ 14 | byte[]bs=new byte[length]; 15 | for(int i=length-1,j=0;i>-1;i--,j++) { 16 | bs[i]|=((int)o)>>(j<<3); 17 | } 18 | return bs; 19 | } 20 | //Little-endian 21 | public static byte[] integer2bytes2(Object o,int length){ 22 | byte[]bs=new byte[length]; 23 | for (int i = 0; i < bs.length; i++) { 24 | bs[i]|=(byte)(((int)o)>>(i<<3)); 25 | } 26 | return bs; 27 | } 28 | public static byte[] unsignedInteger2bytes(Object o,int length){ 29 | return long2bytes(o, length); 30 | } 31 | public static byte[] double2bytes(Object o,int length){ 32 | return long2bytes(Double.doubleToRawLongBits((double)o), length); 33 | } 34 | //Big-endian 35 | public static byte[] long2bytes(Object o,int length){ 36 | byte[]bs=new byte[length]; 37 | for(int i=length-1,j=0;i>-1;i--,j++) { 38 | bs[i]|=((long)o)>>(j<<3); 39 | } 40 | return bs; 41 | } 42 | //Little-endian 43 | public static byte[] long2bytes2(Object o,int length){ 44 | byte[]bs=new byte[length]; 45 | for (int i = 0; i < bs.length; i++) { 46 | bs[i]|=(byte)(((long)o)>>(i<<3)); 47 | } 48 | return bs; 49 | } 50 | public static byte[] float2bytes(Object o,int length){ 51 | return integer2bytes(Float.floatToRawIntBits((float)o), length); 52 | } 53 | 54 | public static byte[] utf82bytes(Object o){ 55 | return ((String)o).getBytes(utf8); 56 | } 57 | public static byte[] utf162bytes(Object o){ 58 | return ((String)o).getBytes(utf16); 59 | } 60 | public static byte[] utf322bytes(Object o){ 61 | return ((String)o).getBytes(utf32); 62 | } 63 | 64 | //from byte[] 65 | 66 | //Big-endian 67 | public static Object bytes2integer(byte[]bytes){ 68 | int value=0; 69 | for(int i=0,j=bytes.length-1;i -1; i--) { 78 | value|=(bytes[i]&0xff)<<(i<<3); 79 | } 80 | return value; 81 | } 82 | public static Object bytes2unsignedInteger(byte[]bytes){ 83 | return bytes2long(bytes); 84 | } 85 | public static Object bytes2double(byte[]bytes){ 86 | return Double.longBitsToDouble((long)bytes2long(bytes)); 87 | } 88 | //Big-endian 89 | public static Object bytes2long(byte[]bytes){ 90 | long value=0; 91 | for(int i=0,j=bytes.length-1;i -1; i--) { 100 | value|=(long)(bytes[i]&0xff)<<(i<<3); 101 | } 102 | return value; 103 | } 104 | public static Object bytes2float(byte[]bytes){ 105 | return Float.intBitsToFloat((int)bytes2integer(bytes)); 106 | } 107 | 108 | 109 | public static Object bytes2utf8(byte[]bytes){ 110 | return new String(bytes, utf8); 111 | } 112 | public static Object bytes2utf16(byte[]bytes){ 113 | return new String(bytes, utf16); 114 | } 115 | public static Object bytes2utf32(byte[]bytes){ 116 | return new String(bytes, utf32); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /public/js/hashWorker.min.js: -------------------------------------------------------------------------------- 1 | var K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function utf16to8(str){var out,i,len,c;out="";len=str.length;for(i=0;i=1&&c<=127){out+=str.charAt(i)}else if(c>2047){out+=String.fromCharCode(224|c>>12&15);out+=String.fromCharCode(128|c>>6&63);out+=String.fromCharCode(128|c>>0&63)}else{out+=String.fromCharCode(192|c>>6&31);out+=String.fromCharCode(128|c>>0&63)}}return out}function utf8to16(str){var out,i,len,c;var char2,char3;out="";len=str.length;i=0;while(i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:out+=str.charAt(i-1);break;case 12:case 13:char2=str.charCodeAt(i++);out+=String.fromCharCode((c&31)<<6|char2&63);break;case 14:char2=str.charCodeAt(i++);char3=str.charCodeAt(i++);out+=String.fromCharCode((c&15)<<12|(char2&63)<<6|(char3&63)<<0);break}}return out}var csm2=[];var start=256;(function(csm2){for(var i=start,j=0;i>>4).toString(16)),b.push((a[c]&15).toString(16))}return b.join("")}function bytesToWords(a){for(var b=[],c=0,d=0;c>>5]|=a[c]<<24-d%32}return b}function wordsToBytes(a){for(var b=[],c=0;c>>5]>>>24-c%32&255)}return b}function sha256(m,H){var w=[],a,b,c,d,e,f,g,h,i,j,t1,t2;for(var i=0;i>>7)^(gamma0x<<14|gamma0x>>>18)^gamma0x>>>3,gamma1=(gamma1x<<15|gamma1x>>>17)^(gamma1x<<13|gamma1x>>>19)^gamma1x>>>10;w[j]=gamma0+(w[j-7]>>>0)+gamma1+(w[j-16]>>>0)}var ch=e&f^~e&g,maj=a&b^a&c^b&c,sigma0=(a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22),sigma1=(e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25);t1=(h>>>0)+sigma1+ch+K[j]+(w[j]>>>0);t2=sigma0+maj;h=g;g=f;f=e;e=d+t1>>>0;d=c;c=b;b=a;a=t1+t2>>>0}H[0]=H[0]+a|0;H[1]=H[1]+b|0;H[2]=H[2]+c|0;H[3]=H[3]+d|0;H[4]=H[4]+e|0;H[5]=H[5]+f|0;H[6]=H[6]+g|0;H[7]=H[7]+h|0}return H}self.hash=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];self.hasFirstHash=false;self.addEventListener("message",function(event){var block=event.data.block;var output={block:block};var nBitsTotal,nBitsLeft,nBitsTotalH,nBitsTotalL;var message=bytesToWords(new Uint8Array(event.data.msg));event=null;if(block.end===block.fileSize){nBitsTotal=block.fileSize*8;nBitsLeft=(block.end-block.start)*8;nBitsTotalH=Math.floor(nBitsTotal/4294967296);nBitsTotalL=nBitsTotal&4294967295;message[nBitsLeft>>>5]|=128<<24-nBitsTotal%32;message[(nBitsLeft+64>>>9<<4)+14]=nBitsTotalH;message[(nBitsLeft+64>>>9<<4)+15]=nBitsTotalL;self.hash=sha256(message,self.hash);output.result=bytesToCCString(wordsToBytes(self.hash))}else{if(!self.hasFirstHash&&block.step==3){var copyHash=self.hash.concat();output.firstHash=bytesToCCString(wordsToBytes(copyHash));self.hasFirstHash=true}self.hash=sha256(message,self.hash)}message=null;self.postMessage(output)},false); -------------------------------------------------------------------------------- /public/js/md5Worker.min.js: -------------------------------------------------------------------------------- 1 | eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"1v 1u";j w(r,e){k r<>>l-e}j u(r){v(r.1w==1x)k 1z&w(r,8)|1y&w(r,24);m(h e=0;e>>5]|=r[s]<<24-n%l;k e}j x(r){m(h e=[],s=0;s>>5]>>>24-s%l&M);k e}j c(r,e,s,n,t,a,o){h H=r+(e&s|~e&n)+(t>>>0)+o;k(H<>>l-a)+e}j d(r,e,s,n,t,a,o){h H=r+(e&n|s&~n)+(t>>>0)+o;k(H<>>l-a)+e}j b(r,e,s,n,t,a,o){h H=r+(e^s^n)+(t>>>0)+o;k(H<>>l-a)+e}j g(r,e,s,n,t,a,o){h H=r+(s^(e|~n))+(t>>>0)+o;k(H<>>l-a)+e}j A(r,e){m(h s=e[0],n=e[1],t=e[2],a=e[3],o=0;o>>0,n=n+f>>>0,t=t+F>>>0,a=a+G>>>0}k[s,n,t,a]}h y=[];!j(){m(h r="2j",e=0,s=0;s<16;s++)m(h n=0;n<16;n++,e++)y[e]=r[s]+r[n]}(),i.p=[1Y,-1Z,-25,26],i.z=!1,i.1X("1W",j(r){h e=r.I.C,s={C:e};v(!e.2k){h n,t,a,o,H=u(D(1T 1U(r.I.1V)));v(r=L,e.E===e.J)n=e.J<<3,t=e.E-e.27<<3,a=28.2f(n/2g),o=2h&n,H[t>>>5]|=2i<>>9<<4)]=a,H[14+(t+K>>>9<<4)]=o,i.p=A(H,i.p),s.2e=B(x(u(i.p)));2d{v(!i.z&&3==e.29){h f=i.p.2a();s.2b=B(x(u(f))),i.z=!0}i.p=A(H,i.p)}H=L,i.2c(s)}},!1);',62,156,'|||||||||||HH|FF|GG|||II|var|self|function|return|32|for|||hash|length||||endian|if|rotl|wordsToBytes|csm|hasFirstHash|md5|bytesToHex|block|bytesToWords|end||||data|fileSize|64|null|255|421815835|1444681467|640364487|51403784|530742520|1163531501|187363961|1019803690|1126891415|198630844|76029189|995338651|1735328473|||||||||35309556|1094730640|1530992060|1272893353|155497632|1839030562|2022574463|358537222|722521979|1926607734|681279174|378558|568446438|165796510|606105819|389564586|1044525330|176418897|1473231341|1200080426|680876936|push|strict|use|constructor|Number|4278255360|16711935|45705983|1770035416|643717713|1069501632|373897302|701558691|660478335|38016083|1416354905|1236535329|42063|1958414417|1990404162|1804603682|1502002290|40341101|405537848|30611744|57434055|new|Uint8Array|msg|message|addEventListener|1732584193|271733879||||||1732584194|271733878|start|Math|step|concat|firstHash|postMessage|else|result|floor|4294967296|4294967295|128|0123456789abcdef|stop|1051523|1120210379|1873313359|1700485571|718787259|1309151649|1560198380|343485551|2054922799|1894986606|145523070'.split('|'),0,{})) 2 | -------------------------------------------------------------------------------- /public/js/CCFileUp.min.js: -------------------------------------------------------------------------------- 1 | eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"1Y 1R";!7(){7 e(e,t){b o=c Y;o.Z=7(o){e.A&&e.A.1X({2o:o.2n.u,1v:t})},o.S(e.1i(t.1a,t.x))}7 t(e){b t=1c.2d(e);m(t){m(""!=t.1s.2l()){m(t.U)d t.U;b o=c 1f([t.1s],{J:t.J});d t.U=1j.2r.2j(o),t.U}d t.14}d a+"/2k.2i.2h"}7 o(e){d c 2e(t(e))}7 s(e,t){b o=c Y;o.Z=7(t){b s=l.1C({B:2,T:o.u});e.R.1B(c 1f([c V(s)]))},o.S(e.1i(t.1t,t.1o))}7 r(e,t){b o=c Y;o.Z=7(s){e.2f=n(c V(o.u)),t&&t(e)},o.S(e.1i(0,20))}7 i(e){b t=5;5.X=5.X||e||1j.2g.2m.1g(/#\\!\\/.+/,"").2u(/\\w+:\\/\\/[^\\/]+\\/[^\\/]+\\/|\\w+:\\/\\/[^\\/]+\\//)[0].1g("2v:","1r:").1g("2t:","2s:")+"1r";2q{M.11("2c R 2x [ "+5.X+" ]");b o=c 1D(5.X);d o.28=7(){t.v.K(o),M.11("1q 1U.")},o.1T=7(){M.1W(),M.11("1q 1S."),t.v.p&&(t.v=[]),o.D&&(t.z.K(o.D),N o.D),1P(7(){i.1x(t)},1z)},o}1Q(e){M.11(e)}}1p.1e.1b={1V:f.g(10,0),2b:f.g(10,3),29:f.g(10,6),2a:f.g(10,9),26:f.g(10,12),25:f.g(10,15),1Z:f.g(10,18),22:f.g(10,21),23:f.g(10,24),2y:f.g(10,27)},1p.1e.2Y=7(e){b t,o=e||2;y(b s 2U 5.1b){b r=5.1b[s];m((t=5.k/r)>=1&&t<2X){t=2W(t*f.g(10,o),10)/f.g(10,o)+s;2V}}d t};b n=1d 0;!7(){b e=[];!7(){y(b t="2Z",o=0,s=0;s<16;s++)y(b r=0;r<16;r++,o++)e[o]=t[s]+t[r]}(),n=7(t){y(b o="",s=0;s=t.k&&(i.x=t.k),e(t,i)))}),e(t,{2O:t.k,1a:0,x:s.Q>t.k?t.k:s.Q,C:0})},H:7(){5.j&&5.j.p&&(5.1m(5.j.1k(),o("2M")),5.G++)},1n:7(){y(;5.G<5.19&&5.j&&5.j.p;)5.H()},1A:7(e,t){b o=5;m(e.C=2,e.R=t,t.D=e,t.2w=7(r){m(e.1G)N e.R,N t.D,5.1N&&5.1N(),o.13(t);2L{b i=c Y;i.Z=7(r){b n=l.2K(i.u);1==n.B?(e.P=n.1M/2N,e.q(),s(e,n)):3==n.B&&(N e.R,N t.D,e.P=1,e.q(),e.1K&&e.1K(),o.13(t))},i.S(r.T)}},t.2R==1D.2Q){b r={B:0,F:e.F,k:e.k,W:e.W,J:e.J,O:e.O},i=l.1C(r);t.1B(c 1f([c V(i)]))}},13:7(e){b t=5.z.1k();t?5.1A(t,e):5.v.K(e)},1E:7(){b e=5.v.1k();e&&5.13(e)},2z:7(e){y(b t=5,o=0;o-1?t.j.1H(e,1):1==5.C?5.1F=!0:(e=t.z.1J(5),e>-1?t.z.1H(e,1):2==5.C&&(5.1G=!0))},e[o].L=7(){t.G--,5.1I&&5.1I(),t.z.K(5)},r(e[o],7(e){e.W=e.O.2p(e.O.1L(".")),t.j.K(e)})}},1j.1O=h}();',62,187,'|||||this||function||||var|new|return||Math|pow|||filesToHash|size||if|||length|onProcess||||result|socketPool||end|for|filesToUpload|worker|hd|step|file|firstHash|id|workers|hashNexFile||type|push|onHashComplete|console|delete|name|progress|bufferSize|socket|readAsArrayBuffer|data|bsrc|Uint8Array|suffix|uploadWSurl|FileReader|onload||log||uploadNextFile|src|||terminate||concurent|start|fileSizeFormats|document|void|prototype|Blob|replace|U8|slice|window|shift|cacheable|doHashWork|startHashFiles|indexEnd|File|Socket|ws|innerText|indexStart|AB|block|hashStopped|apply|localStorage|500|uploadFile|send|convertToIntArray|WebSocket|startUploadFile|stopHash|stopUpload|splice|hashComplete|indexOf|uploadComplete|lastIndexOf|completePercent|uploadStopped|CCFileUp|setTimeout|catch|strict|closed|onclose|opened|Byte|clear|postMessage|use|EB|||ZB|YB||PB|TB||onopen|MB|GB|KB|Connecting|getElementById|Worker|head|location|js|min|createObjectURL|md5Worker|trim|href|target|msg|substring|try|URL|wss|https|match|http|onmessage|to|BB|addFiles|fromLib|toLib|524288|remove|CCBitsyntax|querySelector|script|substr|setInterval|addEventListener|convertToObject|else|hashWorker|1e8|fileSize|message|OPEN|readyState|currentScript|Hex|in|break|parseInt|1e3|formatSize|0123456789abcdef|255'.split('|'),0,{})) 2 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/bean/Bitem.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | 7 | /**© 2015-2017 Chenxj Copyright 8 | * 类 名:Bitem 9 | * 类 描 述:Bit item 10 | * 作 者:chenxj 11 | * 邮 箱:chenios@foxmail.com 12 | * 日 期:2017年9月15日-下午3:10:04 13 | */ 14 | public class Bitem extends BaseBean{ 15 | private static final long serialVersionUID = -7844616599653861649L; 16 | private String name; 17 | //长度可以为数字或关联的字段名称 18 | private Object l; 19 | 20 | private BitemType type; 21 | private Listtypes; 22 | private int separatorDataIndex; 23 | private byte[]separatorData; 24 | private boolean named; 25 | 26 | private Bitem[]bitems; 27 | 28 | private byte[][]range; 29 | private Bitem[]rg; 30 | 31 | private Object[]exchange; 32 | 33 | private boolean dispensable; 34 | 35 | //start--------bitmap参数 36 | //bitmap position 37 | private int p; 38 | //bitmap bit item 占用字节长度 39 | private int bsl; 40 | private Boundary start; 41 | private Boundary end; 42 | //end----------bitmap参数 43 | 44 | public Bitem(){ 45 | this.named=true; 46 | this.type=BitemType.NORMAL; 47 | this.types=new ArrayList<>(); 48 | this.rg=new Bitem[0]; 49 | } 50 | 51 | /**获取 name*/ 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | /**设置 name*/ 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | /**获取 l*/ 62 | @SuppressWarnings("unchecked") 63 | public T getL() { 64 | return (T)l; 65 | } 66 | 67 | /**设置 l*/ 68 | public void setL(Object l) { 69 | this.l = l; 70 | } 71 | 72 | /**获取 type*/ 73 | public BitemType getType() { 74 | return type; 75 | } 76 | 77 | /**设置 type*/ 78 | public void setType(BitemType type) { 79 | this.type = type; 80 | } 81 | 82 | /**获取 types*/ 83 | public List getTypes() { 84 | return types; 85 | } 86 | 87 | /**设置 types*/ 88 | public void setTypes(List types) { 89 | this.types = types; 90 | } 91 | 92 | /**获取 separatorDataIndex*/ 93 | public int getSeparatorDataIndex() { 94 | return separatorDataIndex; 95 | } 96 | 97 | /**设置 separatorDataIndex*/ 98 | public void setSeparatorDataIndex(int separatorDataIndex) { 99 | this.separatorDataIndex = separatorDataIndex; 100 | } 101 | 102 | /**获取 separatorData*/ 103 | public byte[] getSeparatorData() { 104 | return separatorData; 105 | } 106 | 107 | /**设置 separatorData*/ 108 | public void setSeparatorData(byte[] separatorData) { 109 | this.separatorData = separatorData; 110 | } 111 | 112 | /**获取 named*/ 113 | public boolean isNamed() { 114 | return named; 115 | } 116 | 117 | /**设置 named*/ 118 | public void setNamed(boolean named) { 119 | this.named = named; 120 | } 121 | 122 | /**获取 bitems*/ 123 | public Bitem[] getBitems() { 124 | return bitems; 125 | } 126 | 127 | /**设置 bitems*/ 128 | public void setBitems(Bitem[] bitems) { 129 | this.bitems = bitems; 130 | } 131 | 132 | /**获取 range*/ 133 | public byte[][] getRange() { 134 | return range; 135 | } 136 | 137 | /**设置 range*/ 138 | public void setRange(byte[][] range) { 139 | this.range = range; 140 | } 141 | 142 | /**获取 rg*/ 143 | public Bitem[] getRg() { 144 | return rg; 145 | } 146 | 147 | /**设置 rg*/ 148 | public void setRg(Bitem[] rg) { 149 | this.rg = rg; 150 | } 151 | 152 | /**获取 exchange*/ 153 | public Object[] getExchange() { 154 | return exchange; 155 | } 156 | 157 | /**设置 exchange*/ 158 | public void setExchange(Object[] exchange) { 159 | this.exchange = exchange; 160 | } 161 | 162 | /**获取 dispensable*/ 163 | public boolean isDispensable() { 164 | return dispensable; 165 | } 166 | 167 | /**设置 dispensable*/ 168 | public void setDispensable(boolean dispensable) { 169 | this.dispensable = dispensable; 170 | } 171 | 172 | /**获取 p*/ 173 | public int getP() { 174 | return p; 175 | } 176 | 177 | /**设置 p*/ 178 | public void setP(int p) { 179 | this.p = p; 180 | } 181 | 182 | /**获取 bsl*/ 183 | public int getBsl() { 184 | return bsl; 185 | } 186 | 187 | /**设置 bsl*/ 188 | public void setBsl(int bsl) { 189 | this.bsl = bsl; 190 | } 191 | 192 | /**获取 start*/ 193 | public Boundary getStart() { 194 | return start; 195 | } 196 | 197 | /**设置 start*/ 198 | public void setStart(Boundary start) { 199 | this.start = start; 200 | } 201 | 202 | /**获取 end*/ 203 | public Boundary getEnd() { 204 | return end; 205 | } 206 | 207 | /**设置 end*/ 208 | public void setEnd(Boundary end) { 209 | this.end = end; 210 | } 211 | 212 | public enum BitemType { 213 | NORMAL, 214 | SEPARATOR, 215 | MIXED, 216 | RANGE, 217 | LIST, 218 | BITMAP, 219 | EXCHANGE, 220 | PLACEHOLDER 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/CCBitmap.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | 7 | import com.fileup.bitsyntax.bean.BaseBean; 8 | import com.fileup.bitsyntax.bean.Bitem; 9 | import com.fileup.bitsyntax.bean.Boundary; 10 | 11 | 12 | /**© 2015-2017 Chenxj Copyright 13 | * 类 名:CCBitmap 14 | * 类 描 述:CCBitmap 15 | * 作 者:chenxj 16 | * 邮 箱:chenios@foxmail.com 17 | * 日 期:2017年9月15日-下午3:04:02 18 | */ 19 | public class CCBitmap extends BaseBean{ 20 | private static final long serialVersionUID = 6915370138320994281L; 21 | private byte[] buffer; 22 | private int l; 23 | private Bitem[]bm; 24 | private Mapim=new LinkedHashMap<>(); 25 | public CCBitmap(Bitem[]bm,byte[]a){ 26 | this.bm=bm; 27 | for(int i=0,p=0;i>3, this.bm[i].getP()%8)); 40 | this.bm[i].setEnd(new Boundary(this.bm[i].getP()+(int)this.bm[i].getL()>>3, 41 | (this.bm[i].getP()+(int)this.bm[i].getL())%8)); 42 | //计算占用buff长度 43 | if(this.bm[i].getEnd().getOffset()!=0){ 44 | this.bm[i].setBsl(this.bm[i].getEnd().getIndex()-this.bm[i].getStart().getIndex()+1); 45 | }else{ 46 | this.bm[i].setBsl(this.bm[i].getEnd().getIndex()-this.bm[i].getStart().getIndex()); 47 | } 48 | } 49 | this.buffer=(a==null?new byte[(int)Math.ceil((double)this.l/8)]:a); 50 | } 51 | public byte[] buffer(){ 52 | return this.buffer; 53 | } 54 | protected byte getByteMash(int n,boolean right){ 55 | if(right){ 56 | return (byte)((1<>lack; 85 | }else{ 86 | bt=(this.buffer[b.getStart().getIndex()]&0xff)>>lack; 87 | } 88 | }else{ 89 | if(b.getEnd().getOffset()!=0){ 90 | bt=(this.buffer[b.getStart().getIndex()]&0xff)>>lack; 91 | } 92 | for(int i=1;i>lave; 97 | } 98 | bt|=(this.buffer[b.getEnd().getIndex()]&this.getByteUnMash(endLave))<>lave; 124 | }else{ 125 | if(lave!=0){ 126 | //先清除原来的值 127 | this.buffer[b.getStart().getIndex()]&=this.getByteUnMash(lave); 128 | this.buffer[b.getStart().getIndex()]|=bt<>lave; 131 | } 132 | for(int i=1;i>lave; 137 | } 138 | this.buffer[b.getEnd().getIndex()]&=this.getByteUnMash(lave, true); 139 | this.buffer[b.getEnd().getIndex()]|=bt; 140 | } 141 | } 142 | public MaptoMap(){ 143 | Mapm=new HashMap<>(); 144 | for(int i=0;i= 0x0001) && (c <= 0x007F)) { 25 | out += str.charAt(i); 26 | } else if (c > 0x07FF) { 27 | out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); 28 | out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); 29 | out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 30 | } else { 31 | out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); 32 | out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 33 | } 34 | } 35 | return out; 36 | }; 37 | 38 | function utf8to16(str) { 39 | var out, i, len, c; 40 | var char2, char3; 41 | out = ""; 42 | len = str.length; 43 | i = 0; 44 | while (i < len) { 45 | c = str.charCodeAt(i++); 46 | switch (c >> 4) { 47 | case 0: 48 | case 1: 49 | case 2: 50 | case 3: 51 | case 4: 52 | case 5: 53 | case 6: 54 | case 7: 55 | // 0xxxxxxx 56 | out += str.charAt(i - 1); 57 | break; 58 | case 12: 59 | case 13: 60 | // 110x xxxx  10xx xxxx 61 | char2 = str.charCodeAt(i++); 62 | out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); 63 | break; 64 | case 14: 65 | // 1110 xxxx 10xx xxxx 10xx xxxx 66 | char2 = str.charCodeAt(i++); 67 | char3 = str.charCodeAt(i++); 68 | out += String.fromCharCode(((c & 0x0F) << 12) | 69 | ((char2 & 0x3F) << 6) | 70 | ((char3 & 0x3F) << 0)); 71 | break; 72 | } 73 | } 74 | return out; 75 | }; 76 | var csm2 = []; 77 | var start = 0x0100; 78 | (function (csm2) { 79 | for (var i = start, j = 0; i < start + 256; i++) { 80 | csm2[j++] = String.fromCharCode(i); 81 | } 82 | })(csm2); 83 | function bytesToCCString(a) { 84 | var s=''; 85 | for(var i=0;i>> 4).toString(16)), b.push((a[c] & 15).toString(16)); 100 | } 101 | return b.join("") 102 | } 103 | function bytesToWords(a) { 104 | for (var b = [], c = 0, d = 0; c < a.length; c++, d += 8) { 105 | b[d >>> 5] |= a[c] << 24 - d % 32; 106 | } 107 | return b 108 | } 109 | 110 | function wordsToBytes(a) { 111 | for (var b = [], c = 0; c < a.length * 32; c += 8) { 112 | b.push(a[c >>> 5] >>> 24 - c % 32 & 255); 113 | } 114 | return b 115 | } 116 | 117 | function sha256(m, H) { 118 | var w = [], a, b, c, d, e, f, g, h, i, j, t1, t2; 119 | for (var i = 0; i < m.length; i += 16) { 120 | a = H[0]; 121 | b = H[1]; 122 | c = H[2]; 123 | d = H[3]; 124 | e = H[4]; 125 | f = H[5]; 126 | g = H[6]; 127 | h = H[7]; 128 | for (var j = 0; j < 64; j++) { 129 | if (j < 16) { 130 | w[j] = m[j + i]; 131 | } else { 132 | var gamma0x = w[j - 15], 133 | gamma1x = w[j - 2], 134 | gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ ((gamma0x << 14) | (gamma0x >>> 18)) ^ (gamma0x >>> 3), 135 | gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ ((gamma1x << 13) | (gamma1x >>> 19)) ^ (gamma1x >>> 10); 136 | 137 | w[j] = gamma0 + (w[j - 7] >>> 0) + gamma1 + (w[j - 16] >>> 0); 138 | } 139 | var ch = e & f ^ ~e & g, 140 | maj = a & b ^ a & c ^ b & c, 141 | sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)), 142 | sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); 143 | 144 | t1 = (h >>> 0) + sigma1 + ch + (K[j]) + (w[j] >>> 0); 145 | t2 = sigma0 + maj; 146 | h = g; 147 | g = f; 148 | f = e; 149 | e = (d + t1) >>> 0; 150 | d = c; 151 | c = b; 152 | b = a; 153 | a = (t1 + t2) >>> 0; 154 | } 155 | // Intermediate hash value 156 | H[0] = (H[0] + a) | 0; 157 | H[1] = (H[1] + b) | 0; 158 | H[2] = (H[2] + c) | 0; 159 | H[3] = (H[3] + d) | 0; 160 | H[4] = (H[4] + e) | 0; 161 | H[5] = (H[5] + f) | 0; 162 | H[6] = (H[6] + g) | 0; 163 | H[7] = (H[7] + h) | 0; 164 | } 165 | return H; 166 | }; 167 | self.hash = [0x6A09E667, 0xBB67AE85, 168 | 0x3C6EF372, 0xA54FF53A, 169 | 0x510E527F, 0x9B05688C, 170 | 0x1F83D9AB, 0x5BE0CD19]; 171 | self.hasFirstHash = false; 172 | self.addEventListener('message', function (event) { 173 | var block = event.data.block; 174 | var output = {'block': block}; 175 | var nBitsTotal, nBitsLeft, nBitsTotalH, nBitsTotalL; 176 | var message = bytesToWords(new Uint8Array(event.data.msg)); 177 | event = null; 178 | if (block.end === block.fileSize) { 179 | nBitsTotal = block.fileSize * 8; 180 | nBitsLeft = (block.end - block.start) * 8; 181 | nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); 182 | nBitsTotalL = nBitsTotal & 0xFFFFFFFF; 183 | message[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsTotal % 32); 184 | message[((nBitsLeft + 64 >>> 9) << 4) + 14] = nBitsTotalH; 185 | message[((nBitsLeft + 64 >>> 9) << 4) + 15] = nBitsTotalL; 186 | self.hash = sha256(message, self.hash); 187 | output.result = bytesToCCString(wordsToBytes(self.hash)); 188 | } else { 189 | if (!self.hasFirstHash && block.step == 3) { 190 | //为不影响后面的计算,这里进行数组浅拷贝,(对于多维数组需要深拷贝) 191 | var copyHash = self.hash.concat(); 192 | output.firstHash = bytesToCCString(wordsToBytes(copyHash)); 193 | self.hasFirstHash = true; 194 | } 195 | self.hash = sha256(message, self.hash); 196 | } 197 | message = null; 198 | self.postMessage(output); 199 | }, false); -------------------------------------------------------------------------------- /public/js/md5Worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Chenxj on 2016/1/12. 3 | */ 4 | 5 | let csm=[]; 6 | (function () { 7 | var cs="0123456789abcdef"; 8 | var n=0; 9 | for(var i=0;i<16;i++){ 10 | for(var j=0;j<16;j++,n++){ 11 | csm[n]=cs[i]+cs[j]; 12 | } 13 | } 14 | })(); 15 | function rotl(a, b) { 16 | return a << b | a >>> 32 - b 17 | } 18 | function endian(a) { 19 | if (a.constructor == Number){ 20 | return rotl(a, 8) & 21 | 16711935 | 22 | rotl(a, 24) & 23 | 4278255360 24 | } 25 | for (var b = 0; b < a.length; b++){ 26 | a[b] = endian(a[b]) 27 | } 28 | return a 29 | } 30 | function bytesToHex(a) { 31 | var s=''; 32 | for(var i=0;i>> 5] |= a[c] << 24 - d % 32; 40 | } 41 | return b 42 | } 43 | function wordsToBytes(a) { 44 | for (var b = [], c = 0; c < a.length * 32; c += 8) { 45 | b.push(a[c >>> 5] >>> 24 - c % 32 & 255); 46 | } 47 | return b 48 | } 49 | function FF(a, b, c, d, x, s, t) { 50 | var n = a + (b & c | ~b & d) + (x >>> 0) + t; 51 | return ((n << s) | (n >>> (32 - s))) + b; 52 | } 53 | function GG(a, b, c, d, x, s, t) { 54 | var n = a + (b & d | c & ~d) + (x >>> 0) + t; 55 | return ((n << s) | (n >>> (32 - s))) + b; 56 | } 57 | function HH(a, b, c, d, x, s, t) { 58 | var n = a + (b ^ c ^ d) + (x >>> 0) + t; 59 | return ((n << s) | (n >>> (32 - s))) + b; 60 | } 61 | function II(a, b, c, d, x, s, t) { 62 | var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; 63 | return ((n << s) | (n >>> (32 - s))) + b; 64 | } 65 | function md5(m, hash) { 66 | var a = hash[0], b = hash[1], c = hash[2], d = hash[3]; 67 | for (var i = 0; i < m.length; i += 16) { 68 | var aa = a, bb = b, cc = c, dd = d; 69 | a = FF(a, b, c, d, m[i + 0], 7, -680876936); 70 | d = FF(d, a, b, c, m[i + 1], 12, -389564586); 71 | c = FF(c, d, a, b, m[i + 2], 17, 606105819); 72 | b = FF(b, c, d, a, m[i + 3], 22, -1044525330); 73 | a = FF(a, b, c, d, m[i + 4], 7, -176418897); 74 | d = FF(d, a, b, c, m[i + 5], 12, 1200080426); 75 | c = FF(c, d, a, b, m[i + 6], 17, -1473231341); 76 | b = FF(b, c, d, a, m[i + 7], 22, -45705983); 77 | a = FF(a, b, c, d, m[i + 8], 7, 1770035416); 78 | d = FF(d, a, b, c, m[i + 9], 12, -1958414417); 79 | c = FF(c, d, a, b, m[i + 10], 17, -42063); 80 | b = FF(b, c, d, a, m[i + 11], 22, -1990404162); 81 | a = FF(a, b, c, d, m[i + 12], 7, 1804603682); 82 | d = FF(d, a, b, c, m[i + 13], 12, -40341101); 83 | c = FF(c, d, a, b, m[i + 14], 17, -1502002290); 84 | b = FF(b, c, d, a, m[i + 15], 22, 1236535329); 85 | a = GG(a, b, c, d, m[i + 1], 5, -165796510); 86 | d = GG(d, a, b, c, m[i + 6], 9, -1069501632); 87 | c = GG(c, d, a, b, m[i + 11], 14, 643717713); 88 | b = GG(b, c, d, a, m[i + 0], 20, -373897302); 89 | a = GG(a, b, c, d, m[i + 5], 5, -701558691); 90 | d = GG(d, a, b, c, m[i + 10], 9, 38016083); 91 | c = GG(c, d, a, b, m[i + 15], 14, -660478335); 92 | b = GG(b, c, d, a, m[i + 4], 20, -405537848); 93 | a = GG(a, b, c, d, m[i + 9], 5, 568446438); 94 | d = GG(d, a, b, c, m[i + 14], 9, -1019803690); 95 | c = GG(c, d, a, b, m[i + 3], 14, -187363961); 96 | b = GG(b, c, d, a, m[i + 8], 20, 1163531501); 97 | a = GG(a, b, c, d, m[i + 13], 5, -1444681467); 98 | d = GG(d, a, b, c, m[i + 2], 9, -51403784); 99 | c = GG(c, d, a, b, m[i + 7], 14, 1735328473); 100 | b = GG(b, c, d, a, m[i + 12], 20, -1926607734); 101 | a = HH(a, b, c, d, m[i + 5], 4, -378558); 102 | d = HH(d, a, b, c, m[i + 8], 11, -2022574463); 103 | c = HH(c, d, a, b, m[i + 11], 16, 1839030562); 104 | b = HH(b, c, d, a, m[i + 14], 23, -35309556); 105 | a = HH(a, b, c, d, m[i + 1], 4, -1530992060); 106 | d = HH(d, a, b, c, m[i + 4], 11, 1272893353); 107 | c = HH(c, d, a, b, m[i + 7], 16, -155497632); 108 | b = HH(b, c, d, a, m[i + 10], 23, -1094730640); 109 | a = HH(a, b, c, d, m[i + 13], 4, 681279174); 110 | d = HH(d, a, b, c, m[i + 0], 11, -358537222); 111 | c = HH(c, d, a, b, m[i + 3], 16, -722521979); 112 | b = HH(b, c, d, a, m[i + 6], 23, 76029189); 113 | a = HH(a, b, c, d, m[i + 9], 4, -640364487); 114 | d = HH(d, a, b, c, m[i + 12], 11, -421815835); 115 | c = HH(c, d, a, b, m[i + 15], 16, 530742520); 116 | b = HH(b, c, d, a, m[i + 2], 23, -995338651); 117 | a = II(a, b, c, d, m[i + 0], 6, -198630844); 118 | d = II(d, a, b, c, m[i + 7], 10, 1126891415); 119 | c = II(c, d, a, b, m[i + 14], 15, -1416354905); 120 | b = II(b, c, d, a, m[i + 5], 21, -57434055); 121 | a = II(a, b, c, d, m[i + 12], 6, 1700485571); 122 | d = II(d, a, b, c, m[i + 3], 10, -1894986606); 123 | c = II(c, d, a, b, m[i + 10], 15, -1051523); 124 | b = II(b, c, d, a, m[i + 1], 21, -2054922799); 125 | a = II(a, b, c, d, m[i + 8], 6, 1873313359); 126 | d = II(d, a, b, c, m[i + 15], 10, -30611744); 127 | c = II(c, d, a, b, m[i + 6], 15, -1560198380); 128 | b = II(b, c, d, a, m[i + 13], 21, 1309151649); 129 | a = II(a, b, c, d, m[i + 4], 6, -145523070); 130 | d = II(d, a, b, c, m[i + 11], 10, -1120210379); 131 | c = II(c, d, a, b, m[i + 2], 15, 718787259); 132 | b = II(b, c, d, a, m[i + 9], 21, -343485551); 133 | a = (a + aa) >>> 0; 134 | b = (b + bb) >>> 0; 135 | c = (c + cc) >>> 0; 136 | d = (d + dd) >>> 0; 137 | } 138 | return [a, b, c, d]; 139 | } 140 | self.hash = [1732584193, -271733879, -1732584194, 271733878]; 141 | self.hasFirstHash=false; 142 | self.addEventListener('message', function (event) { 143 | var block = event.data.block; 144 | var output = {'block' : block}; 145 | if(!block.stop){ 146 | var nBitsTotal, nBitsLeft, nBitsTotalH, nBitsTotalL; 147 | var message = endian(bytesToWords(new Uint8Array(event.data.msg))); 148 | event = null; 149 | if (block.end === block.fileSize) { 150 | //MD5 151 | nBitsTotal = block.fileSize << 3; 152 | nBitsLeft = (block.end - block.start) << 3; 153 | nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); 154 | nBitsTotalL = nBitsTotal & 0xFFFFFFFF; 155 | message[nBitsLeft >>> 5] |= 0x80 << (nBitsLeft % 32); 156 | message[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotalH; 157 | message[(((nBitsLeft + 64) >>> 9) << 4) + 14] = nBitsTotalL; 158 | self.hash = md5(message, self.hash); 159 | output.result = bytesToHex(wordsToBytes(endian(self.hash))); 160 | } else { 161 | if(!self.hasFirstHash&&block.step==3){ 162 | //为不影响后面的计算,这里进行数组浅拷贝,(对于多维数组需要深拷贝) 163 | var copyHash=self.hash.concat(); 164 | output.firstHash=bytesToHex(wordsToBytes(endian(copyHash))); 165 | self.hasFirstHash=true; 166 | } 167 | self.hash = md5(message, self.hash); 168 | } 169 | message = null; 170 | self.postMessage(output); 171 | } 172 | }, false); 173 | -------------------------------------------------------------------------------- /src/main/java/com/fileup/bean/FileTarget.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bean; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.RandomAccessFile; 6 | import java.math.BigDecimal; 7 | import java.nio.ByteBuffer; 8 | import java.nio.channels.FileChannel; 9 | import java.util.Map; 10 | import java.util.Queue; 11 | import java.util.concurrent.ConcurrentLinkedQueue; 12 | 13 | import com.fileup.Config; 14 | import com.fileup.util.Paths; 15 | import com.fileup.util.RocksDbUtil; 16 | import com.fileup.util.StringUtil; 17 | 18 | import io.netty.buffer.ByteBuf; 19 | 20 | /** 21 | * © 2015-2019 Chenxj Copyright 22 | * 类 名:FileTarget 23 | * 类 描 述:文件处理类,有并发需要注意 24 | * 作 者:chenxj 25 | * 邮 箱:chenios@foxmail.com 26 | * 日 期:2019年1月19日-下午12:31:44 27 | */ 28 | public class FileTarget implements CommandType{ 29 | private String id; 30 | private String name; 31 | private String suffix; 32 | private String type; 33 | private long size; 34 | private BSet bSet; 35 | //bSet开始检查位置 36 | private int iStart=0; 37 | private long completeFileSize=0; 38 | private float completePercent=0; 39 | private QueueuploadServers=new ConcurrentLinkedQueue<>(); 40 | 41 | private RandomAccessFile raf; 42 | private FileChannel fc; 43 | private File tmpFile; 44 | public FileTarget(MapfileInfo) { 45 | this.id=(String) fileInfo.get("id"); 46 | this.name=(String) fileInfo.get("name"); 47 | this.suffix=(String) fileInfo.get("suffix"); 48 | this.type=(String) fileInfo.get("type"); 49 | this.size=new BigDecimal( fileInfo.get("size").toString()).longValue(); 50 | 51 | byte[]bs=RocksDbUtil.get(id); 52 | if(null!=bs) { 53 | this.bSet=new BSet(bs); 54 | //查找iStart位置 55 | for(int i=0;i0) { 77 | bSetSize++; 78 | } 79 | this.bSet=new BSet(bSetSize); 80 | } 81 | try { 82 | this.tmpFile=fileWithEnd(this.id, this.suffix, ".tmp"); 83 | if(!tmpFile.getParentFile().exists()) { 84 | tmpFile.getParentFile().mkdirs(); 85 | } 86 | this.raf=new RandomAccessFile(this.tmpFile, "rw"); 87 | this.fc=raf.getChannel(); 88 | } catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | public static boolean fileExist(String id,String suffix) { 93 | return fileWithEnd(id, suffix, "").exists(); 94 | } 95 | public static String getFilePath(String id) { 96 | long v1=StringUtil.strtol(id.substring(0, 3), 16); 97 | long v2=StringUtil.strtol(id.substring(3, 6), 16); 98 | return "/"+v1/4+"/"+v2/4+"/"+id+"/"; 99 | } 100 | public static UploadCommand commandSuccess() { 101 | return new UploadCommand().setHd(UPLOAD_COMPLETE); 102 | } 103 | private FileTarget addCompleteFileSize(long sz) { 104 | this.completeFileSize+=sz; 105 | this.completePercent=this.size>0?(float)completeFileSize/this.size:1; 106 | return this; 107 | } 108 | public boolean isUploadServerEmpty() { 109 | return this.uploadServers.isEmpty(); 110 | } 111 | public FileTarget addUploadServer(String sId) { 112 | this.uploadServers.add(sId); 113 | return this; 114 | } 115 | public FileTarget removeUploadServer(String sId) { 116 | this.uploadServers.remove(sId); 117 | return this; 118 | } 119 | public FileTarget commandComplete(UploadCommand command,byte[]data) { 120 | return commandComplete(command, ByteBuffer.wrap(data)); 121 | } 122 | public FileTarget commandComplete(UploadCommand command,ByteBuf data) { 123 | return commandComplete(command, data.nioBuffer()); 124 | } 125 | public FileTarget commandComplete(UploadCommand command,ByteBuffer data) { 126 | try { 127 | this.fc.write(data,command.getIndexStart()); 128 | addCompleteFileSize(command.blobSize()); 129 | this.bSet.setBit(command.getIndex()); 130 | } catch (Exception e) { 131 | e.printStackTrace(); 132 | }finally { 133 | if(this.completeFileSize==this.size) { 134 | this.uploadServers.clear(); 135 | RocksDbUtil.delete(id); 136 | this.releaseResource(); 137 | if(this.tmpFile.exists()) { 138 | String p=this.tmpFile.getAbsolutePath(); 139 | this.tmpFile.renameTo(new File(p.substring(0, p.length()-4))); 140 | } 141 | } 142 | } 143 | return this; 144 | } 145 | public FileTarget nextUploadCommand(UploadCommand command) { 146 | for(int i=iStart;isize 151 | ?size 152 | :(indexStart+Config.blobSize); 153 | command 154 | .setHd(UPLOAD_COMMAND) 155 | .setId(id) 156 | .setIndex(i) 157 | .setIndexStart(indexStart) 158 | .setIndexEnd(indexEnd) 159 | .setCompletePercent(completePercent); 160 | return this; 161 | } 162 | } 163 | //ID 不能为空,handler需要用来清除FileTarget 164 | command.setHd(UPLOAD_COMPLETE).setId(id); 165 | return this; 166 | } 167 | public FileTarget cancelCommand(UploadCommand command) { 168 | this.bSet.unsetBit(command.getIndex()); 169 | if(command.getIndex()>((i&1)<<2);break; 61 | case '2':bytes[j]|=0x20>>((i&1)<<2);break; 62 | case '3':bytes[j]|=0x30>>((i&1)<<2);break; 63 | case '4':bytes[j]|=0x40>>((i&1)<<2);break; 64 | case '5':bytes[j]|=0x50>>((i&1)<<2);break; 65 | case '6':bytes[j]|=0x60>>((i&1)<<2);break; 66 | case '7':bytes[j]|=0x70>>((i&1)<<2);break; 67 | case '8':bytes[j]|=0x80>>((i&1)<<2);break; 68 | case '9':bytes[j]|=0x90>>((i&1)<<2);break; 69 | case 'a':case 'A':bytes[j]|=0xA0>>((i&1)<<2);break; 70 | case 'b':case 'B':bytes[j]|=0xB0>>((i&1)<<2);break; 71 | case 'c':case 'C':bytes[j]|=0xC0>>((i&1)<<2);break; 72 | case 'd':case 'D':bytes[j]|=0xD0>>((i&1)<<2);break; 73 | case 'e':case 'E':bytes[j]|=0xE0>>((i&1)<<2);break; 74 | case 'f':case 'F':bytes[j]|=0xF0>>((i&1)<<2);break; 75 | default:break; 76 | } 77 | j+=i&1; 78 | } 79 | return bytes; 80 | } 81 | /** 82 | * 描述:字节数组转整形 83 | * 作者:Chenxj 84 | * 日期:2016年6月6日 - 下午10:26:02 85 | * @param bytes 字节数组 86 | * @param endianness 字节序( 1:Big Endian,-1:Little Endian) 87 | * @return 88 | */ 89 | public static int readBytesToInt(byte[]bytes,int endianness){ 90 | int a=0; 91 | int length=bytes.length; 92 | if(endianness==1){ 93 | for(int i=length-1;i>-1;i--){ 94 | a|=(bytes[i]&0xFF)<<(i*8); 95 | } 96 | }else if(endianness==-1){ 97 | for(int i=0;i-1;i--){ 116 | b[i]= (byte) (a>>(8*i)&0xFF); 117 | } 118 | }else if(endianness==-1){ 119 | for(int i=0;i>(8*(length-1-i))&0xFF); 121 | } 122 | } 123 | return b; 124 | } 125 | /** 126 | * 描述:字节数组转长整形 127 | * 作者:Chenxj 128 | * 日期:2016年6月6日 - 下午10:31:49 129 | * @param bytes 130 | * @param endianness 字节序( 1:Big Endian,-1:Little Endian) 131 | * @return 132 | */ 133 | public static long readBytesToLong(byte[]bytes,int endianness){ 134 | long a=0; 135 | int length=bytes.length; 136 | if(endianness==1){ 137 | for(int i=length-1;i>-1;i--){ 138 | a|=((long)bytes[i]&0xFF)<<(i*8); 139 | } 140 | }else if(endianness==-1){ 141 | for(int i=0;i-1;i--){ 160 | b[i]= (byte) (a>>(8*i)&0xFF); 161 | } 162 | }else if(endianness==-1){ 163 | for(int i=0;i>((length-1-i)*8)&0xFF); 165 | } 166 | } 167 | return b; 168 | } 169 | /** 170 | * 描述:字节数组转双精度类型 171 | * 作者:Chenxj 172 | * 日期:2016年6月6日 - 下午10:40:16 173 | * @param bytes 字节数组 174 | * @param endianness 字节序( 1:Big Endian,-1:Little Endian) 175 | * @return 176 | */ 177 | public static double readBytesToDouble(byte[]bytes,int endianness){ 178 | return Double.longBitsToDouble(readBytesToLong(bytes,endianness)); 179 | } 180 | /** 181 | * 描述:双精度类型转字节数组 182 | * 作者:Chenxj 183 | * 日期:2016年6月6日 - 下午10:42:16 184 | * @param a 双精度类型 185 | * @param length 字节数组长度 186 | * @param endianness 字节序( 1:Big Endian,-1:Little Endian) 187 | * @return 188 | */ 189 | public static byte[] doubleToBytes(double a,int length,int endianness){ 190 | return longToBytes(Double.doubleToLongBits(a), length,endianness); 191 | } 192 | /** 193 | * 描述:字节数组转Float 194 | * 作者:Chenxj 195 | * 日期:2016年6月25日 - 下午12:30:53 196 | * @param bytes 197 | * @param endianness 字节序( 1:Big Endian,-1:Little Endian) 198 | * @return 199 | */ 200 | public static float readBytesToFloat(byte[]bytes,int endianness){ 201 | int a=0; 202 | int length=bytes.length; 203 | if(endianness==1){ 204 | for(int i=length-1;i>-1;i--){ 205 | a|=((long)bytes[i]&0xFF)<<(i*8); 206 | } 207 | }else if(endianness==-1){ 208 | for(int i=0;iE readBytesAsObject(byte[]buf){ 254 | if(buf!=null){ 255 | return readBytesAsObject(buf, 0, buf.length); 256 | } 257 | return null; 258 | } 259 | 260 | @SuppressWarnings("unchecked") 261 | public final static E readBytesAsObject(byte buf[], int offset, int length){ 262 | ByteArrayInputStream byteInStream=new ByteArrayInputStream(buf, offset, length); 263 | ObjectInputStream ois=null; 264 | try{ 265 | ois=new ObjectInputStream(byteInStream); 266 | return (E) ois.readObject(); 267 | }catch (Exception e) { 268 | e.printStackTrace(); 269 | } 270 | return null; 271 | } 272 | 273 | 274 | public final static byte[]writeValueAsBytesWithCompress(Object obj){ 275 | ByteArrayOutputStream bos=new ByteArrayOutputStream(); 276 | ObjectOutputStream oos=null; 277 | try{ 278 | oos=new ObjectOutputStream(bos); 279 | oos.writeObject(obj); 280 | oos.flush(); 281 | return Snappy.compress(bos.toByteArray()); 282 | // return bos.toByteArray(); 283 | }catch (Exception e) { 284 | e.printStackTrace(); 285 | } 286 | return new byte[0]; 287 | } 288 | public final static void writeValueAsBytesWithCompress(Object obj,byte[] b, int off,int len){ 289 | ByteArrayOutputStream bos=new ByteArrayOutputStream(); 290 | ObjectOutputStream oos=null; 291 | try{ 292 | oos=new ObjectOutputStream(bos); 293 | oos.writeObject(obj); 294 | oos.flush(); 295 | System.arraycopy(Snappy.compress(bos.toByteArray()), 0, b, off, len); 296 | }catch (Exception e) { 297 | e.printStackTrace(); 298 | } 299 | } 300 | public final static E readBytesAsObjectWithCompress(byte[]buf){ 301 | if(buf!=null){ 302 | return readBytesAsObjectWithCompress(buf, 0, buf.length); 303 | } 304 | return null; 305 | } 306 | @SuppressWarnings("unchecked") 307 | public final static E readBytesAsObjectWithCompress(byte buf[], int offset, int length){ 308 | ByteArrayInputStream byteInStream=null; 309 | ObjectInputStream ois=null; 310 | try{ 311 | byte[] result = new byte[Snappy.uncompressedLength(buf,offset,length)]; 312 | Snappy.uncompress(buf, offset, length, result, 0); 313 | byteInStream=new ByteArrayInputStream(result); 314 | // byteInStream=new ByteArrayInputStream(buf); 315 | ois=new ObjectInputStream(byteInStream); 316 | return (E) ois.readObject(); 317 | }catch (Exception e) { 318 | e.printStackTrace(); 319 | } 320 | return null; 321 | } 322 | public static void main(String[] args) { 323 | String hex=bytesToHexString("Hello world".getBytes()); 324 | System.out.println(hex); 325 | System.out.println(new String(hexStringToBytes(hex))); 326 | } 327 | } 328 | -------------------------------------------------------------------------------- /public/js/bst.min.js: -------------------------------------------------------------------------------- 1 | eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"2H 2S";q 2s="M"==U 1A&&"2l"==U 1A.2P?M(e){H U e}:M(e){H e&&"M"==U 1A&&e.2z===1A&&e!==1A.1M?"2l":U e};!M(){q e=M(e,t){e 1K 20?j.Q=1c 1H(e):e 1K 2q&&(j.Q=1c 1H(e)),j.1G=t,j.1g=0,j.1l=e.w||e.2R};e.1M={1w:M(){H j.Q},V:M(e){z(1L 0==e||"1b"!=U e)H j.1g;j.1g=e},1m:M(e){z(1L 0==e||"1b"!=U e)H j.1l;j.1l=e},2b:M(e,t){G(q r=!0,a=0;a=j.1g;s--){z(a=j.1v(s,e),a[0])H r-a[1].w;r++}N G(q s=j.1g;s>a:j.Q[t.13.S]>>a;N{0!=t.Y.1h&&(i=j.Q[t.13.S]>>a);G(q o=1;o>s;i|=(j.Q[t.Y.S]&j.1t(n))<>s&Z;N{0!=s&&(j.Q[r.13.S]&=j.1t(s),j.Q[r.13.S]|=i<>=s);G(q o=1;o>=s;j.Q[r.Y.S]&=j.1t(s,!0),j.Q[r.Y.S]|=Z&i}}},1W.1T=e}(),M(){M e(e){G(q t=[],r=0,a=0;a>6|2i,t[r++]=14&s|1k):2h==(2e&s)&&a+1>18|2m,t[r++]=s>>12&14|1k,t[r++]=s>>6&14|1k,t[r++]=14&s|1k):(t[r++]=s>>12|26,t[r++]=s>>6&14|1k,t[r++]=14&s|1k)}H t}M t(e){G(q t=[],r=0,a=0;r2L&&s<26){q n=e[r++];t[a++]=1D.1E((31&s)<<6|14&n)}N z(s>2K&&s<2N){q n=e[r++],i=e[r++],o=e[r++],h=((7&s)<<18|(14&n)<<12|(14&i)<<6|14&o)-2n;t[a++]=1D.1E(2h+(h>>10)),t[a++]=1D.1E(2k+(25&h))}N{q n=e[r++],i=e[r++];t[a++]=1D.1E((15&s)<<12|(14&n)<<6|14&i)}}H t.2A("")}M r(e){G(q t="",r=0;r>((1&r)<<2);J;x"2":t[a]|=32>>((1&r)<<2);J;x"3":t[a]|=2I>>((1&r)<<2);J;x"4":t[a]|=2G>>((1&r)<<2);J;x"5":t[a]|=2F>>((1&r)<<2);J;x"6":t[a]|=2E>>((1&r)<<2);J;x"7":t[a]|=2B>>((1&r)<<2);J;x"8":t[a]|=1k>>((1&r)<<2);J;x"9":t[a]|=2T>>((1&r)<<2);J;x"a":x"A":t[a]|=2Z>>((1&r)<<2);J;x"b":x"B":t[a]|=2W>>((1&r)<<2);J;x"c":x"C":t[a]|=2i>>((1&r)<<2);J;x"d":x"D":t[a]|=2V>>((1&r)<<2);J;x"e":x"E":t[a]|=26>>((1&r)<<2);J;x"f":x"F":t[a]|=2m>>((1&r)<<2)}a+=1&r}H t}M n(e,t,r){e=e||0;q a=e.1x(16);a.w%2!=0&&(a="0"+a);q s=[];z(t>a.w>>1)z(r){G(q n=(a.w>>1)-1;n>-1;n--)s.P(1p(a[n<<1]+a[1+(n<<1)],16));G(q n=a.w>>1;n>1);n++)s.P(0);G(q n=0;n>1;n++)s.P(1p(a[n<<1]+a[1+(n<<1)],16))}N z(t>0)z(r)G(q n=t-1;n>-1;n--)s.P(1p(a[n<<1]+a[1+(n<<1)],16));N G(q n=0;n-1;n--)s.P(1p(a[n-1]+a[n--],16));N G(q n=0;n":r--,t+=e[s];J;x"\\\\":t+=e[s++];J;1q:t+=e[s]}H a.P(j.1I(t)),t="",a},1I:M(t){q r={O:[],2p:j.1N.w,17:!0};z("\'"==t[0]&&"\'"==t[t.w-1]||\'"\'==t[0]&&\'"\'==t[t.w-1])H r.X="1z",r.1o=e(t.W(1,t.w-2)),r.L=r.1o.w,r.K=1s.1Q().1x(16).W(2),r.17=!1,j.1N.P(r.1o),j.1n[r.K]=r,r;z("<"==t[0]&&">"==t[t.w-1])H r.X="1U",r.K=1s.1Q().1x(16).W(2),r.17=!1,j.27(t,r),j.1n[r.K]=r,r;z("("==t[0]&&")"==t[t.w-1]){r.X="23",r.K=1s.1Q().1x(16).W(2),r.17=!1,r.T=j.1P(t.W(1,t.w-2));q a=[];r.1d=[];G(q s=0;s"==n[n.w-1]);N z("("==n[0]&&")"==n[n.w-1]){r.T=j.1P(n.W(1,n.w-2));G(q f=0;f":h--,n+=t[s];J;x"\\\\":n+=t[s++];J;1q:n+=t[s]}z("/"==i)z("["==n[0]&&"]"==n[n.w-1])r.X="1Z",r.19=j.1i(n.W(1,n.w-2));N z("{"==n[0]&&"}"==n[n.w-1])r.X="2d",r.1S=j.1i(n.W(1,n.w-2));N z("<"==n[0]&&">"==n[n.w-1])r.X="1U",j.27(n,r);N z("("==n[0]&&")"==n[n.w-1]){r.T=j.1P(n.W(1,n.w-2));G(q f=0;f":r--,t+=e[s];J;x"\\\\":t+=e[s++];J;1q:t+=e[s]}H a.P(j.1I(t)),t="",a},27:M(e,t){"?"==e[1]?(t.1V=!0,e=e.W(2,e.w-4)):(t.1V=!1,e=e.W(1,e.w-2)),t.11=j.1i(e)},2x:M(e){q t=[],r=e.2X("){");t.P(e.W(0,r)),e=e.W(r+2,e.w-2);G(q a=0,s="",n=[],i=0;i":a--,s+=e[i];J;x"\\\\":s+=e[i++];J;1q:s+=e[i]}H n.P(j.1i(s.W(1,s.w-2))),s="",t.P(n),t},1X:M(e,t){q r,a={};r=e 1K 21?e:1c 21(e);q s;s=t?"1B"==U t?j.1i(t):t:j.2c;q n=j.1a(s,r,a);z(n[0])G(q i=s.w-1;i>=n[1];i--)j.1R(s[i],r,a,!0);H a},1a:M(e,t,r,a){z(a)G(q s=e.w-1;s>-1;s--){q n=j.1R(e[s],t,r,a);z(n[0])H[n[0],s]}N G(q s=0;s-1&&(p=j.1a(b[1][g],t,r,a))}H p;x"1U":1e(e.11[0].X){x"1z":q v=t.1v(t.V(),[e.11[0].1o]);z(v[0]){z(e.17){q y={},d=j.1a(e.11,t,y,a);H r[e.K]=y,d}H j.1a(e.11,t,r,a)}J;1q:z(e.11[0].T){q v=t.1v(t.V(),e.11[0].T);z(v[0]){z(e.17){q y={},d=j.1a(e.11,t,y,a);H r[e.K]=y,d}H j.1a(e.11,t,r,a)}}N z(!e.1V){z(e.17){q y={},d=j.1a(e.11,t,y,a);H r[e.K]=y,d}H j.1a(e.11,t,r,a)}}J;x"23":q v=t.1v(t.V(),e.T);z(!v[0]&&e.1d&&e.1d.w)H j.1a(e.1d,t,r,a);t.V(t.V()+v[1].w);J;1q:z(e.T){q v=t.1v(t.V(),e.T);z(v[0])z(a?t.1m(t.1m()-v[1].w):t.V(t.V()+v[1].w),e.O&&e.O.w){G(q c,l=v[1],i=0;c=e.O[i];i++)l=j.1r[c](l);r[e.K]=l}N r[e.K]=v[1]}N{q L=j.1N.2U(e.2p);z(!L.w){z(a)z("1O"!=e.X){q l=t.1f(30,a);z(e.O&&e.O.w)G(q c,i=0;c=e.O[i];i++)l=j.1r[c](l);r[e.K]=l}N t.1m(t.V());H[!0]}z("1O"!=e.X){q l=t.1f(L,a);z(e.O&&e.O.w)G(q c,i=0;c=e.O[i];i++)l=j.1r[c](l);r[e.K]=l}N a?t.1m(t.1m()-t.1y(L,a)):t.V(t.V()+t.1y(L,a))}}H[]},1u:M(e,t){q r,a={};r=t?"1B"==U t?j.1i(t):t:j.2c;G(q s=0;s-1&&(a[n.K]=j.1u(e,b[1][m]))}J;x"2d":G(q g=e[n.K],v=1c 1T(n.1S),y=v.R,f=0;f= 1 && r < 1000) { 22 | r = parseInt(r * Math.pow(10, l), 10) / Math.pow(10, l) + k; 23 | break; 24 | } 25 | } 26 | return r; 27 | }; 28 | 29 | let bytesToHex; 30 | (function () { 31 | let csm=[]; 32 | (function () { 33 | var cs="0123456789abcdef"; 34 | var n=0; 35 | for(var i=0;i<16;i++){ 36 | for(var j=0;j<16;j++,n++){ 37 | csm[n]=cs[i]+cs[j]; 38 | } 39 | } 40 | })(); 41 | bytesToHex=function (a) { 42 | var s=''; 43 | for(var i=0;i= file.size) { 230 | block.end = file.size; 231 | } 232 | readFile(file, block); 233 | } 234 | } 235 | }); 236 | readFile(file, { 237 | fileSize: file.size, 238 | start: 0, 239 | end: ($this.bufferSize > file.size ? file.size : $this.bufferSize), 240 | step: 0 241 | }); 242 | }, 243 | hashNexFile: function () { 244 | if (this.filesToHash && this.filesToHash.length) { 245 | this.doHashWork(this.filesToHash.shift(), getWorker("hashWorker")); 246 | this.workers++; 247 | } 248 | }, 249 | startHashFiles: function () { 250 | while(this.workers-1){ 323 | $this.filesToHash.splice(idx,1); 324 | }else if(this.step==1){ 325 | this.stopHash=true; 326 | }else{ 327 | idx=$this.filesToUpload.indexOf(this); 328 | if(idx>-1){ 329 | $this.filesToUpload.splice(idx,1); 330 | }else if(this.step==2){ 331 | this.stopUpload=true; 332 | } 333 | } 334 | } 335 | files[i].onHashComplete=function(){ 336 | $this.workers--; 337 | this.hashComplete&&this.hashComplete(); 338 | $this.filesToUpload.push(this); 339 | }; 340 | readFileHead(files[i],function (file) { 341 | file.suffix=file.name.substring(file.name.lastIndexOf('.')); 342 | $this.filesToHash.push(file); 343 | }); 344 | } 345 | } 346 | }; 347 | window.CCFileUp = CCFileUp; 348 | })(); 349 | -------------------------------------------------------------------------------- /public/js/FileUtil.min.js: -------------------------------------------------------------------------------- 1 | File.prototype.fileSignatureMap={"ļĿŸŭŬĠŶťŲųũůŮĽĢıĮİĢĿľčĊļōōŃşŃůŮųůŬťņũŬťĠŃůŮųůŬťŖťŲ":["msc","MMC Snap-in Control file"],"ĀāĀĀōœʼnœŁōĠńšŴšŢšųť":["mny","Microsoft Money file"],"ĀāĀĀœŴšŮŤšŲŤĠŊťŴĠńł":["mdb","Microsoft Access"],"ĀāĀĀœŴšŮŤšŲŤĠŁŃŅĠńł":["accdb","Microsoft Access 2007"],"ōũţŲůųůŦŴĠŃįŃīīĠ":["pdb","MS C++ debugging symbols file"],"œőŌũŴťĠŦůŲŭšŴĠijĀ":["db","SQLite database file"],"ĀĆĕšĀĀĀĂĀĀĄǒĀĀĐĀ":["db","Netscape Navigator (v4) database"],"ļĿŸŭŬĠŶťŲųũůŮĽ":["manifest","Windows Visual Stylesheet"],"ĀĀĀĠŦŴŹŰōĴŁ":["m4a","Apple audio and video files"],"ŀŀŀĠĀĀŀŀŀŀ":["enl","EndNote Library File"],"łŏŏŋōŏłʼn":["prc","Palmpilot"],"ŴłōŐŋŮŗŲ":["prc","PathWay Map file"],"ŐŋăĄĔĀĆĀ":["pptx","MS Office 2007 documents"],"ǽǿǿǿĎĀĀĀ":["ppt","PowerPoint presentation subheader_4"],"ǐǏđǠơƱĚǡ":["ppt","Microsoft Office document"],"ǽǿǿǿĜĀĀĀ":["ppt","PowerPoint presentation subheader_5"],"ǽǿǿǿŃĀĀĀ":["ppt","PowerPoint presentation subheader_6"],"ǐǏđǠơƱĚǡ":["pps","Microsoft Office document"],"ƉŐŎŇčĊĚĊ":["png","PNG image"],"ŐŇŐŤōŁʼnŎ":["pgd","PGP disk image"],"ŁŏŌŖōıİİ":["pfc","AOL personal file cabinet"],"đĀĀĀœŃŃŁ":["pf","Windows prefetch file"],"ƬǭĀąųŲĀĒ":["pdb","BGBlitz position database file"],"ōĭŗĠŐůţū":["pdb","Merriam-Webster Pocket Dictionary"],"ŁŏŌŖōıİİ":["org","AOL personal file cabinet"],"ǐǏđǠơƱĚǡ":["opt","Developer Studio File Options file"],"ǤŒŜŻƌǘƧō":["one","MS OneNote note"],"ŏŧŧœĀĂĀĀ":["ogx","Ogg Vorbis Codec compressed file"],"ŏŧŧœĀĂĀĀ":["ogv","Ogg Vorbis Codec compressed file"],"ŏŧŧœĀĂĀĀ":["ogg","Ogg Vorbis Codec compressed file"],"ŏŧŧœĀĂĀĀ":["oga","Ogg Vorbis Codec compressed file"],"İıŏŒńŎŁŎ":["ntf","National Transfer Format Map"],"ĎŎťŲůʼnœŏ":["nri","Nero CD compilation"],"ǐǏđǠơƱĚǡ":["mtw","Minitab data file"],"ōœşŖŏʼnŃŅ":["msv","Sony Compressed Voice File"],"ǐǏđǠơƱĚǡ":["msi","Microsoft Installer package"],"ǐǏđǠơƱĚǡ":["msc","Microsoft Common Console Document"],"ǿǾģĀŬĀũĀ":["mof","MSinfo file"],"ĚŅǟƣƓłƂƈ":["mkv","Matroska stream file"],"ĚŅǟƣāĀĀĀ":["webm","google web media"],"ŖťŲųũůŮĠ":["mif","MapInfo Interchange Format file"],"ļōšūťŲņũ":["mif","Adobe FrameMaker"],"ĪĪĪĠĠʼnŮų":["log","Symantec Wise Installer log"],"ŌĀĀĀāĔĂĀ":["lnk","Windows shortcut file"],"ʼnŔŏŌʼnŔŌœ":["lit","MS Reader eBook"],"ġļšŲţŨľĊ":["lib","Unix archiver (ar)|MS Program Library Common Object File Format (COFF)"],"ŋŇłşšŲţŨ":["kgb","KGB archive"],"ĀĀĀČŪŐĠĠ":["jp2","JPEG2000 image files"],"ŐŋăĄĔĀĈĀ":["jar","Java archive_2"],"ŔŨũųĠũųĠ":["info","GNU Info Reader file"],"ǣĐĀāĀĀĀĀ":["info","Amiga icon"],"ŐĀĀĀĠĀĀĀ":["idx","Quicken QuickFinder Information File"],"ĨŔŨũųĠŦũ":["hqx","BinHex 4 Compressed Archive"],"ģĿŒŁńʼnŁŎ":["hdr","Radiance High Dynamic Range image file"],"ļōšūťŲņũ":["fm","Adobe FrameMaker"],"ŶIJİİijĮıİ":["flt","Qimage filter"],"ōŚƐĀăĀĀĀ":["flt","Audition graphic filter"],"ŦŌšŃĀĀĀĢ":["flac","Free Lossless Audio Codec file"],"ŅŬŦņũŬťĀ":["evtx","Windows Vista event log"],"İĀĀĀŌŦŌť":["evt","Windows Event Viewer file"],"ĥġŐœĭŁŤů":["eps","Encapsulated PostScript file"],"ŒťŴŵŲŮĭŐ":["eml","Generic e-mail_1"],"śŇťŮťŲšŬ":["ecf","MS Exchange configuration file"],"ŌŖņĉčĊǿĀ":["e01","Logical File Evidence Format"],"ŅŖņĉčĊǿĀ":["e01","Expert Witness Compression Format"],"ōœşŖŏʼnŃŅ":["dvf","Sony Compressed Voice File"],"ćŤŴIJŤŤŴŤ":["dtd","DesignTools 2D Design file"],"ģĠōũţŲůų":["dsp","MS Developer Studio project file"],"ǐǏđǠơƱĚǡ":["dot","Microsoft Office document"],"ŐŋăĄĔĀĆĀ":["docx","MS Office 2007 documents"],"ǏđǠơƱĚǡĀ":["doc","Perfect Office document"],"ǐǏđǠơƱĚǡ":["doc","Microsoft Office document"],"ŤťŸĊİİĹĀ":["dex","Dalvik (Android) executable file"],"ļġŤůţŴŹŰ":["dci","AOL HTML mail"],"ŏŐŌńšŴšŢ":["dbf","Psion Series 3 Database"],"ǐǏđǠơƱĚǡ":["db","MSWorks database file"],"ŕņŏŏŲŢũŴ":["dat","UFO Capture map file"],"ŎŁŖŔŒŁņņ":["dat","TomTom traffic data"],"ŒŁŚŁŔńłı":["dat","Shareaza (P2P) thumbnail"],"ĚŒŔœĠŃŏō":["dat","Runtime Software disk image"],"ŐŎŃʼnŕŎńŏ":["dat","Norton Disk Doctor undo file"],"ʼnŮŮůĠœťŴ":["dat","Inno Setup Uninstall Log"],"ŃŬũťŮŴĠŕ":["dat","IE History file"],"ŅŒņœœŁŖŅ":["dat","EasyRecovery Saved State file"],"ŁŖŇĶşʼnŮŴ":["dat","AVG6 Integrity database"],"ƩčĀĀĀĀĀĀ":["dat","Access Data FTK evidence"],"ŖŅŒœʼnŏŎĠ":["ctl","Visual Basic User-defined Control file"],"ŃšŴšŬůŧĠ":["ctf","WhereIsIt Catalog"],"ţŵųŨĀĀĀĂ":["csh","Photoshop Custom Shape"],"ʼnʼnĚĀĀĀňŅ":["crw","Canon RAW file"],"śŗũŮŤůŷų":["cpx","Microsoft Code Page Translation file"],"ŃŐŔķņʼnŌŅ":["cpt","Corel Photopaint file_1"],"œʼnŅŔŒŏŎʼn":["cpi","Sietronics CPI XRD document"],"ņŁŘŃŏŖŅŒ":["cpe","MS Fax Cover Sheet"],"œőŌŏŃŏŎŖ":["cnv","DB2 conversion file"],"śŦŬŴųũŭĮ":["cfg","Flight Simulator Aircraft Configuration"],"ōœşŖŏʼnŃŅ":["cdr","Sony Compressed Voice File"],"ŅŌʼnŔŅĠŃů":["cdr","Elite Plus Commander game file"],"ƵƢưƳƳưƥƵ":["cal","Windows calendar"],"œŵŰťŲŃšŬ":["cal","SuperCalc worksheet"],"ųŲţŤůţũŤ":["cal","CALS raster bitmap"],"ŁŏŌĠņťťŤ":["bag","AOL and AIM buddy list"],"ōŚƐĀăĀĀĀ":["ax","DirectShow filter"],"ƊāĉĀĀĀǡĈ":["aw","MS Answer Wizard"],"İĦƲŵƎŦǏđ":["asf","Windows Media Audio|Video File"],"ǐǏđǠơƱĚǡ":["apr","Lotus|IBM Approach 97 file"],"ōŚƐĀăĀĀĀ":["api","Acrobat plug-in"],"ăĀĀĀŁŐŐŒ":["adx","Approach index file"],"ǐǏđǠơƱĚǡ":["adp","Access project file"],"ŒŅŖŎŕōĺĬ":["ad","Antenna data file"],"ǐǏđǠơƱĚǡ":["ac_","CaseWare Working Papers"],"ŁŏŌʼnŎńŅŘ":["abi","AOL address book index"],"őŗĠŖťŲĮĠ":["abd","ABD | QSD Quicken data file"],"ĀĀĀĘŦŴŹŰ":["3gp5","MPEG-4 video files"],"ĀĀĀĠŦŴŹŰ":["3gp","3GPP2 multimedia files"],"ĀĀĀĔŦŴŹŰ":["3gp","3GPP multimedia files"],"ķǤœƖljǛǖć":["*","zisofs compressed file"],"œŚńńƈǰħij":["*","SZDD file format"],"œŚĠƈǰħijǑ":["*","QBASIC SZDD file"],"ǍĠƪƪĂĀĀĀ":["*","NAV quarantined virus file"],"ŋŗŁŊƈǰħǑ":["*","KWAJ (compressed) file"],"ŗůŲŤŐŲů":["lwp","Lotus WordPro file"],"śŐŨůŮťŝ":["dun","Dial-up networking file"],"ŤųŷŦũŬť":["dsw","MS Visual Studio workspace file"],"ŃŒŕœňĠŶ":["cru","Crush compressed archive"],"ŃŐŔņʼnŌŅ":["cpt","Corel Photopaint file_2"],"łŌʼnIJIJijő":["bin","Speedtouch router firmware"],"ƀĀĀĠăĒĄ":["adx","Dreamcast audio"],"ĀĀĚĀąĐĄ":["123","Lotus 1-2-3 (v9)"],"ŖŃŐŃňİ":["pch","Visual C PreCompiled header"],"ŎŅœōĚā":["nsf","NES Sound file"],"ĚĀĀĄĀĀ":["nsf","Lotus Notes database"],"ōōōńĀĀ":["mmf","Yamaha Synthetic music Mobile Application Format"],"ŊŁŒŃœĀ":["jar","JARCS compressed archive"],"ŁŏŌʼnńŘ":["ind","AOL client preferences|settings file"],"ŐʼnŃŔĀĈ":["img","ChromaGraph Graphics Card Bitmap"],"ĀĀǿǿǿǿ":["hlp","Windows Help file_1"],"ōńōŐƓƧ":["hdmp","Windows dump file"],"āǿĂĄăĂ":["drw","Micrografx vector graphic file"],"ŐŁŇŅńŕ":["dmp","Windows memory dump"],"ōńōŐƓƧ":["dmp","Windows dump file"],"ŎšŭťĺĠ":["cod","Agent newsreader character map"],"şŃŁœŅş":["cbk","EnCase case file"],"ŃłņʼnŌŅ":["cbd","WordPerfect dictionary"],"şŃŁœŅş":["cas","EnCase case file"],"ķźƼƯħĜ":["7z","7-Zip compressed file"],"ĀĔĀĀāĂ":["*","BIOS details in RAM"],"ŢŰŬũųŴ":["*","Binary property list (plist)"],"ǽǿǿǿĠ":["opt","Developer Studio subheader"],"ŎʼnŔņİ":["ntf","National Imagery Transmission Format file"],"ōŖIJıĴ":["mls","Milestones project management file_1"],"ōʼnŌŅœ":["mls","Milestones project management file"],"ōŁŒıĀ":["mar","Mozilla archive"],"ōŁŲİĀ":["mar","MAr compressed archive"],"ŻčĊůĠ":["lgd","Windows application log"],"ŻčĊůĠ":["lgc","Windows application log"],"Ńńİİı":["iso","ISO-9660 CD Disc Image"],"ŁŏŌńł":["idx","AOL user configuration"],"ǿņŏŎŔ":["cpi","Windows international code page"],"ģġŁōŒ":["amr","Adaptive Multi-Rate ACELP Codec (GSM)"],"ņŏŒōĀ":["aiff","Audio Interchange File"],"ŁŏŌńł":["aby","AOL address book"],"ŢťŧũŮ":["*","UUencoded file"],"İķİķİ":["*","cpio archive"],"ōŁŃĠ":["ape","Monkey’s Audio"],"ŒšŲġ":["rar","RAR File"],"ōœŃņ":["ppz","Powerpoint Packaged Presentation"],"ŐŋăĄ":["pptx","MS Office Open XML Format Document"],"ĀŮĞǰ":["ppt","PowerPoint presentation subheader_1"],"ďĀǨă":["ppt","PowerPoint presentation subheader_2"],"Ơņĝǰ":["ppt","PowerPoint presentation subheader_3"],"ĥŐńņ":["pdf","PDF file"],"ųźťź":["pdb","PowerBASIC Debugger Symbols"],"ĊĂāā":["pcx","ZSOFT Paintbrush file_1"],"Ċăāā":["pcx","ZSOFT Paintbrush file_2"],"Ċąāā":["pcx","ZSOFT Paintbrush file_3"],"ŇŐŁŔ":["pat","GIMP pattern file"],"ŐŁŃŋ":["pak","Quake archive file"],"ŤĀĀĀ":["p10","Intel PROset|Wireless Profile"],"ŐŋăĄ":["ott","OpenDocument template"],"ŐŋăĄ":["odt","OpenDocument template"],"ŐŋăĄ":["odp","OpenDocument template"],"ōŒŖŎ":["nvram","VMware BIOS state file"],"ĀĀāƳ":["mpg","MPEG video file"],"ĀĀāƺ":["mpg","DVD video file"],"ųūũŰ":["mov","QuickTime movie_6"],"ŰŮůŴ":["mov","QuickTime movie_5"],"ŷũŤť":["mov","QuickTime movie_4"],"ŭŤšŴ":["mov","QuickTime movie_3"],"ŦŲťť":["mov","QuickTime movie_2"],"ŭůůŶ":["mov","QuickTime movie_1"],"ōŌœŗ":["mls","Skype localization data file"],"ōŖIJŃ":["mls","Milestones project management file_2"],"ōŔŨŤ":["midi","MIDI sound file"],"ōŔŨŤ":["mid","MIDI sound file"],"āďĀĀ":["mdf","SQL Data Base"],"ōŁŒŃ":["mar","Microsoft|MSN MARC archive"],"LjĀŹĀ":["lbk","Jeppesen FliteLog file"],"ŐŋăĄ":["kwd","KWord document"],"ŎłĪĀ":["jtp","MS Windows journal"],"ǿǘǿǨ":["jpg","Still Picture Interchange File Format (SPIFF)"],"ǿǘǿǡ":["jpg","Digital camera JPG using Exchangeable Image File Format (EXIF)"],"ǿǘǿǠ":["jpg","JPEG IMAGE"],"ǿǘǿǣ":["jpeg","SAMSUNG D500 JPEG FILE"],"ǿǘǿǢ":["jpeg","CANNON EOS JPEG FILE"],"ǿǘǿǠ":["jpeg","JPEG IMAGE"],"ǿǘǿǠ":["jpe","JPE IMAGE FILE - jpeg"],"ǿǘǿǠ":["jpe","JPEG IMAGE"],"ŎłĪĀ":["jnt","MS Windows journal"],"ŊŇĄĎ":["jg","AOL ART file_2"],"ŊŇăĎ":["jg","AOL ART file_1"],"ǿǘǿǠ":["jfif","JFIF IMAGE FILE - jpeg"],"ǿǘǿǠ":["jfif","JPEG IMAGE"],"şħƨƉ":["jar","Jar archive"],"ŐŋăĄ":["jar","Java archive_1"],"ĮŒŅŃ":["ivr","RealPlayer video file (V11+)"],"źŢťŸ":["info","ZoomBrowser Image Index"],"œŃōʼn":["img","Img Software Bitmap"],"ǫļƐĪ":["img","GEM Raster file"],"ĀĀāĀ":["ico","Windows icon|printer spool file"],"ŌŎĂĀ":["hlp","Windows help file_3"],"ĿşăĀ":["hlp","Windows Help file_2"],"ňũŐġ":["hip","Houdini image file. Three-dimensional modeling and animation"],"ʼnœţĨ":["hdr","Install Shield compressed file"],"Ƒijňņ":["hap","Hamarsoft compressed archive"],"ŐōŃŃ":["grp","Windows Program Manager group file"],"Ňʼnņĸ":["gif","GIF file"],"ŌŎĂĀ":["gid","Windows help file_3"],"ĿşăĀ":["gid","Windows Help file_2"],"ǒĊĀĀ":["ftr","WinPharoah filter file"],"ĥŐńņ":["fdf","PDF file"],"ŎŅœĚ":["nes","NINTENDO game ROM file"],"ĚĵāĀ":["eth","WinPharoah capture file"],"DžǐǓdž":["eps","Adobe encapsulated PostScript"],"ņŲůŭ":["eml","Generic e-mail_2"],"ŁŃıİ":["dwg","Generic AutoCAD drawing"],"ĂŤųų":["dss","Digital Speech Standard file"],"Œʼnņņ":["ds4","Micrografx Designer graphic"],"ŐŋăĄ":["docx","MS Office Open XML Format Document"],"ǬƥǁĀ":["doc","Word document subheader"],"ǛƥĭĀ":["doc","Word 2.0 file"],"čńŏŃ":["doc","DeskMate Document"],"ńōœġ":["dms","Amiga DiskMasher compressed archive"],"ƱŨǞĺ":["dcx","PCX bitmap"],"ǏƭĒǾ":["dbx","Outlook Express e-mail folder"],"ŬijijŬ":["dbb","Skype user data file"],"Āāłń":["dba","Palm DateBook Archive"],"ǽǿǿǿ":["db","Thumbs.db subheader"],"ńłņň":["db","Palm Zire photo database"],"ŲťŧŦ":["dat","WinNT registry file"],"ŃŒŅŇ":["dat","Win9x registry hive"],"ŗōōŐ":["dat","Walkman MP3 file"],"ŐŅœŔ":["dat","PestPatrol data|scan strings"],"ųŬŨĮ":["dat","Allegro Generic Packfile (uncompressed)"],"ųŬŨġ":["dat","Allegro Generic Packfile (compressed)"],"Œʼnņņ":["dat","Video CD MPEG movie"],"ĀĀĂĀ":["cur","Windows cursor"],"ŐŋăĄ":["zip","zip files"],"Œʼnņņ":["cmx","Corel Presentation Exchange metadata"],"ŃōŘı":["clb","Corel Binary metafile"],"Ńŏōī":["clb","COM+ Catalog"],"NJǾƺƾ":["class","Java bytecode"],"ʼnŔœņ":["chm","MS Compiled HTML Help File"],"ʼnŔœņ":["chi","MS Compiled HTML Help File"],"Œʼnņņ":["cdr","CorelDraw document"],"Œʼnņņ":["cda","Resource Interchange File Format"],"ŒŔœœ":["cap","WinNT Netmon capture file"],"ŘŃŐĀ":["cap","Packet sniffer files"],"ōœŃņ":["cab","Microsoft cabinet file"],"ʼnœţĨ":["cab","Install Shield compressed file"],"Œʼnņņ":["avi","Resource Interchange File Format"],"ĮųŮŤ":["au","NeXT|Sun Microsystems audio file"],"ŤŮųĮ":["au","Audacity audio file"],"œŃňŬ":["ast","Underground Audio"],"ŁŲŃā":["arc","FreeArc compressed file"],"Œʼnņņ":["ani","Windows animated cursor"],"ǃƫǍƫ":["acs","MS Agent Character file"],"ŲũŦŦ":["ac","Sonic Foundry Acid Music File"],"ĀāłŁ":["aba","Palm Address Book Archive"],"Œʼnņņ":["4xm","4X Movie video"],"ǔǃƲơ":["*","WinDump (winpcap) capture file"],"ǿǾĀĀ":["*","UTF-32|UCS-4 file"],"ĴǍƲơ":["*","Tcpdump capture file"],"ơƲǃǔ":["*","tcpdump (libpcap) capture file"],"ąĀĀĀ":["*","INFO2 Windows recycle bin_2"],"ĄĀĀĀ":["*","INFO2 Windows recycle bin_1"],"ơƲǍĴ":["*","Extended tcpdump (libpcap) capture file"],"ſŅŌņ":["*","ELF executable"],"ŁŃœń":["*","AOL parameter|info files"],"ŐĵĊ":["pgm","Portable Graymap Graphic"],"ŁŏŌ":["pfc","AOL config files"],"ųŭş":["pdb","PalmOS SuperMemo"],"ŐŁŘ":["pax","PAX password protected bitmap"],"ĚĀĀ":["ntf","Lotus Notes database template"],"ʼnńij":["mp3","MP3 audio file"],"ĭŬŨ":["lzh","Compressed archive"],"ĭŬŨ":["lha","Compressed archive"],"ŁŏŌ":["ind","AOL config files"],"ńŖń":["ifo","DVD info file"],"ŁŏŌ":["idx","AOL config files"],"ğƋĈ":["gz","GZIP archive file"],"ŇŘIJ":["gx2","Show Partner graphics file"],"ņŌŖ":["flv","Flash video file"],"ńŖń":["dvr","DVR-Studio stream file"],"łŚŨ":["bz2","bzip2 compressed archive"],"ŁŏŌ":["bag","AOL config files"],"ńŏœ":["adf","Amiga disk file"],"ŁŏŌ":["aby","AOL config files"],"ŁŏŌ":["abi","AOL config files"],"ǯƻƿ":["*","UTF8 file"],"ƙā":["pkr","PGP public keyring"],"ōŚ":["pif","Windows|DOS executable file"],"Ěċ":["pak","PAK Compressed archive file"],"ōŚ":["olb","OLE object library"],"ōŚ":["ocx","ActiveX|OLE Custom Control"],"Ōā":["obj","MS COFF relocatable object code"],"ģĠ":["msi","Cerius2 file"],"Čǭ":["mp","Monochrome Picture TIFF bitmap"],"ŅŐ":["mdi","MS Document Imaging file"],"Ǿǯ":["ghs","Symantex Ghost image file"],"Ǿǯ":["gho","Symantex Ghost image file"],"ōŚ":["fon","Font file"],"Āđ":["fli","FLIC animation"],"ōŚ":["exe","Windows|DOS executable file"],"Řĭ":["eml","Exchange e-mail"],"ǜǾ":["efx","eFax file"],"ŏŻ":["dw4","Visio|DisplayWrite 4 text file"],"ōŖ":["dsn","CD Stomper Pro label file"],"ōŚ":["drv","Windows|DOS executable file"],"ōŚ":["dll","Windows|DOS executable file"],"łō":["dib","Bitmap image"],"ǜǜ":["cpl","Corel color palette"],"ōŚ":["cpl","Control panel application"],"ōŚ":["com","Windows|DOS executable file"],"łō":["bmp","Bitmap image"],"ŘŔ":["bdr","MS Publisher"],"ōŚ":["ax","Library cache file"],"ǔĪ":["aut","AOL history|typed URL files"],"ǔĪ":["arl","AOL history|typed URL files"],"ŠǪ":["arj","ARJ Compressed archive file"],"Ěĉ":["arc","LH archive (old vers.|type 5)"],"ĚĈ":["arc","LH archive (old vers.|type 4)"],"ĚĄ":["arc","LH archive (old vers.|type 3)"],"Ěă":["arc","LH archive (old vers.|type 2)"],"ĚĂ":["arc","LH archive (old vers.|type 1)"],"ġĒ":["ain","AIN Compressed Archive"],"ōŚ":["acm","MS audio compression manager driver"],"ōŚ":["386","Windows virtual device drivers"],"Ǿǿ":["*","UTF-16|UCS-2 file"],"ůļ":["*","SMS text (SIM)"],"Ƭǭ":["*","Java serialization data"],"ƀ":["obj","Relocatable object code"],"ƙ":["gpg","GPG public keyring"],"ć":["drw","Generic drawing programs"],"Ÿ":["dmg","MacOS X image file"],"Ą":["db4","dBASE IV file"],"ă":["db3","dBASE III file"],"Ĉ":["db","dBASE IV or dBFast configuration file"],"ă":["dat","MapInfo Native Data Format"],"ǫ":["com","Windows executable file_3"],"ǩ":["com","Windows executable file_2"],"Ǩ":["com","Windows executable file_1"],"İ":["cat","MS security catalog file"],"ļ":["asx","Advanced Stream Redirector"]};File.prototype.getFileRealType=function(){if(this.head){for(var p in this.fileSignatureMap){if(this.head.startsWith(p)){return this.fileSignatureMap[p]}}}};File.prototype.fileSizeFormats={Byte:Math.pow(10,0),KB:Math.pow(10,3),MB:Math.pow(10,6),GB:Math.pow(10,9),TB:Math.pow(10,12),PB:Math.pow(10,15),EB:Math.pow(10,18),ZB:Math.pow(10,21),YB:Math.pow(10,24),BB:Math.pow(10,27)};File.prototype.formatSize=function(lenght){var r;var l=lenght||2;for(var k in this.fileSizeFormats){var v=this.fileSizeFormats[k];r=this.size/v;if(r>=1&&r<1e3){r=parseInt(r*Math.pow(10,l),10)/Math.pow(10,l)+k;break}}return r}; -------------------------------------------------------------------------------- /public/js/FileUtil.js: -------------------------------------------------------------------------------- 1 | File.prototype.fileSignatureMap={ 2 | "ļĿŸŭŬĠŶťŲųũůŮĽĢıĮİĢĿľčĊļōōŃşŃůŮųůŬťņũŬťĠŃůŮųůŬťŖťŲ" : [ "msc", "MMC Snap-in Control file" ], 3 | "ĀāĀĀōœʼnœŁōĠńšŴšŢšųť" : [ "mny", "Microsoft Money file" ], 4 | "ĀāĀĀœŴšŮŤšŲŤĠŊťŴĠńł" : [ "mdb", "Microsoft Access" ], 5 | "ĀāĀĀœŴšŮŤšŲŤĠŁŃŅĠńł" : [ "accdb", "Microsoft Access 2007" ], 6 | "ōũţŲůųůŦŴĠŃįŃīīĠ" : [ "pdb", "MS C++ debugging symbols file" ], 7 | "œőŌũŴťĠŦůŲŭšŴĠijĀ" : [ "db", "SQLite database file" ], 8 | "ĀĆĕšĀĀĀĂĀĀĄǒĀĀĐĀ" : [ "db", "Netscape Navigator (v4) database" ], 9 | "ļĿŸŭŬĠŶťŲųũůŮĽ" : [ "manifest", "Windows Visual Stylesheet" ], 10 | "ĀĀĀĠŦŴŹŰōĴŁ" : [ "m4a", "Apple audio and video files" ], 11 | "ŀŀŀĠĀĀŀŀŀŀ" : [ "enl", "EndNote Library File" ], 12 | "łŏŏŋōŏłʼn" : [ "prc", "Palmpilot" ], 13 | "ŴłōŐŋŮŗŲ" : [ "prc", "PathWay Map file" ], 14 | "ŐŋăĄĔĀĆĀ" : [ "pptx", "MS Office 2007 documents" ], 15 | "ǽǿǿǿĎĀĀĀ" : [ "ppt", "PowerPoint presentation subheader_4" ], 16 | "ǐǏđǠơƱĚǡ" : [ "ppt", "Microsoft Office document" ], 17 | "ǽǿǿǿĜĀĀĀ" : [ "ppt", "PowerPoint presentation subheader_5" ], 18 | "ǽǿǿǿŃĀĀĀ" : [ "ppt", "PowerPoint presentation subheader_6" ], 19 | "ǐǏđǠơƱĚǡ" : [ "pps", "Microsoft Office document" ], 20 | "ƉŐŎŇčĊĚĊ" : [ "png", "PNG image" ], 21 | "ŐŇŐŤōŁʼnŎ" : [ "pgd", "PGP disk image" ], 22 | "ŁŏŌŖōıİİ" : [ "pfc", "AOL personal file cabinet" ], 23 | "đĀĀĀœŃŃŁ" : [ "pf", "Windows prefetch file" ], 24 | "ƬǭĀąųŲĀĒ" : [ "pdb", "BGBlitz position database file" ], 25 | "ōĭŗĠŐůţū" : [ "pdb", "Merriam-Webster Pocket Dictionary" ], 26 | "ŁŏŌŖōıİİ" : [ "org", "AOL personal file cabinet" ], 27 | "ǐǏđǠơƱĚǡ" : [ "opt", "Developer Studio File Options file" ], 28 | "ǤŒŜŻƌǘƧō" : [ "one", "MS OneNote note" ], 29 | "ŏŧŧœĀĂĀĀ" : [ "ogx", "Ogg Vorbis Codec compressed file" ], 30 | "ŏŧŧœĀĂĀĀ" : [ "ogv", "Ogg Vorbis Codec compressed file" ], 31 | "ŏŧŧœĀĂĀĀ" : [ "ogg", "Ogg Vorbis Codec compressed file" ], 32 | "ŏŧŧœĀĂĀĀ" : [ "oga", "Ogg Vorbis Codec compressed file" ], 33 | "İıŏŒńŎŁŎ" : [ "ntf", "National Transfer Format Map" ], 34 | "ĎŎťŲůʼnœŏ" : [ "nri", "Nero CD compilation" ], 35 | "ǐǏđǠơƱĚǡ" : [ "mtw", "Minitab data file" ], 36 | "ōœşŖŏʼnŃŅ" : [ "msv", "Sony Compressed Voice File" ], 37 | "ǐǏđǠơƱĚǡ" : [ "msi", "Microsoft Installer package" ], 38 | "ǐǏđǠơƱĚǡ" : [ "msc", "Microsoft Common Console Document" ], 39 | "ǿǾģĀŬĀũĀ" : [ "mof", "MSinfo file" ], 40 | "ĚŅǟƣƓłƂƈ" : [ "mkv", "Matroska stream file" ], 41 | "ĚŅǟƣāĀĀĀ" : [ "webm", "google web media" ], 42 | "ŖťŲųũůŮĠ" : [ "mif", "MapInfo Interchange Format file" ], 43 | "ļōšūťŲņũ" : [ "mif", "Adobe FrameMaker" ], 44 | "ĪĪĪĠĠʼnŮų" : [ "log", "Symantec Wise Installer log" ], 45 | "ŌĀĀĀāĔĂĀ" : [ "lnk", "Windows shortcut file" ], 46 | "ʼnŔŏŌʼnŔŌœ" : [ "lit", "MS Reader eBook" ], 47 | "ġļšŲţŨľĊ" : [ "lib", "Unix archiver (ar)|MS Program Library Common Object File Format (COFF)" ], 48 | "ŋŇłşšŲţŨ" : [ "kgb", "KGB archive" ], 49 | "ĀĀĀČŪŐĠĠ" : [ "jp2", "JPEG2000 image files" ], 50 | "ŐŋăĄĔĀĈĀ" : [ "jar", "Java archive_2" ], 51 | "ŔŨũųĠũųĠ" : [ "info", "GNU Info Reader file" ], 52 | "ǣĐĀāĀĀĀĀ" : [ "info", "Amiga icon" ], 53 | "ŐĀĀĀĠĀĀĀ" : [ "idx", "Quicken QuickFinder Information File" ], 54 | "ĨŔŨũųĠŦũ" : [ "hqx", "BinHex 4 Compressed Archive" ], 55 | "ģĿŒŁńʼnŁŎ" : [ "hdr", "Radiance High Dynamic Range image file" ], 56 | "ļōšūťŲņũ" : [ "fm", "Adobe FrameMaker" ], 57 | "ŶIJİİijĮıİ" : [ "flt", "Qimage filter" ], 58 | "ōŚƐĀăĀĀĀ" : [ "flt", "Audition graphic filter" ], 59 | "ŦŌšŃĀĀĀĢ" : [ "flac", "Free Lossless Audio Codec file" ], 60 | "ŅŬŦņũŬťĀ" : [ "evtx", "Windows Vista event log" ], 61 | "İĀĀĀŌŦŌť" : [ "evt", "Windows Event Viewer file" ], 62 | "ĥġŐœĭŁŤů" : [ "eps", "Encapsulated PostScript file" ], 63 | "ŒťŴŵŲŮĭŐ" : [ "eml", "Generic e-mail_1" ], 64 | "śŇťŮťŲšŬ" : [ "ecf", "MS Exchange configuration file" ], 65 | "ŌŖņĉčĊǿĀ" : [ "e01", "Logical File Evidence Format" ], 66 | "ŅŖņĉčĊǿĀ" : [ "e01", "Expert Witness Compression Format" ], 67 | "ōœşŖŏʼnŃŅ" : [ "dvf", "Sony Compressed Voice File" ], 68 | "ćŤŴIJŤŤŴŤ" : [ "dtd", "DesignTools 2D Design file" ], 69 | "ģĠōũţŲůų" : [ "dsp", "MS Developer Studio project file" ], 70 | "ǐǏđǠơƱĚǡ" : [ "dot", "Microsoft Office document" ], 71 | "ŐŋăĄĔĀĆĀ" : [ "docx", "MS Office 2007 documents" ], 72 | "ǏđǠơƱĚǡĀ" : [ "doc", "Perfect Office document" ], 73 | "ǐǏđǠơƱĚǡ" : [ "doc", "Microsoft Office document" ], 74 | "ŤťŸĊİİĹĀ" : [ "dex", "Dalvik (Android) executable file" ], 75 | "ļġŤůţŴŹŰ" : [ "dci", "AOL HTML mail" ], 76 | "ŏŐŌńšŴšŢ" : [ "dbf", "Psion Series 3 Database" ], 77 | "ǐǏđǠơƱĚǡ" : [ "db", "MSWorks database file" ], 78 | "ŕņŏŏŲŢũŴ" : [ "dat", "UFO Capture map file" ], 79 | "ŎŁŖŔŒŁņņ" : [ "dat", "TomTom traffic data" ], 80 | "ŒŁŚŁŔńłı" : [ "dat", "Shareaza (P2P) thumbnail" ], 81 | "ĚŒŔœĠŃŏō" : [ "dat", "Runtime Software disk image" ], 82 | "ŐŎŃʼnŕŎńŏ" : [ "dat", "Norton Disk Doctor undo file" ], 83 | "ʼnŮŮůĠœťŴ" : [ "dat", "Inno Setup Uninstall Log" ], 84 | "ŃŬũťŮŴĠŕ" : [ "dat", "IE History file" ], 85 | "ŅŒņœœŁŖŅ" : [ "dat", "EasyRecovery Saved State file" ], 86 | "ŁŖŇĶşʼnŮŴ" : [ "dat", "AVG6 Integrity database" ], 87 | "ƩčĀĀĀĀĀĀ" : [ "dat", "Access Data FTK evidence" ], 88 | "ŖŅŒœʼnŏŎĠ" : [ "ctl", "Visual Basic User-defined Control file" ], 89 | "ŃšŴšŬůŧĠ" : [ "ctf", "WhereIsIt Catalog" ], 90 | "ţŵųŨĀĀĀĂ" : [ "csh", "Photoshop Custom Shape" ], 91 | "ʼnʼnĚĀĀĀňŅ" : [ "crw", "Canon RAW file" ], 92 | "śŗũŮŤůŷų" : [ "cpx", "Microsoft Code Page Translation file" ], 93 | "ŃŐŔķņʼnŌŅ" : [ "cpt", "Corel Photopaint file_1" ], 94 | "œʼnŅŔŒŏŎʼn" : [ "cpi", "Sietronics CPI XRD document" ], 95 | "ņŁŘŃŏŖŅŒ" : [ "cpe", "MS Fax Cover Sheet" ], 96 | "œőŌŏŃŏŎŖ" : [ "cnv", "DB2 conversion file" ], 97 | "śŦŬŴųũŭĮ" : [ "cfg", "Flight Simulator Aircraft Configuration" ], 98 | "ōœşŖŏʼnŃŅ" : [ "cdr", "Sony Compressed Voice File" ], 99 | "ŅŌʼnŔŅĠŃů" : [ "cdr", "Elite Plus Commander game file" ], 100 | "ƵƢưƳƳưƥƵ" : [ "cal", "Windows calendar" ], 101 | "œŵŰťŲŃšŬ" : [ "cal", "SuperCalc worksheet" ], 102 | "ųŲţŤůţũŤ" : [ "cal", "CALS raster bitmap" ], 103 | "ŁŏŌĠņťťŤ" : [ "bag", "AOL and AIM buddy list" ], 104 | "ōŚƐĀăĀĀĀ" : [ "ax", "DirectShow filter" ], 105 | "ƊāĉĀĀĀǡĈ" : [ "aw", "MS Answer Wizard" ], 106 | "İĦƲŵƎŦǏđ" : [ "asf", "Windows Media Audio|Video File" ], 107 | "ǐǏđǠơƱĚǡ" : [ "apr", "Lotus|IBM Approach 97 file" ], 108 | "ōŚƐĀăĀĀĀ" : [ "api", "Acrobat plug-in" ], 109 | "ăĀĀĀŁŐŐŒ" : [ "adx", "Approach index file" ], 110 | "ǐǏđǠơƱĚǡ" : [ "adp", "Access project file" ], 111 | "ŒŅŖŎŕōĺĬ" : [ "ad", "Antenna data file" ], 112 | "ǐǏđǠơƱĚǡ" : [ "ac_", "CaseWare Working Papers" ], 113 | "ŁŏŌʼnŎńŅŘ" : [ "abi", "AOL address book index" ], 114 | "őŗĠŖťŲĮĠ" : [ "abd", "ABD | QSD Quicken data file" ], 115 | "ĀĀĀĘŦŴŹŰ" : [ "3gp5", "MPEG-4 video files" ], 116 | "ĀĀĀĠŦŴŹŰ" : [ "3gp", "3GPP2 multimedia files" ], 117 | "ĀĀĀĔŦŴŹŰ" : [ "3gp", "3GPP multimedia files" ], 118 | "ķǤœƖljǛǖć" : [ "*", "zisofs compressed file" ], 119 | "œŚńńƈǰħij" : [ "*", "SZDD file format" ], 120 | "œŚĠƈǰħijǑ" : [ "*", "QBASIC SZDD file" ], 121 | "ǍĠƪƪĂĀĀĀ" : [ "*", "NAV quarantined virus file" ], 122 | "ŋŗŁŊƈǰħǑ" : [ "*", "KWAJ (compressed) file" ], 123 | "ŗůŲŤŐŲů" : [ "lwp", "Lotus WordPro file" ], 124 | "śŐŨůŮťŝ" : [ "dun", "Dial-up networking file" ], 125 | "ŤųŷŦũŬť" : [ "dsw", "MS Visual Studio workspace file" ], 126 | "ŃŒŕœňĠŶ" : [ "cru", "Crush compressed archive" ], 127 | "ŃŐŔņʼnŌŅ" : [ "cpt", "Corel Photopaint file_2" ], 128 | "łŌʼnIJIJijő" : [ "bin", "Speedtouch router firmware" ], 129 | "ƀĀĀĠăĒĄ" : [ "adx", "Dreamcast audio" ], 130 | "ĀĀĚĀąĐĄ" : [ "123", "Lotus 1-2-3 (v9)" ], 131 | "ŖŃŐŃňİ" : [ "pch", "Visual C PreCompiled header" ], 132 | "ŎŅœōĚā" : [ "nsf", "NES Sound file" ], 133 | "ĚĀĀĄĀĀ" : [ "nsf", "Lotus Notes database" ], 134 | "ōōōńĀĀ" : [ "mmf", "Yamaha Synthetic music Mobile Application Format" ], 135 | "ŊŁŒŃœĀ" : [ "jar", "JARCS compressed archive" ], 136 | "ŁŏŌʼnńŘ" : [ "ind", "AOL client preferences|settings file" ], 137 | "ŐʼnŃŔĀĈ" : [ "img", "ChromaGraph Graphics Card Bitmap" ], 138 | "ĀĀǿǿǿǿ" : [ "hlp", "Windows Help file_1" ], 139 | "ōńōŐƓƧ" : [ "hdmp", "Windows dump file" ], 140 | "āǿĂĄăĂ" : [ "drw", "Micrografx vector graphic file" ], 141 | "ŐŁŇŅńŕ" : [ "dmp", "Windows memory dump" ], 142 | "ōńōŐƓƧ" : [ "dmp", "Windows dump file" ], 143 | "ŎšŭťĺĠ" : [ "cod", "Agent newsreader character map" ], 144 | "şŃŁœŅş" : [ "cbk", "EnCase case file" ], 145 | "ŃłņʼnŌŅ" : [ "cbd", "WordPerfect dictionary" ], 146 | "şŃŁœŅş" : [ "cas", "EnCase case file" ], 147 | "ķźƼƯħĜ" : [ "7z", "7-Zip compressed file" ], 148 | "ĀĔĀĀāĂ" : [ "*", "BIOS details in RAM" ], 149 | "ŢŰŬũųŴ" : [ "*", "Binary property list (plist)" ], 150 | "ǽǿǿǿĠ" : [ "opt", "Developer Studio subheader" ], 151 | "ŎʼnŔņİ" : [ "ntf", "National Imagery Transmission Format file" ], 152 | "ōŖIJıĴ" : [ "mls", "Milestones project management file_1" ], 153 | "ōʼnŌŅœ" : [ "mls", "Milestones project management file" ], 154 | "ōŁŒıĀ" : [ "mar", "Mozilla archive" ], 155 | "ōŁŲİĀ" : [ "mar", "MAr compressed archive" ], 156 | "ŻčĊůĠ" : [ "lgd", "Windows application log" ], 157 | "ŻčĊůĠ" : [ "lgc", "Windows application log" ], 158 | "Ńńİİı" : [ "iso", "ISO-9660 CD Disc Image" ], 159 | "ŁŏŌńł" : [ "idx", "AOL user configuration" ], 160 | "ǿņŏŎŔ" : [ "cpi", "Windows international code page" ], 161 | "ģġŁōŒ" : [ "amr", "Adaptive Multi-Rate ACELP Codec (GSM)" ], 162 | "ņŏŒōĀ" : [ "aiff", "Audio Interchange File" ], 163 | "ŁŏŌńł" : [ "aby", "AOL address book" ], 164 | "ŢťŧũŮ" : [ "*", "UUencoded file" ], 165 | "İķİķİ" : [ "*", "cpio archive" ], 166 | "ōŁŃĠ" : [ "ape" , "Monkey’s Audio" ], 167 | "ŒšŲġ" : [ "rar" , "RAR File" ], 168 | "ōœŃņ" : [ "ppz", "Powerpoint Packaged Presentation" ], 169 | "ŐŋăĄ" : [ "pptx", "MS Office Open XML Format Document" ], 170 | "ĀŮĞǰ" : [ "ppt", "PowerPoint presentation subheader_1" ], 171 | "ďĀǨă" : [ "ppt", "PowerPoint presentation subheader_2" ], 172 | "Ơņĝǰ" : [ "ppt", "PowerPoint presentation subheader_3" ], 173 | "ĥŐńņ" : [ "pdf", "PDF file" ], 174 | "ųźťź" : [ "pdb", "PowerBASIC Debugger Symbols" ], 175 | "ĊĂāā" : [ "pcx", "ZSOFT Paintbrush file_1" ], 176 | "Ċăāā" : [ "pcx", "ZSOFT Paintbrush file_2" ], 177 | "Ċąāā" : [ "pcx", "ZSOFT Paintbrush file_3" ], 178 | "ŇŐŁŔ" : [ "pat", "GIMP pattern file" ], 179 | "ŐŁŃŋ" : [ "pak", "Quake archive file" ], 180 | "ŤĀĀĀ" : [ "p10", "Intel PROset|Wireless Profile" ], 181 | "ŐŋăĄ" : [ "ott", "OpenDocument template" ], 182 | "ŐŋăĄ" : [ "odt", "OpenDocument template" ], 183 | "ŐŋăĄ" : [ "odp", "OpenDocument template" ], 184 | "ōŒŖŎ" : [ "nvram", "VMware BIOS state file" ], 185 | "ĀĀāƳ" : [ "mpg", "MPEG video file" ], 186 | "ĀĀāƺ" : [ "mpg", "DVD video file" ], 187 | "ųūũŰ" : [ "mov", "QuickTime movie_6" ], 188 | "ŰŮůŴ" : [ "mov", "QuickTime movie_5" ], 189 | "ŷũŤť" : [ "mov", "QuickTime movie_4" ], 190 | "ŭŤšŴ" : [ "mov", "QuickTime movie_3" ], 191 | "ŦŲťť" : [ "mov", "QuickTime movie_2" ], 192 | "ŭůůŶ" : [ "mov", "QuickTime movie_1" ], 193 | "ōŌœŗ" : [ "mls", "Skype localization data file" ], 194 | "ōŖIJŃ" : [ "mls", "Milestones project management file_2" ], 195 | "ōŔŨŤ" : [ "midi", "MIDI sound file" ], 196 | "ōŔŨŤ" : [ "mid", "MIDI sound file" ], 197 | "āďĀĀ" : [ "mdf", "SQL Data Base" ], 198 | "ōŁŒŃ" : [ "mar", "Microsoft|MSN MARC archive" ], 199 | "LjĀŹĀ" : [ "lbk", "Jeppesen FliteLog file" ], 200 | "ŐŋăĄ" : [ "kwd", "KWord document" ], 201 | "ŎłĪĀ" : [ "jtp", "MS Windows journal" ], 202 | "ǿǘǿǨ" : [ "jpg", "Still Picture Interchange File Format (SPIFF)" ], 203 | "ǿǘǿǡ" : [ "jpg", "Digital camera JPG using Exchangeable Image File Format (EXIF)" ], 204 | "ǿǘǿǠ" : [ "jpg", "JPEG IMAGE" ], 205 | "ǿǘǿǣ" : [ "jpeg", "SAMSUNG D500 JPEG FILE" ], 206 | "ǿǘǿǢ" : [ "jpeg", "CANNON EOS JPEG FILE" ], 207 | "ǿǘǿǠ" : [ "jpeg", "JPEG IMAGE" ], 208 | "ǿǘǿǠ" : [ "jpe", "JPE IMAGE FILE - jpeg" ], 209 | "ǿǘǿǠ" : [ "jpe", "JPEG IMAGE" ], 210 | "ŎłĪĀ" : [ "jnt", "MS Windows journal" ], 211 | "ŊŇĄĎ" : [ "jg", "AOL ART file_2" ], 212 | "ŊŇăĎ" : [ "jg", "AOL ART file_1" ], 213 | "ǿǘǿǠ" : [ "jfif", "JFIF IMAGE FILE - jpeg" ], 214 | "ǿǘǿǠ" : [ "jfif", "JPEG IMAGE" ], 215 | "şħƨƉ" : [ "jar", "Jar archive" ], 216 | "ŐŋăĄ" : [ "jar", "Java archive_1" ], 217 | "ĮŒŅŃ" : [ "ivr", "RealPlayer video file (V11+)" ], 218 | "źŢťŸ" : [ "info", "ZoomBrowser Image Index" ], 219 | "œŃōʼn" : [ "img", "Img Software Bitmap" ], 220 | "ǫļƐĪ" : [ "img", "GEM Raster file" ], 221 | "ĀĀāĀ" : [ "ico", "Windows icon|printer spool file" ], 222 | "ŌŎĂĀ" : [ "hlp", "Windows help file_3" ], 223 | "ĿşăĀ" : [ "hlp", "Windows Help file_2" ], 224 | "ňũŐġ" : [ "hip", "Houdini image file. Three-dimensional modeling and animation" ], 225 | "ʼnœţĨ" : [ "hdr", "Install Shield compressed file" ], 226 | "Ƒijňņ" : [ "hap", "Hamarsoft compressed archive" ], 227 | "ŐōŃŃ" : [ "grp", "Windows Program Manager group file" ], 228 | "Ňʼnņĸ" : [ "gif", "GIF file" ], 229 | "ŌŎĂĀ" : [ "gid", "Windows help file_3" ], 230 | "ĿşăĀ" : [ "gid", "Windows Help file_2" ], 231 | "ǒĊĀĀ" : [ "ftr", "WinPharoah filter file" ], 232 | "ĥŐńņ" : [ "fdf", "PDF file" ], 233 | "ŎŅœĚ" : [ "nes", "NINTENDO game ROM file" ], 234 | "ĚĵāĀ" : [ "eth", "WinPharoah capture file" ], 235 | "DžǐǓdž" : [ "eps", "Adobe encapsulated PostScript" ], 236 | "ņŲůŭ" : [ "eml", "Generic e-mail_2" ], 237 | "ŁŃıİ" : [ "dwg", "Generic AutoCAD drawing" ], 238 | "ĂŤųų" : [ "dss", "Digital Speech Standard file" ], 239 | "Œʼnņņ" : [ "ds4", "Micrografx Designer graphic" ], 240 | "ŐŋăĄ" : [ "docx", "MS Office Open XML Format Document" ], 241 | "ǬƥǁĀ" : [ "doc", "Word document subheader" ], 242 | "ǛƥĭĀ" : [ "doc", "Word 2.0 file" ], 243 | "čńŏŃ" : [ "doc", "DeskMate Document" ], 244 | "ńōœġ" : [ "dms", "Amiga DiskMasher compressed archive" ], 245 | "ƱŨǞĺ" : [ "dcx", "PCX bitmap" ], 246 | "ǏƭĒǾ" : [ "dbx", "Outlook Express e-mail folder" ], 247 | "ŬijijŬ" : [ "dbb", "Skype user data file" ], 248 | "Āāłń" : [ "dba", "Palm DateBook Archive" ], 249 | "ǽǿǿǿ" : [ "db", "Thumbs.db subheader" ], 250 | "ńłņň" : [ "db", "Palm Zire photo database" ], 251 | "ŲťŧŦ" : [ "dat", "WinNT registry file" ], 252 | "ŃŒŅŇ" : [ "dat", "Win9x registry hive" ], 253 | "ŗōōŐ" : [ "dat", "Walkman MP3 file" ], 254 | "ŐŅœŔ" : [ "dat", "PestPatrol data|scan strings" ], 255 | "ųŬŨĮ" : [ "dat", "Allegro Generic Packfile (uncompressed)" ], 256 | "ųŬŨġ" : [ "dat", "Allegro Generic Packfile (compressed)" ], 257 | "Œʼnņņ" : [ "dat", "Video CD MPEG movie" ], 258 | "ĀĀĂĀ" : [ "cur", "Windows cursor" ], 259 | "ŐŋăĄ" : [ "zip", "zip files" ], 260 | "Œʼnņņ" : [ "cmx", "Corel Presentation Exchange metadata" ], 261 | "ŃōŘı" : [ "clb", "Corel Binary metafile" ], 262 | "Ńŏōī" : [ "clb", "COM+ Catalog" ], 263 | "NJǾƺƾ" : [ "class", "Java bytecode" ], 264 | "ʼnŔœņ" : [ "chm", "MS Compiled HTML Help File" ], 265 | "ʼnŔœņ" : [ "chi", "MS Compiled HTML Help File" ], 266 | "Œʼnņņ" : [ "cdr", "CorelDraw document" ], 267 | "Œʼnņņ" : [ "cda", "Resource Interchange File Format" ], 268 | "ŒŔœœ" : [ "cap", "WinNT Netmon capture file" ], 269 | "ŘŃŐĀ" : [ "cap", "Packet sniffer files" ], 270 | "ōœŃņ" : [ "cab", "Microsoft cabinet file" ], 271 | "ʼnœţĨ" : [ "cab", "Install Shield compressed file" ], 272 | "Œʼnņņ" : [ "avi", "Resource Interchange File Format" ], 273 | "ĮųŮŤ" : [ "au", "NeXT|Sun Microsystems audio file" ], 274 | "ŤŮųĮ" : [ "au", "Audacity audio file" ], 275 | "œŃňŬ" : [ "ast", "Underground Audio" ], 276 | "ŁŲŃā" : [ "arc", "FreeArc compressed file" ], 277 | "Œʼnņņ" : [ "ani", "Windows animated cursor" ], 278 | "ǃƫǍƫ" : [ "acs", "MS Agent Character file" ], 279 | "ŲũŦŦ" : [ "ac", "Sonic Foundry Acid Music File" ], 280 | "ĀāłŁ" : [ "aba", "Palm Address Book Archive" ], 281 | "Œʼnņņ" : [ "4xm", "4X Movie video" ], 282 | "ǔǃƲơ" : [ "*", "WinDump (winpcap) capture file" ], 283 | "ǿǾĀĀ" : [ "*", "UTF-32|UCS-4 file" ], 284 | "ĴǍƲơ" : [ "*", "Tcpdump capture file" ], 285 | "ơƲǃǔ" : [ "*", "tcpdump (libpcap) capture file" ], 286 | "ąĀĀĀ" : [ "*", "INFO2 Windows recycle bin_2" ], 287 | "ĄĀĀĀ" : [ "*", "INFO2 Windows recycle bin_1" ], 288 | "ơƲǍĴ" : [ "*", "Extended tcpdump (libpcap) capture file" ], 289 | "ſŅŌņ" : [ "*", "ELF executable" ], 290 | "ŁŃœń" : [ "*", "AOL parameter|info files" ], 291 | "ŐĵĊ" : [ "pgm", "Portable Graymap Graphic" ], 292 | "ŁŏŌ" : [ "pfc", "AOL config files" ], 293 | "ųŭş" : [ "pdb", "PalmOS SuperMemo" ], 294 | "ŐŁŘ" : [ "pax", "PAX password protected bitmap" ], 295 | "ĚĀĀ" : [ "ntf", "Lotus Notes database template" ], 296 | "ʼnńij" : [ "mp3", "MP3 audio file" ], 297 | "ĭŬŨ" : [ "lzh", "Compressed archive" ], 298 | "ĭŬŨ" : [ "lha", "Compressed archive" ], 299 | "ŁŏŌ" : [ "ind", "AOL config files" ], 300 | "ńŖń" : [ "ifo", "DVD info file" ], 301 | "ŁŏŌ" : [ "idx", "AOL config files" ], 302 | "ğƋĈ" : [ "gz", "GZIP archive file" ], 303 | "ŇŘIJ" : [ "gx2", "Show Partner graphics file" ], 304 | "ņŌŖ" : [ "flv", "Flash video file" ], 305 | "ńŖń" : [ "dvr", "DVR-Studio stream file" ], 306 | "łŚŨ" : [ "bz2", "bzip2 compressed archive" ], 307 | "ŁŏŌ" : [ "bag", "AOL config files" ], 308 | "ńŏœ" : [ "adf", "Amiga disk file" ], 309 | "ŁŏŌ" : [ "aby", "AOL config files" ], 310 | "ŁŏŌ" : [ "abi", "AOL config files" ], 311 | "ǯƻƿ" : [ "*", "UTF8 file" ], 312 | "ƙā" : [ "pkr", "PGP public keyring" ], 313 | "ōŚ" : [ "pif", "Windows|DOS executable file" ], 314 | "Ěċ" : [ "pak", "PAK Compressed archive file" ], 315 | "ōŚ" : [ "olb", "OLE object library" ], 316 | "ōŚ" : [ "ocx", "ActiveX|OLE Custom Control" ], 317 | "Ōā" : [ "obj", "MS COFF relocatable object code" ], 318 | "ģĠ" : [ "msi", "Cerius2 file" ], 319 | "Čǭ" : [ "mp", "Monochrome Picture TIFF bitmap" ], 320 | "ŅŐ" : [ "mdi", "MS Document Imaging file" ], 321 | "Ǿǯ" : [ "ghs", "Symantex Ghost image file" ], 322 | "Ǿǯ" : [ "gho", "Symantex Ghost image file" ], 323 | "ōŚ" : [ "fon", "Font file" ], 324 | "Āđ" : [ "fli", "FLIC animation" ], 325 | "ōŚ" : [ "exe", "Windows|DOS executable file" ], 326 | "Řĭ" : [ "eml", "Exchange e-mail" ], 327 | "ǜǾ" : [ "efx", "eFax file" ], 328 | "ŏŻ" : [ "dw4", "Visio|DisplayWrite 4 text file" ], 329 | "ōŖ" : [ "dsn", "CD Stomper Pro label file" ], 330 | "ōŚ" : [ "drv", "Windows|DOS executable file" ], 331 | "ōŚ" : [ "dll", "Windows|DOS executable file" ], 332 | "łō" : [ "dib", "Bitmap image" ], 333 | "ǜǜ" : [ "cpl", "Corel color palette" ], 334 | "ōŚ" : [ "cpl", "Control panel application" ], 335 | "ōŚ" : [ "com", "Windows|DOS executable file" ], 336 | "łō" : [ "bmp", "Bitmap image" ], 337 | "ŘŔ" : [ "bdr", "MS Publisher" ], 338 | "ōŚ" : [ "ax", "Library cache file" ], 339 | "ǔĪ" : [ "aut", "AOL history|typed URL files" ], 340 | "ǔĪ" : [ "arl", "AOL history|typed URL files" ], 341 | "ŠǪ" : [ "arj", "ARJ Compressed archive file" ], 342 | "Ěĉ" : [ "arc", "LH archive (old vers.|type 5)" ], 343 | "ĚĈ" : [ "arc", "LH archive (old vers.|type 4)" ], 344 | "ĚĄ" : [ "arc", "LH archive (old vers.|type 3)" ], 345 | "Ěă" : [ "arc", "LH archive (old vers.|type 2)" ], 346 | "ĚĂ" : [ "arc", "LH archive (old vers.|type 1)" ], 347 | "ġĒ" : [ "ain", "AIN Compressed Archive" ], 348 | "ōŚ" : [ "acm", "MS audio compression manager driver" ], 349 | "ōŚ" : [ "386", "Windows virtual device drivers" ], 350 | "Ǿǿ" : [ "*", "UTF-16|UCS-2 file" ], 351 | "ůļ" : [ "*", "SMS text (SIM)" ], 352 | "Ƭǭ" : [ "*", "Java serialization data" ], 353 | "ƀ" : [ "obj", "Relocatable object code" ], 354 | "ƙ" : [ "gpg", "GPG public keyring" ], 355 | "ć" : [ "drw", "Generic drawing programs" ], 356 | "Ÿ" : [ "dmg", "MacOS X image file" ], 357 | "Ą" : [ "db4", "dBASE IV file" ], 358 | "ă" : [ "db3", "dBASE III file" ], 359 | "Ĉ" : [ "db", "dBASE IV or dBFast configuration file" ], 360 | "ă" : [ "dat", "MapInfo Native Data Format" ], 361 | "ǫ" : [ "com", "Windows executable file_3" ], 362 | "ǩ" : [ "com", "Windows executable file_2" ], 363 | "Ǩ" : [ "com", "Windows executable file_1" ], 364 | "İ" : [ "cat", "MS security catalog file" ], 365 | "ļ" : [ "asx", "Advanced Stream Redirector" ] 366 | } 367 | File.prototype.getFileRealType=function () { 368 | if(this.head){ 369 | for(var p in this.fileSignatureMap){ 370 | if(this.head.startsWith(p)){ 371 | return this.fileSignatureMap[p]; 372 | } 373 | } 374 | } 375 | } 376 | 377 | File.prototype.fileSizeFormats={ 378 | 'Byte':Math.pow(10,0), 379 | 'KB':Math.pow(10,3), 380 | 'MB':Math.pow(10,6), 381 | 'GB':Math.pow(10,9), 382 | 'TB':Math.pow(10,12), 383 | 'PB':Math.pow(10,15), 384 | 'EB':Math.pow(10,18), 385 | 'ZB':Math.pow(10,21), 386 | 'YB':Math.pow(10,24), 387 | 'BB':Math.pow(10,27) 388 | }; 389 | File.prototype.formatSize=function(lenght){ 390 | var r; 391 | var l=lenght||2; 392 | for(var k in this.fileSizeFormats){ 393 | var v=this.fileSizeFormats[k]; 394 | r=this.size/v; 395 | if(r>=1&&r<1000){ 396 | r=parseInt(r*Math.pow(10,l),10)/Math.pow(10,l)+k; 397 | break; 398 | } 399 | } 400 | return r; 401 | } -------------------------------------------------------------------------------- /src/main/java/com/fileup/bitsyntax/CCBitsyntax.java: -------------------------------------------------------------------------------- 1 | package com.fileup.bitsyntax; 2 | import java.io.OutputStream; 3 | import java.nio.ByteBuffer; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.HashMap; 7 | import java.util.LinkedHashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import java.util.Random; 12 | 13 | import com.fileup.bitsyntax.bean.Bitem; 14 | import com.fileup.bitsyntax.bean.Bitem.BitemType; 15 | import com.fileup.bitsyntax.function.FromBytes; 16 | import com.fileup.bitsyntax.function.ToBytes; 17 | 18 | 19 | /** 20 | * © 2015-2017 Chenxj Copyright 21 | * 类 名:CCBitsyntax 22 | * 类 描 述:Bit syntax 23 | * 作 者:chenxj 24 | * 邮 箱:chenios@foxmail.com 25 | * 日 期:2017年9月15日-下午6:03:15 26 | */ 27 | public class CCBitsyntax extends CCFLib { 28 | private Random random; 29 | 30 | // 分隔符列表, 31 | private List sps; 32 | private Map allItems; 33 | private Bitem[] bitems; 34 | 35 | public CCBitsyntax(String des) { 36 | this.random=new Random(); 37 | this.sps = new ArrayList<>(); 38 | this.allItems = new LinkedHashMap<>(); 39 | this.bitems = this.parser(des); 40 | } 41 | 42 | public String toString() { 43 | StringBuilder sb = new StringBuilder(); 44 | sb.append("sps:\n"); 45 | for (byte[] b : this.sps) { 46 | sb.append(Arrays.toString(b)).append('\n'); 47 | } 48 | sb.append("bitems:\n"); 49 | for (Bitem b : bitems) { 50 | sb.append(b.toString()).append('\n'); 51 | } 52 | return sb.toString(); 53 | } 54 | 55 | @SuppressWarnings("unchecked") 56 | private T stringToInt(String str) { 57 | try { 58 | return (T) Integer.valueOf(str); 59 | } catch (Exception e) { 60 | return (T) str; 61 | } 62 | } 63 | 64 | private Bitem[] parser(String byntax) { 65 | StringBuilder sb = new StringBuilder(); 66 | List rl = new ArrayList<>(); 67 | int inArea = 0; 68 | for (int i = 0; i < byntax.length(); i++) { 69 | switch (byntax.charAt(i)) { 70 | case ',': 71 | if (inArea != 0) { 72 | sb.append(byntax.charAt(i)); 73 | } else { 74 | rl.add(this.analyze(sb.toString())); 75 | sb.delete(0, sb.length()); 76 | } 77 | break; 78 | case '"': 79 | case '\'': 80 | inArea = -inArea; 81 | sb.append(byntax.charAt(i)); 82 | break; 83 | case '(': 84 | case '{': 85 | case '[': 86 | case '<': 87 | inArea++; 88 | sb.append(byntax.charAt(i)); 89 | break; 90 | case ')': 91 | case '}': 92 | case ']': 93 | case '>': 94 | inArea--; 95 | sb.append(byntax.charAt(i)); 96 | break; 97 | case '\\': 98 | sb.append(byntax.charAt(i++)); 99 | break; 100 | default: 101 | sb.append(byntax.charAt(i)); 102 | break; 103 | } 104 | } 105 | rl.add(this.analyze(sb.toString())); 106 | sb = null; 107 | Bitem[] r = new Bitem[rl.size()]; 108 | rl.toArray(r); 109 | return r; 110 | } 111 | 112 | private Bitem analyze(String el) { 113 | Bitem rm = new Bitem(); 114 | rm.setSeparatorDataIndex(this.sps.size()); 115 | if ((el.charAt(0) == '\'' && el.charAt(el.length() - 1) == '\'') 116 | || (el.charAt(0) == '"' && el.charAt(el.length() - 1) == '"')) { 117 | rm.setType(BitemType.SEPARATOR); 118 | // 实际中应该使用stringToUint8Array 119 | rm.setSeparatorData(el.substring(1, el.length() - 1).getBytes()); 120 | rm.setL(rm.getSeparatorData().length); 121 | rm.setName(Integer.toHexString(random.nextInt())); 122 | rm.setNamed(false); 123 | this.sps.add(rm.getSeparatorData()); 124 | this.allItems.put(rm.getName(), rm); 125 | return rm; 126 | } else if (el.charAt(0) == '<' && el.charAt(el.length() - 1) == '>') { 127 | rm.setType(BitemType.MIXED); 128 | rm.setName(Integer.toHexString(random.nextInt())); 129 | rm.setNamed(false); 130 | this.parserMixed(el, rm); 131 | this.allItems.put(rm.getName(), rm); 132 | return rm; 133 | } else if (el.charAt(0) == '(' && el.charAt(el.length() - 1) == ')') { 134 | rm.setType(BitemType.RANGE); 135 | rm.setName(Integer.toHexString(random.nextInt())); 136 | rm.setNamed(false); 137 | rm.setBitems(this.parserRange(el.substring(1, el.length() - 1))); 138 | List range = new ArrayList<>(); 139 | List rg = new ArrayList<>(); 140 | for (int i = 0; i < rm.getBitems().length; i++) { 141 | if (rm.getBitems()[i].getType() != BitemType.SEPARATOR) { 142 | rg.add(rm.getBitems()[i]); 143 | } else { 144 | range.add(rm.getBitems()[i].getSeparatorData()); 145 | } 146 | } 147 | Bitem[] rgg = new Bitem[rg.size()]; 148 | rg.toArray(rgg); 149 | rm.setRg(rgg); 150 | 151 | byte[][] rag = new byte[range.size()][]; 152 | range.toArray(rag); 153 | rm.setRange(rag); 154 | this.allItems.put(rm.getName(), rm); 155 | return rm; 156 | } 157 | StringBuilder sb = new StringBuilder(); 158 | char lastChar = 0; 159 | int inArea = 0; 160 | for (int i = 0; i < el.length(); i++) { 161 | switch (el.charAt(i)) { 162 | case ':': 163 | if (inArea == 0) { 164 | rm.setName(sb.toString()); 165 | sb.delete(0, sb.length()); 166 | lastChar = el.charAt(i); 167 | } else { 168 | sb.append(el.charAt(i)); 169 | } 170 | break; 171 | case '/': 172 | if (inArea == 0) { 173 | if (rm.getName() != null) { 174 | rm.setL(this.stringToInt(sb.toString())); 175 | } else { 176 | rm.setName(sb.toString()); 177 | } 178 | sb.delete(0, sb.length()); 179 | lastChar = el.charAt(i); 180 | } else { 181 | sb.append(el.charAt(i)); 182 | } 183 | break; 184 | case '-': 185 | if (inArea == 0) { 186 | if (sb.charAt(0) == '[' && sb.charAt(sb.length() - 1) == ']') { 187 | // 188 | } else if (sb.charAt(0) == '{' && sb.charAt(sb.length() - 1) == '}') { 189 | // 190 | } else if (sb.charAt(0) == '<' && sb.charAt(sb.length() - 1) == '>') { 191 | // 192 | } else if (sb.charAt(0) == '(' && sb.charAt(sb.length() - 1) == ')') { 193 | rm.setBitems(this.parserRange(sb.substring(1, sb.length() - 1))); 194 | List range = new ArrayList<>(); 195 | for (int j = 0; j < rm.getBitems().length; j++) { 196 | range.add(rm.getBitems()[j].getSeparatorData()); 197 | } 198 | byte[][] rag = new byte[range.size()][]; 199 | range.toArray(rag); 200 | rm.setRange(rag); 201 | } else { 202 | rm.getTypes().add(sb.toString()); 203 | } 204 | sb.delete(0, sb.length()); 205 | } else { 206 | sb.append(el.charAt(i)); 207 | } 208 | break; 209 | case '(': 210 | case '{': 211 | case '[': 212 | case '<': 213 | inArea++; 214 | sb.append(el.charAt(i)); 215 | break; 216 | case ')': 217 | case '}': 218 | case ']': 219 | case '>': 220 | inArea--; 221 | sb.append(el.charAt(i)); 222 | break; 223 | case '\\': 224 | sb.append(el.charAt(i++)); 225 | break; 226 | default: 227 | sb.append(el.charAt(i)); 228 | break; 229 | } 230 | } 231 | if (lastChar == '/') { 232 | if (sb.charAt(0) == '[' && sb.charAt(sb.length() - 1) == ']') { 233 | rm.setType(BitemType.LIST); 234 | rm.setBitems(this.parser(sb.substring(1, sb.length() - 1))); 235 | } else if (sb.charAt(0) == '{' && sb.charAt(sb.length() - 1) == '}') { 236 | rm.setType(BitemType.BITMAP); 237 | rm.setBitems(this.parser(sb.substring(1, sb.length() - 1))); 238 | } else if (sb.charAt(0) == '<' && sb.charAt(sb.length() - 1) == '>') { 239 | rm.setType(BitemType.MIXED); 240 | this.parserMixed(sb.toString(), rm); 241 | } else if (sb.charAt(0) == '(' && sb.charAt(sb.length() - 1) == ')') { 242 | rm.setBitems(this.parserRange(sb.substring(1, sb.length() - 1))); 243 | List range = new ArrayList<>(); 244 | for (int j = 0; j < rm.getBitems().length; j++) { 245 | range.add(rm.getBitems()[j].getSeparatorData()); 246 | } 247 | byte[][] rag = new byte[range.size()][]; 248 | range.toArray(rag); 249 | rm.setRange(rag); 250 | } else { 251 | rm.getTypes().add(sb.toString()); 252 | } 253 | } else if (lastChar == ':') { 254 | rm.setL(this.stringToInt(sb.toString())); 255 | } else { 256 | if (sb.charAt(0) == '(' && sb.charAt(sb.length() - 1) == '}') { 257 | rm.setType(BitemType.EXCHANGE); 258 | rm.setExchange(this.parserExchange(sb.substring(1, sb.length() - 1))); 259 | } else { 260 | rm.setName(sb.toString()); 261 | } 262 | } 263 | sb.delete(0, sb.length()); 264 | if (rm.getName() == null||"".equals(rm.getName())) { 265 | rm.setName(Integer.toHexString(random.nextInt())); 266 | rm.setNamed(false); 267 | } else if ("_".equals(rm.getName())) { 268 | rm.setType(BitemType.PLACEHOLDER); 269 | } 270 | this.allItems.put(rm.getName(), rm); 271 | return rm; 272 | } 273 | 274 | private Bitem[] parserRange(String el) { 275 | StringBuilder sb = new StringBuilder(); 276 | int inArea = 0; 277 | List rl = new ArrayList<>(); 278 | for (int i = 0; i < el.length(); i++) { 279 | switch (el.charAt(i)) { 280 | case '|': 281 | if (inArea != 0) { 282 | sb.append(el.charAt(i)); 283 | } else { 284 | rl.add(this.analyze(sb.toString())); 285 | sb.delete(0, sb.length()); 286 | } 287 | break; 288 | case '"': 289 | case '\'': 290 | inArea = -inArea; 291 | sb.append(el.charAt(i)); 292 | break; 293 | case '(': 294 | case '{': 295 | case '[': 296 | case '<': 297 | inArea++; 298 | sb.append(el.charAt(i)); 299 | break; 300 | case ')': 301 | case '}': 302 | case ']': 303 | case '>': 304 | inArea--; 305 | sb.append(el.charAt(i)); 306 | break; 307 | case '\\': 308 | sb.append(el.charAt(i++)); 309 | break; 310 | default: 311 | sb.append(el.charAt(i)); 312 | break; 313 | } 314 | } 315 | rl.add(this.analyze(sb.toString())); 316 | sb.delete(0, sb.length()); 317 | Bitem[] r = new Bitem[rl.size()]; 318 | rl.toArray(r); 319 | return r; 320 | } 321 | 322 | private void parserMixed(String el, Bitem rm) { 323 | if (el.charAt(1) == '?') { 324 | rm.setDispensable(true); 325 | el = el.substring(2, el.length() - 2); 326 | } else { 327 | rm.setDispensable(false); 328 | el = el.substring(1, el.length() - 1); 329 | } 330 | rm.setBitems(this.parser(el)); 331 | } 332 | 333 | private Object[] parserExchange(String el) { 334 | List rl = new ArrayList<>(); 335 | int index = el.indexOf("){"); 336 | rl.add(el.substring(0, index)); 337 | el = el.substring(index + 2, el.length()); 338 | 339 | int inArea = 0; 340 | StringBuilder sb = new StringBuilder(); 341 | List exs = new ArrayList<>(); 342 | for (int i = 0; i < el.length(); i++) { 343 | switch (el.charAt(i)) { 344 | case ':': 345 | if (inArea == 0) { 346 | exs.add(this.stringToInt(sb.toString())); 347 | sb.delete(0, sb.length()); 348 | } else { 349 | sb.append(el.charAt(i)); 350 | } 351 | break; 352 | case ',': 353 | if (inArea == 0) { 354 | exs.add(this.parser(sb.substring(1, sb.length() - 1))); 355 | sb.delete(0, sb.length()); 356 | } else { 357 | sb.append(el.charAt(i)); 358 | } 359 | break; 360 | case '"': 361 | case '\'': 362 | inArea = -inArea; 363 | sb.append(el.charAt(i)); 364 | break; 365 | case '(': 366 | case '{': 367 | case '[': 368 | case '<': 369 | inArea++; 370 | sb.append(el.charAt(i)); 371 | break; 372 | case ')': 373 | case '}': 374 | case ']': 375 | case '>': 376 | inArea--; 377 | sb.append(el.charAt(i)); 378 | break; 379 | case '\\': 380 | sb.append(el.charAt(i++)); 381 | break; 382 | default: 383 | sb.append(el.charAt(i)); 384 | break; 385 | } 386 | } 387 | exs.add(this.parser(sb.substring(1, sb.length() - 1))); 388 | sb.delete(0, sb.length()); 389 | rl.add(exs.toArray()); 390 | return rl.toArray(); 391 | } 392 | 393 | public Map convertToMap(Object a, Object des) { 394 | Map rs = new HashMap<>(); 395 | CCDataView dv; 396 | if (a instanceof CCDataView) { 397 | dv = (CCDataView) a; 398 | } else if (a instanceof ByteBuffer) { 399 | dv = new CCDataView((ByteBuffer) a); 400 | } else { 401 | dv = new CCDataView((byte[]) a); 402 | } 403 | Bitem[] bitems; 404 | if (des != null) { 405 | if (des instanceof String) { 406 | bitems = this.parser((String) des); 407 | } else { 408 | bitems = (Bitem[]) des; 409 | } 410 | } else { 411 | bitems = this.bitems; 412 | } 413 | int[] r = this.doConvertTo(bitems, dv, rs, false); 414 | if (r[0] != 0) { 415 | for (int i = bitems.length - 1; i >= r[1]; i--) { 416 | this.doConvert(bitems[i], dv, rs, true); 417 | } 418 | } 419 | return rs; 420 | } 421 | public Map convertToMap(Object a) { 422 | return convertToMap(a,null); 423 | } 424 | 425 | private int[] doConvertTo(Bitem[] bitems, CCDataView dv, Map rs, boolean revert) { 426 | if (revert) { 427 | for (int i = bitems.length - 1; i > -1; i--) { 428 | int[] r = this.doConvert(bitems[i], dv, rs, revert); 429 | if (r[0] != 0) { 430 | return new int[] { r[0], i }; 431 | } 432 | } 433 | } else { 434 | for (int i = 0; i < bitems.length; i++) { 435 | int[] r = this.doConvert(bitems[i], dv, rs, revert); 436 | if (r[0] != 0) { 437 | return new int[] { r[0], i }; 438 | } 439 | } 440 | } 441 | return new int[] { 0 }; 442 | } 443 | 444 | private int[] doConvert(Bitem bitem, CCDataView dv, Map rs, boolean revert) { 445 | if (bitem.getL() != null) { 446 | switch (bitem.getType()) { 447 | case SEPARATOR: 448 | if (revert) { 449 | dv.limit(dv.limit() - (int) bitem.getL()); 450 | } else { 451 | dv.position(dv.position() + (int) bitem.getL()); 452 | } 453 | break; 454 | case LIST: 455 | List datas = new ArrayList<>(); 456 | boolean itemIsArray = false; 457 | if (bitem.getBitems().length == 1) { 458 | itemIsArray = !bitem.getBitems()[0].isNamed(); 459 | } 460 | if (bitem.getL() instanceof String) { 461 | if (itemIsArray) { 462 | for (int j = 0; j < (int) rs.get(bitem.getL()); j++) { 463 | datas.add(dv.getArray(bitem.getBitems()[0].getL())); 464 | } 465 | } else { 466 | for (int j = 0; j < (int) rs.get(bitem.getL()); j++) { 467 | datas.add(this.convertToMap(dv, bitem.getBitems())); 468 | } 469 | } 470 | } else { 471 | if (itemIsArray) { 472 | for (int j = 0; j < (int) bitem.getL(); j++) { 473 | datas.add(dv.getArray(bitem.getBitems()[0].getL())); 474 | } 475 | } else { 476 | for (int j = 0; j < (int) bitem.getL(); j++) { 477 | datas.add(this.convertToMap(dv, bitem.getBitems())); 478 | } 479 | } 480 | } 481 | rs.put(bitem.getName(), datas); 482 | break; 483 | case BITMAP: 484 | CCBitmap bm; 485 | if (bitem.getL() instanceof String) { 486 | bm = new CCBitmap(bitem.getBitems(), dv.getArray(bitem.getL(), revert)); 487 | } else { 488 | bm = new CCBitmap(bitem.getBitems(), dv.getArray(rs.get(bitem.getL()), revert)); 489 | } 490 | Bitem[] bms = bm.getBm(); 491 | Map bmv = bm.toMap(); 492 | for (int j = 0; j < bms.length; j++) { 493 | if (!"_".equals(bms[j].getName())) { 494 | bmv.put(bms[j].getName(), 495 | convertByTypes(fromLib, bms[j].getTypes(), bmv.get(bms[j].getName()), -1, false)); 496 | } 497 | } 498 | if (bitem.isNamed()) { 499 | rs.put(bitem.getName(), bmv); 500 | } else { 501 | rs.putAll(bmv); 502 | } 503 | break; 504 | case PLACEHOLDER: // 只适合读取用来跳过数据读取 505 | if (bitem.getL() instanceof String) { 506 | dv.position(dv.position() + (int) rs.get(bitem.getL())); 507 | } else { 508 | dv.position(dv.position() + (int) bitem.getL()); 509 | } 510 | break; 511 | default: 512 | Object v; 513 | if (bitem.getL() instanceof String) { 514 | v = dv.getArray((int) rs.get(bitem.getL()), revert); 515 | } else { 516 | v = dv.getArray(bitem.getL(), revert); 517 | } 518 | if (!bitem.getTypes().isEmpty()) { 519 | int l = bitem.getTypes().size(); 520 | for (int j = 0; j < l; j++) { 521 | v = fromLib.get(bitem.getTypes().get(j)).apply(v); 522 | } 523 | } 524 | rs.put(bitem.getName(), v); 525 | break; 526 | } 527 | } else { 528 | switch (bitem.getType()) { 529 | case EXCHANGE: 530 | Object[] exc = bitem.getExchange(); 531 | int[] r = new int[] { 0 }; 532 | if (exc[0] instanceof String) { 533 | Object refCondition = rs.get(exc[0]); 534 | int convertFlag = -1; 535 | Object[] exc_1 = (Object[]) exc[1]; 536 | if(refCondition instanceof String){ 537 | for (int j = 0; j < exc_1.length; j++) { 538 | if (refCondition.equals(exc_1[j])) { 539 | r = this.doConvertTo((Bitem[]) exc_1[++j], dv, rs, revert); 540 | convertFlag--; 541 | break; 542 | } else if ("".equals(exc_1[j])) { 543 | convertFlag = ++j; 544 | }else { 545 | j++; 546 | } 547 | } 548 | }else{ 549 | for (int j = 0; j < exc_1.length; j++) { 550 | if ((int)refCondition==(int)exc_1[j]) { 551 | r = this.doConvertTo((Bitem[]) exc_1[++j], dv, rs, revert); 552 | convertFlag--; 553 | break; 554 | } else if ("".equals(exc_1[j])) { 555 | convertFlag = ++j; 556 | }else{ 557 | j++; 558 | } 559 | } 560 | } 561 | if (convertFlag > -1) { 562 | r = this.doConvertTo((Bitem[]) exc_1[convertFlag], dv, rs, revert); 563 | } 564 | } 565 | return r; 566 | case MIXED: 567 | switch (bitem.getBitems()[0].getType()) { 568 | case SEPARATOR: 569 | Object[] matchsResult = dv.matchsAt(dv.position(), 570 | new byte[][] { bitem.getBitems()[0].getSeparatorData() }); 571 | if ((boolean) matchsResult[0]) { 572 | if (bitem.isNamed()) { 573 | Map oo = new HashMap<>(); 574 | int[] rr = this.doConvertTo(bitem.getBitems(), dv, oo, revert); 575 | rs.put(bitem.getName(), oo); 576 | return rr; 577 | } else { 578 | return this.doConvertTo(bitem.getBitems(), dv, rs, revert); 579 | } 580 | } 581 | break; 582 | default: 583 | if (bitem.getBitems()[0].getRange().length != 0) { 584 | Object[] matchsResult2 = dv.matchsAt(dv.position(), bitem.getBitems()[0].getRange()); 585 | if ((boolean) matchsResult2[0]) { 586 | if (bitem.isNamed()) { 587 | Map oo = new HashMap<>(); 588 | int[] rr = this.doConvertTo(bitem.getBitems(), dv, oo, revert); 589 | rs.put(bitem.getName(), oo); 590 | return rr; 591 | } else { 592 | return this.doConvertTo(bitem.getBitems(), dv, rs, revert); 593 | } 594 | } 595 | } else if (!bitem.isDispensable()) { 596 | if (bitem.isNamed()) { 597 | Map oo = new HashMap<>(); 598 | int[] rr = this.doConvertTo(bitem.getBitems(), dv, oo, revert); 599 | rs.put(bitem.getName(), oo); 600 | return rr; 601 | } else { 602 | return this.doConvertTo(bitem.getBitems(), dv, rs, revert); 603 | } 604 | } 605 | ; 606 | break; 607 | } 608 | break; 609 | case RANGE: 610 | Object[] matchsResult = dv.matchsAt(dv.position(), bitem.getRange()); 611 | if (!(boolean) matchsResult[0] && bitem.getRg().length != 0) { 612 | return this.doConvertTo(bitem.getRg(), dv, rs, revert); 613 | } else { 614 | dv.position(dv.position() + ((Object[]) matchsResult[1]).length); 615 | } 616 | break; 617 | default: 618 | if (bitem.getRange()!=null) { 619 | Object[] matchsResult2 = dv.matchsAt(dv.position(), bitem.getRange()); 620 | if ((boolean) matchsResult2[0]) { 621 | if (revert) { 622 | dv.limit(dv.limit() - ((byte[]) matchsResult2[1]).length); 623 | } else { 624 | dv.position(dv.position() + ((byte[]) matchsResult2[1]).length); 625 | } 626 | Object v = matchsResult2[1]; 627 | if (!bitem.getTypes().isEmpty()) { 628 | int l = bitem.getTypes().size(); 629 | for (int j = 0; j < l; j++) { 630 | v = fromLib.get(bitem.getTypes().get(j)).apply(v); 631 | } 632 | } 633 | rs.put(bitem.getName(), v); 634 | } 635 | } else { 636 | List lsb = this.sps.subList(bitem.getSeparatorDataIndex(), sps.size()); 637 | byte[][] separatorDatas = new byte[lsb.size()][]; 638 | lsb.toArray(separatorDatas); 639 | 640 | if (separatorDatas.length != 0) { 641 | if (bitem.getType() != BitemType.PLACEHOLDER) { 642 | Object v = dv.getArray(separatorDatas, revert); 643 | if (!bitem.getTypes().isEmpty()) { 644 | int l = bitem.getTypes().size(); 645 | for (int j = 0; j < l; j++) { 646 | v = fromLib.get(bitem.getTypes().get(j)).apply(v); 647 | } 648 | } 649 | rs.put(bitem.getName(), v); 650 | } else { 651 | if (revert) { 652 | dv.limit(dv.limit() - dv.arrayMatch(separatorDatas, revert)); 653 | } else { 654 | dv.position(dv.position() + dv.arrayMatch(separatorDatas, revert)); 655 | } 656 | } 657 | } else { 658 | if (revert) { 659 | if (bitem.getType() != BitemType.PLACEHOLDER) { 660 | Object v = dv.getArray(null, revert); 661 | if (!bitem.getTypes().isEmpty()) { 662 | int l = bitem.getTypes().size(); 663 | for (int j = 0; j < l; j++) { 664 | v = fromLib.get(bitem.getTypes().get(j)).apply(v); 665 | } 666 | } 667 | rs.put(bitem.getName(), v); 668 | } else { 669 | dv.limit(dv.position()); 670 | } 671 | } 672 | return new int[] { 1 }; 673 | } 674 | } 675 | break; 676 | } 677 | } 678 | return new int[] { 0 }; 679 | } 680 | 681 | @SuppressWarnings("unchecked") 682 | private Map convertToBytesMap(Map o, Object des) { 683 | Map rm = new LinkedHashMap<>(); 684 | Bitem[] bitems; 685 | if (des != null) { 686 | if (des instanceof String) { 687 | bitems = this.parser((String) des); 688 | } else { 689 | bitems = (Bitem[]) des; 690 | } 691 | } else { 692 | bitems = this.bitems; 693 | } 694 | for (int i = 0; i < bitems.length; i++) { 695 | Bitem bitem = bitems[i]; 696 | switch (bitem.getType()) { 697 | case SEPARATOR: 698 | rm.put(bitem.getName(), bitem.getSeparatorData()); 699 | break; 700 | case LIST: 701 | Object[] datas; 702 | Object dts = o.get(bitem.getName()); 703 | if (dts instanceof List) { 704 | datas = ((List) dts).toArray(); 705 | } else { 706 | datas = (Object[]) dts; 707 | } 708 | CCBytes da = new CCBytes(); 709 | boolean itemIsArray = false; 710 | if (bitem.getBitems().length == 1) { 711 | itemIsArray = !bitem.getBitems()[0].isNamed(); 712 | } 713 | if (bitem.getL() instanceof String) { 714 | if (itemIsArray) { 715 | for (int j = 0; j < datas.length; j++) { 716 | da.addAll((byte[]) datas[j]); 717 | } 718 | } else { 719 | for (int j = 0; j < datas.length; j++) { 720 | da.addAll(this.convertToByteArray((Map) datas[j], bitem.getBitems())); 721 | } 722 | } 723 | Bitem refBitem = this.allItems.get(bitem.getL()); 724 | Object tv = datas.length; 725 | int typesl = refBitem.getTypes().size(); 726 | for (int j = typesl - 1; j > -1; j--) { 727 | tv = toLib.get(refBitem.getTypes().get(j)).apply(tv, refBitem.getL()); 728 | } 729 | rm.put(bitem.getL(), (byte[])tv); 730 | // 别的地方可能需要使用 731 | o.put(bitem.getL(), datas.length); 732 | 733 | } else { 734 | if (itemIsArray) { 735 | for (int j = 0; j < (int) bitem.getL(); j++) { 736 | da.addAll((byte[]) datas[j]); 737 | } 738 | } else { 739 | for (int j = 0; j < (int) bitem.getL(); j++) { 740 | da.addAll(this.convertToByteArray((Map) datas[j], bitem.getBitems())); 741 | } 742 | } 743 | } 744 | rm.put(bitem.getName(), da.getBytes()); 745 | break; 746 | case EXCHANGE: 747 | Object[] exc = bitem.getExchange(); 748 | if (exc[0] instanceof String) { 749 | Object refCondition =o.get(exc[0]); 750 | Object[] exc_1 = (Object[]) exc[1]; 751 | int convertFlag = -1; 752 | if(refCondition instanceof String){ 753 | for (int j = 0; j < exc_1.length; j++) { 754 | if (refCondition.equals(exc_1[j])) { 755 | rm.put(bitem.getName(), this.convertToByteArray(o, exc_1[++j])); 756 | convertFlag--; 757 | break; 758 | } else if ("".equals(exc_1[j])) { 759 | convertFlag = ++j; 760 | }else{ 761 | j++; 762 | } 763 | } 764 | }else{ 765 | for (int j = 0; j < exc_1.length; j++) { 766 | if ((int)refCondition==(int)exc_1[j]) { 767 | rm.put(bitem.getName(), this.convertToByteArray(o, exc_1[++j])); 768 | convertFlag--; 769 | break; 770 | } else if ("".equals(exc_1[j])) { 771 | convertFlag = ++j; 772 | }else{ 773 | j++; 774 | } 775 | } 776 | } 777 | if (convertFlag > -1) { 778 | rm.put(bitem.getName(), this.convertToByteArray(o, exc_1[convertFlag])); 779 | } 780 | } 781 | break; 782 | case BITMAP: 783 | Map valueMap = (Map) o.get(bitem.getName()); 784 | 785 | CCBitmap bitmap = new CCBitmap(bitem.getBitems(), null); 786 | Bitem[] bms = bitmap.getBm(); 787 | for (int j = 0; j < bms.length; j++) { 788 | bitmap.setItemValue(bms[j].getName(), convertByTypes(toLib, bms[j].getTypes(), 789 | valueMap.get(bms[j].getName()), bms[j].getL(), true)); 790 | } 791 | byte[] bs = bitmap.buffer(); 792 | rm.put(bitem.getName(), bs); 793 | if (bitem.getL() instanceof String) { 794 | 795 | Bitem refBitem = this.allItems.get(bitem.getL()); 796 | Object tv = bs.length; 797 | int typesl = refBitem.getTypes().size(); 798 | for (int j = typesl - 1; j > -1; j--) { 799 | tv = toLib.get(refBitem.getTypes().get(j)).apply(tv, refBitem.getL()); 800 | } 801 | rm.put(bitem.getL(), (byte[])tv); 802 | o.put(bitem.getL(), bs.length); 803 | } 804 | break; 805 | case MIXED: 806 | if (bitem.isNamed()) { 807 | if (o.containsKey(bitem.getName())) { 808 | rm.put(bitem.getName(), this.convertToByteArray((Map) o.get(bitem.getName()), 809 | bitem.getBitems())); 810 | } 811 | } else { 812 | for (int mi = 0; mi < bitem.getBitems().length; mi++) { 813 | if (o.containsKey(bitem.getBitems()[mi].getName())) { 814 | rm.put(bitem.getName(), this.convertToByteArray(o, bitem.getBitems())); 815 | break; 816 | } 817 | } 818 | } 819 | if (!bitem.isDispensable()) { 820 | // TODO 821 | } 822 | break; 823 | case RANGE: 824 | if (bitem.getRg().length > 0 && o.containsKey(bitem.getRg()[0].getName())) { 825 | Object tv = o.get(bitem.getRg()[0].getName()); 826 | int typesl = bitem.getRg()[0].getTypes().size(); 827 | for (int j = typesl - 1; j > -1; j--) { 828 | tv = toLib.get(bitem.getRg()[0].getTypes().get(j)).apply(tv, -1); 829 | } 830 | rm.put(bitem.getName(), (byte[])tv); 831 | } else { 832 | rm.put(bitem.getName(), bitem.getRange()[0]); 833 | } 834 | break; 835 | default: 836 | if (bitem.getL() instanceof String) { 837 | Object tv = o.get(bitem.getName()); 838 | int typesl = bitem.getTypes().size(); 839 | for (int j = typesl - 1; j > -1; j--) { 840 | tv = toLib.get(bitem.getTypes().get(j)).apply(tv, -1); 841 | } 842 | rm.put(bitem.getName(), (byte[])tv); 843 | o.put(bitem.getL(), ((byte[]) tv).length); 844 | 845 | Bitem refBitem = this.allItems.get(bitem.getL()); 846 | tv = ((byte[]) tv).length; 847 | typesl = refBitem.getTypes().size(); 848 | for (int j = typesl - 1; j > -1; j--) { 849 | tv = toLib.get(refBitem.getTypes().get(j)).apply(tv, refBitem.getL()); 850 | } 851 | rm.put(bitem.getL(), (byte[])tv); 852 | } else { 853 | Object tv = o.get(bitem.getName()); 854 | int typesl = bitem.getTypes().size(); 855 | for (int j = typesl - 1; j > -1; j--) { 856 | tv = toLib.get(bitem.getTypes().get(j)).apply(tv, bitem.getL()); 857 | } 858 | rm.put(bitem.getName(), (byte[])tv); 859 | } 860 | break; 861 | } 862 | } 863 | return rm; 864 | } 865 | public byte[] convertToByteArray(Map o, Object des){ 866 | Map rm=this.convertToBytesMap(o, des); 867 | CCBytes rs = new CCBytes(); 868 | for (Entry entry : rm.entrySet()) { 869 | rs.addAll((byte[]) entry.getValue()); 870 | } 871 | return rs.getBytes(); 872 | } 873 | public byte[] convertToByteArray(Map o){ 874 | return convertToByteArray(o, null); 875 | } 876 | public void writeToOutPutStream(Map o, Object des,OutputStream out){ 877 | Map rm=this.convertToBytesMap(o, des); 878 | try{ 879 | for (Entry entry : rm.entrySet()) { 880 | out.write((byte[]) entry.getValue()); 881 | } 882 | }catch (Exception e) { 883 | e.printStackTrace(); 884 | } 885 | } 886 | public void writeToOutPutStream(Map o,OutputStream out){ 887 | writeToOutPutStream(o, null, out); 888 | } 889 | @SuppressWarnings("unchecked") 890 | private T convertByTypes(Map lib, List types, Object value, int length, boolean d) { 891 | int l = types.size(); 892 | if (!d) { 893 | for (int i = 0; i < l; i++) { 894 | value = ((FromBytes) lib.get(types.get(i))).apply(value); 895 | } 896 | } else { 897 | for (int i = l - 1; i > -1; i--) { 898 | value = ((ToBytes) lib.get(types.get(i))).apply(value, length); 899 | } 900 | } 901 | return (T) value; 902 | } 903 | } 904 | --------------------------------------------------------------------------------