Exemple #1
0
 private String createAMFRequest(String arg0, String arg1) {
   String data = "0A000000030200";
   data += getHexLength(arg0) + JDHexUtils.getHexString(arg0) + "0200";
   data += getHexLength(arg1) + JDHexUtils.getHexString(arg1) + "020004706C6179";
   return JDHexUtils.toString(
       "000300000001000F66696C652E617564696F5F696E666F00022F31000000"
           + getHexLength(JDHexUtils.toString(data))
           + data);
 }
Exemple #2
0
 @Override
 public void extract(ExtractionController ctrl) {
   final Archive archive = getExtractionController().getArchive();
   final ArchiveFile firstArchiveFile = archive.getArchiveFiles().get(0);
   final String matches[] = splitType.getMatches(firstArchiveFile.getName());
   if (matches != null) {
     try {
       final String fileName;
       final int skipBytes;
       final String signature =
           JDHexUtils.toString(
               FileSignatures.readFileSignature(new File(firstArchiveFile.getFilePath())));
       if (new Regex(signature, "^[\\w]{3}  \\d{3}").matches()) {
         final String extension = new Regex(signature, "^([\\w]{3})").getMatch(0);
         fileName = matches[0] + "." + extension;
         skipBytes = 8;
       } else {
         skipBytes = 0;
         fileName = matches[0];
       }
       if (SplitUtil.merge(getExtractionController(), fileName, skipBytes, getConfig())) {
         archive.setExitCode(ExtractionControllerConstants.EXIT_CODE_SUCCESS);
       } else {
         if (archive.getExitCode() == -1) {
           archive.setExitCode(ExtractionControllerConstants.EXIT_CODE_FATAL_ERROR);
         }
       }
       return;
     } catch (ExtractionControllerException e) {
       archive.setExitCode(e.getExitCode());
     } catch (IOException e) {
       archive.setExitCode(ExtractionControllerConstants.EXIT_CODE_FATAL_ERROR);
     }
   } else {
     archive.setExitCode(ExtractionControllerConstants.EXIT_CODE_FATAL_ERROR);
   }
 }
Exemple #3
0
 public DummyArchive checkComplete(Archive archive) throws CheckException {
   if (archive.getSplitType() == splitType) {
     try {
       final DummyArchive ret = new DummyArchive(archive, splitType.name());
       boolean hasMissingArchiveFiles = false;
       for (ArchiveFile archiveFile : archive.getArchiveFiles()) {
         if (archiveFile instanceof MissingArchiveFile) {
           hasMissingArchiveFiles = true;
         }
         ret.add(new DummyArchiveFile(archiveFile));
       }
       if (hasMissingArchiveFiles == false) {
         final ArchiveFile firstFile = archive.getArchiveFiles().get(0);
         final String firstArchiveFile = firstFile.getFilePath();
         final String partNumberOfFirstArchiveFile =
             splitType.getPartNumberString(firstArchiveFile);
         if (splitType.getFirstPartIndex()
             != splitType.getPartNumber(partNumberOfFirstArchiveFile)) {
           throw new CheckException(
               "Wrong firstArchiveFile("
                   + firstArchiveFile
                   + ") for Archive("
                   + archive.getName()
                   + ")");
         }
         if (firstFile.exists()) {
           final String signature =
               JDHexUtils.toString(FileSignatures.readFileSignature(new File(firstArchiveFile)));
           if (new Regex(signature, "^[\\w]{3}  \\d{3}").matches()) {
             /** cutkiller header: extension and number of files */
             final String numberOfPartsString =
                 new Regex(signature, "^[\\w]{3}  (\\d{3})").getMatch(0);
             final int numberOfParts = Integer.parseInt(numberOfPartsString);
             final List<ArchiveFile> missingArchiveFiles =
                 SplitType.getMissingArchiveFiles(archive, splitType, numberOfParts);
             if (missingArchiveFiles != null) {
               for (ArchiveFile missingArchiveFile : missingArchiveFiles) {
                 ret.add(new DummyArchiveFile(missingArchiveFile));
               }
             }
             if (ret.getSize() < numberOfParts) {
               throw new CheckException(
                   "Missing archiveParts("
                       + numberOfParts
                       + "!="
                       + ret.getSize()
                       + ") for Archive("
                       + archive.getName()
                       + ")");
             } else if (ret.getSize() > numberOfParts) {
               throw new CheckException(
                   "Too many archiveParts("
                       + numberOfParts
                       + "!="
                       + ret.getSize()
                       + ") for Archive("
                       + archive.getName()
                       + ")");
             }
           }
         }
       }
       return ret;
     } catch (CheckException e) {
       throw e;
     } catch (Throwable e) {
       throw new CheckException("Cannot check Archive(" + archive.getName() + ")", e);
     }
   }
   return null;
 }