OutputFormat of;
XMLSerializer serializer;
Element XMLelement = null;
Node XMLnode = null;
// Document (Xerces implementation only).
Document xmldoc = new DocumentImpl();
// Root element.
Element mainElement = xmldoc.createElement("mainElement");
Element rootFilesForDeleting = xmldoc.createElement("filesForDeleting");
Element rootDirsForDeleting = xmldoc.createElement("foldersForDeleting");
Element mainDir = xmldoc.createElement("mainDir");
SomeFunctionsForInstaller SomeFunctionsForInstaller = new SomeFunctionsForInstaller();
Map<Integer, String> tmpfileNamesForShortcuts = new HashMap();
ArrayList<Map> fileNamesForShortcuts = new ArrayList<Map>();
SomeFunctionsForInstaller SomeFunctionsForInstallerLocal=new SomeFunctionsForInstaller();
if (zipfile_test.getEncoding() == null) {
zipfile = new ZipFile(filename, consoleEnc);
} else {
zipfile = new ZipFile(filename, zipfile_test.getEncoding());
}
zipfile_test.close();
e = zipfile.getEntries();
while (e.hasMoreElements()) {
countFiles++;
entry = (ZipEntry) e.nextElement();
localFileName = entry.getName();
if (localFileName.endsWith("/")) {
localFileName = MainFrame.destinationFolder + localFileName;
XMLelement = xmldoc.createElementNS(null, "folderForDeleting");
XMLelement.setAttributeNS(null, "pathToDir", localFileName);
XMLnode = xmldoc.createTextNode(localFileName);
XMLelement.appendChild(XMLnode);
rootDirsForDeleting.appendChild(XMLelement);
nameForDirCreating = new File(MainFrame.destinationFolder + entry.getName());
nameForDirCreating.mkdirs();
}
}
e = zipfile.getEntries();
while (e.hasMoreElements()) {
countProcessedFiles++;
countProgress = (int) (countProcessedFiles / countFiles * 100);
SwingUtilities.invokeLater(new UpdateProgressBarTask(
MainFrame.jPB1, countProgress));
MainFrame.jPB1.repaint();
count = 0;
data = new byte[BUFFER];
entry = (ZipEntry) e.nextElement();
localFileName = MainFrame.destinationFolder + entry.getName();
if (!localFileName.endsWith("/")) {
XMLelement = xmldoc.createElementNS(null, "fileForDeleting");
XMLelement.setAttributeNS(null, "pathToFile", localFileName);
XMLnode = xmldoc.createTextNode(localFileName);
XMLelement.appendChild(XMLnode);
rootFilesForDeleting.appendChild(XMLelement);
//System.out.println("Extracting " + localFileName);
entryStream = zipfile.getInputStream(entry);
is = new BufferedInputStream(entryStream);
fos = new FileOutputStream(localFileName);
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = is.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
is.close();
entryStream.close();
}
}
zipfile.close();
XMLelement = xmldoc.createElementNS(null, "mainDirForDeleting");
XMLelement.setAttributeNS(null, "pathToDir", MainFrame.destinationFolder);
XMLnode = xmldoc.createTextNode(MainFrame.destinationFolder);
XMLelement.appendChild(XMLnode);
mainDir.appendChild(XMLelement);
mainElement.appendChild(rootFilesForDeleting);
mainElement.appendChild(rootDirsForDeleting);
mainElement.appendChild(mainDir);
xmldoc.appendChild(mainElement);
fosForXML = new FileOutputStream(MainFrame.destinationFolder + "fileList.xml");
of = new OutputFormat("XML", "UTF-8", true);
of.setIndent(1);
of.setIndenting(true);
serializer = new XMLSerializer(fosForXML, of);
serializer.asDOMSerializer();
serializer.serialize(xmldoc.getDocumentElement());
fosForXML.close();
SwingUtilities.invokeLater(new Runnable() {
@Override