Changeset 9942


Ignore:
Timestamp:
2005-05-24T16:39:35+12:00 (19 years ago)
Author:
davidb
Message:

Modifications to handling of zip files.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/GathererApplet.java

    r9896 r9942  
    144144
    145145    Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator;
     146    Utility.TMP_DIR = Utility.BASE_DIR + "tmp" + File.separator;
    146147
    147148    Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
     
    293294
    294295        dl_dbis.close();
     296        dl_bis.close();
     297        dl_is.close();
     298
    295299        zip_bfos.close();
     300        zip_fos.close();
    296301
    297302    }
     
    399404        dos.flush();
    400405        dos.close();
    401        
    402        
     406
     407        // delete zip file
     408        boolean file_deleted = file.delete();
     409        if (file_deleted) {
     410        System.err.println("Zip file " + file.toString() + " deleted");
     411        }
     412        else {
     413        System.err.println("Zip file " + file.toString() + " NOT deleted");
     414        }
    403415    }
    404416    catch (MalformedURLException ex) {
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r9894 r9942  
    881881
    882882    String zip_fname = col_dir + col_name + ".zip";
    883     int zip_mode = ZipFile.OPEN_READ | ZipFile.OPEN_DELETE;
     883    // int zip_mode = ZipFile.OPEN_READ | ZipFile.OPEN_DELETE;
     884    int zip_mode = ZipFile.OPEN_READ;
    884885
    885886    try {
    886         ZipFile zipfile = new ZipFile(new File(zip_fname), zip_mode);
     887        File cfile = new File(zip_fname);
     888        ZipFile zipfile = new ZipFile(cfile, zip_mode);
    887889       
    888890        Enumeration e = zipfile.entries();
     
    890892        ZipEntry zipentry = (ZipEntry) e.nextElement();
    891893        String zentryname = col_dir + zipentry.getName();
    892         File file = new File(zentryname);
     894        File zfile = new File(zentryname);
    893895        DebugStream.println("    Unzipping: " + zentryname);
    894896
    895897        if (zipentry.isDirectory()) {
    896898            // Create named directory, if it doesn't already exist
    897             if (!file.exists() && !file.mkdirs()) {
    898             System.err.println("Error: unable to create directory " + file);
     899            if (!zfile.exists() && !zfile.mkdirs()) {
     900            System.err.println("Error: unable to create directory " + zfile);
    899901            }
    900902        }
     
    903905
    904906            //Make sure it's parent directory exists.
    905             File dir = new File(file.getParent());
     907            File dir = new File(zfile.getParent());
    906908            dir.mkdirs();
    907909
     
    922924           
    923925            dbzis.close();
     926            bzis.close();
     927            zis.close();
     928
    924929            bfzos.close();
    925         }
    926         }
     930            fzos.close();
     931        }
     932        }
     933
     934        zipfile.close();
     935
     936        // delete zip file
     937        boolean file_deleted = cfile.delete();
     938        if (file_deleted) {
     939        System.err.println("Zip file " + cfile.toString() + " deleted");
     940        }
     941        else {
     942        System.err.println("Zip file " + cfile.toString() + " NOT deleted");
     943        }
     944
     945
    927946    }
    928947    catch (ZipException error) {
Note: See TracChangeset for help on using the changeset viewer.