protected void read(DataInputStream in) { if (in == null) { err("NO input stream!"); } try { signature = FileUtils.getUInt32(in); if (getSignature() != DAT_HEADER_SIGNATURE) { err( "Signature must be " + Long.toHexString(DAT_HEADER_SIGNATURE) + ", but was " + Long.toHexString(getSignature())); } setVersion(FileUtils.getUInt32(in)); headerSize = FileUtils.getUInt32(in); dataSize = FileUtils.getUInt32(in); if (getVersion() == 4) { header = new PGMAcquisitionRegionHeader(); } else if (getVersion() == 3) { header = new PGMAcquisitionHeader(); } else { err("Unknown header version: " + getVersion()); } header.read(in); // p("read header: "+toString()); } catch (IOException ex) { err("Could not read header info of acquisition", ex); } }
public String createConversionObject(String raw_dir, String cache_dir) { String d = raw_dir; if ((FileUtils.isUrl(d) && !FileUtils.exists(d + "acq_0000.dat")) || (!FileUtils.isUrl(d) && !(new File(d).exists()))) { return "I cannot access the raw directory " + raw_dir + ", please check the path<br>"; } File dir = new File(cache_dir); if (!dir.exists()) { return "I cannot access the cache directory " + dir + ", please check the path<br>"; } if (!dir.canWrite()) { return "I don't have write permssion in the ache directory " + dir + ", please change the path<br>"; } conv = new Conversion[RawType.values().length]; String msg = ""; for (int i = 0; i < RawType.values().length; i++) { RawType rtype = RawType.values()[i]; Conversion con = new Conversion(rtype); conv[i] = con; int nrfiles = RasterIO.getNrFiles(rtype, raw_dir); con.max = nrfiles; // count nr of flows so far RawDataFacade io = RawDataFacade.getFacade(raw_dir, cache_dir, rtype); int nrflowsSoFar = io.getNrFlowsInCache(); if (nrflowsSoFar < 0) { String raw = io.getRawFilePath(rtype, raw_dir, 0); if (raw != null && FileUtils.exists(raw)) { p("I could not find the raw file or url " + raw + " (Myabe it's an old experiment?)<br>"); } // else p("Problem with accessing raw file in " + raw_dir + " for type " + rtype + "<br>"); } con.start = nrflowsSoFar; // the end is between start and nrfiles so far } if (msg != null && msg.length() > 0) { JOptionPane.showMessageDialog(null, "<html>RawFileConverter<br>" + msg + "</html>"); conv = null; return msg; } return null; }
private void initUrl(URL url) { // this.file = file; in = FileUtils.openUrl(url); if (in == null) { err("Could not open url " + url); } readHeader(); }