lxw
2023-10-09 1fa878f57239475c925ae1ea4bd2793c3e831b49
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
33
package com.whyc.service;
 
import com.whyc.dto.FileDirPath;
import com.whyc.dto.Response;
import com.whyc.pojo.FileMessage;
import com.whyc.util.ZipAndRarUtil;
import org.springframework.stereotype.Service;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
@Service
public class ZipAndRarService {
 
 
    //产品查看原来压缩包中文件信息(文件目录和时间)
    public Response getzipAndRarInfo(String fileUrl) {
        String fileDirName = FileDirPath.getFileDirName();
        List<FileMessage> list=new ArrayList<>();
        try {
            if(fileUrl.contains("zip")){
                list=ZipAndRarUtil.getZipFileList(fileDirName+ File.separator+fileUrl);
            }else if(fileUrl.contains("rar")){
                list=ZipAndRarUtil.getRarList(fileDirName+ File.separator+fileUrl);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new Response().setII(1,list!=null,list,"压缩文件信息");
    }
}