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

void org::jlhafrontend::JLHAFrontEnd::createDirectory ( Opts  useropts,
LhaOutputStream  lio,
String  dirname 
) [inline]

compress a directory into a LhaOutputStream

Parameters:
useropts Options input by users
lio the LhaOutputStream for an archive file
filename the directory need to be compressed

Definition at line 1461 of file JLHAFrontEnd.java.

References addFileSeparator(), createSwitcher(), org::jlhafrontend::Opts::getDeleteFiles(), and mylogger.

Referenced by createSwitcher().

                                                                                   {
      File fl=null;
      File[] listfiles=null;
      String prefix=null;
      int i;
      LhaHeader header;
      boolean deleteFiles=false;

      deleteFiles=useropts.getDeleteFiles();

      prefix = addFileSeparator(dirname);

      try {
          fl = new File(dirname);
      } catch (Exception e) {
          mylogger.severe("new File error: "+e.toString());
          return;
      }
      /* add -lhd- record */
      header = new LhaHeader(prefix);
      header.setCompressMethod(CompressMethod.LHD);
      header.setLastModified( new Date( fl.lastModified() ) );
      header.setOSID((byte)0);
      header.setOriginalSize(0);
      try {
          lio.putNextEntry( header );
      } catch (IOException e) {
          mylogger.severe("putNextEntry error: "+e.toString());
      }
      try {
          lio.closeEntry();
      } catch (IOException e) {
          mylogger.warning("lio.closeEntry: "+e.toString());
      }
      try {
          listfiles = fl.listFiles();
      } catch (Exception e) {
          mylogger.warning("open dir \""+dirname+"\" error: "+e.toString());
          return;
      }
      for (i=0 ; i<listfiles.length ; i++) {
          createSwitcher(useropts,lio, new String(prefix+listfiles[i].getName()));
      }
      if (deleteFiles) {
          try {
            fl.delete();
          } catch (Exception e) {
            mylogger.warning("cannot remove directory "+fl.getAbsolutePath()+" : "+e.toString());
          }
      }
    }


Generated by  Doxygen 1.6.0   Back to index