Logo Search packages:      
Sourcecode: jlha-utils version File versions  Download package

void org::jlhafrontend::JLHAFrontEnd::add ( Opts  useropts,
String  archiveFilename,
String[]  filesFilename 
) [inline]

execute add command

Parameters:
useropts Options input by users
archiveFilename the filename of the archive file
filesFilename the array of filenames to be extracted

Definition at line 443 of file JLHAFrontEnd.java.

References create(), createSwitcher(), genListArray(), list(), mkbackup(), mylogger, and transferBackupToArchive().

                                                                                   {
      String[] list;
      int i=0;
      File fl=null;
      String backupFilename=null;
      LhaFile backupFile=null;
      LhaOutputStream lio=null;

      /* open archive file */
      try {
          fl = (new File(archiveFilename));
      } catch (Exception e) {
          mylogger.warning("Open "+archiveFilename+" error:"+e.toString());
          return;
      }

      /* if the file is not exist, call create */
      try {
          if (!fl.exists()) {
            create(useropts,archiveFilename,filesFilename);
            return;
          }
      } catch (SecurityException e) {
          mylogger.severe("Cannot test exist");
          return;
      }


      /* make backup */
      backupFilename = mkbackup(archiveFilename);

      /* open new archive file */
      try {
          lio = new LhaOutputStream(new FileOutputStream(archiveFilename));
      } catch (Exception e) {
          mylogger.severe("new LhaImeediateOutputStream with "+archiveFilename+" error: "+e.toString());
          return;
      }

      /* generate list */
      list = genListArray(filesFilename);

      /* open backup file */
      try {
          backupFile = new LhaFile (new File(backupFilename));
      } catch (FileNotFoundException e) {
          System.err.println("LHa: Fatal error: "+archiveFilename+": No such file or directory");
          return;
      } catch (Exception e) {
          mylogger.warning("Open "+archiveFilename+" error:"+e.toString());             System.err.println("LHa: Warning: Checksum error (LHarc file?)");
          System.err.println("LHa: Fatal error: Unkonwn header (lha file?)");
          return;
      }

      transferBackupToArchive(backupFile,lio,list);

      /* compress new entries */
      for (i=0 ; i<filesFilename.length ; i++) {
          createSwitcher(useropts,lio,filesFilename[i]);
      }
      try {
          lio.close();
      } catch (IOException e) {
          mylogger.severe("lio.close() "+e.toString());
      }
      try {
          backupFile.close();
      } catch (IOException e) {
          mylogger.severe("backupFile.close() "+e.toString());
      }

    }


Generated by  Doxygen 1.6.0   Back to index