boolean exists = true;
    protected boolean parseToc(BinaryFile binFile) {        RpfTocEntry entry;        RpfFrameEntry frame;        int n, pathLength; // ushort        int i, j, k, currentPosition;        int boundaryId, frameRow, frameCol; // ushort        long numFrameIndexRecords; // uint # frame file index records        // DKS new        long pathOffset; // uint, offset of frame file pathname        int boundaryRecordLength; // ushort        int numPathnameRecords; //ushort        int indexRecordLength; //ushort, frame file index record                               // length        int indexSubheaderLength = 9; //ushort, frame file index                                      // subheader length        long boundRectTableOffset; // uint, Bound. rect. table offset        long frameIndexTableOffset; // uint, Frame file index table                                    // offset        if (DEBUG_RPFTOC) {            Debug.output("ENTER TOC parsing...");        }        boolean local = false;        if (binFile.getInputReader() instanceof FileInputReader) {            local = true;        }        try {            // binFile should be set to the beginning at this point            binFile.seek(0);            // Read header            head = new RpfHeader();            if (!head.read(binFile))                return false;            if (DEBUG_RPFTOC) {                Debug.output("RpfTocHandler.parseToc: read header:\n" + head);            }            binFile.seek(head.locationSectionLocation);            RpfFileSections rfs = new RpfFileSections(binFile);            // Everything must be OK to reach here...            // DKS. fseek to start of location section: 48            // DFD not necessarily 48! New A.TOCs are different.            RpfFileSections.RpfLocationRecord[] locations = rfs.getLocations(RpfFileSections.TOC_LOCATION_KEY);            // Read boundary rectangles            // Number of Boundary records            // DKS: now phys_index, not index            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): fseek to Boundary section subheader: "                        + locations[0].componentLocation);            }            binFile.seek(locations[0].componentLocation);            // NEW            boundRectTableOffset = (long) binFile.readInteger();            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): BoundRectTableOffset: "                        + boundRectTableOffset);            }            n = (int) binFile.readShort();            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): # Boundary rect. recs: "                        + n);            }            numBoundaries = n;            // DKS new            // Boundary record length            boundaryRecordLength = (int) binFile.readShort();            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): should be 132: "                        + boundaryRecordLength);            }            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): fseek to Boundary Rectangle Table: "                        + locations[1].componentLocation);            }            binFile.seek(locations[1].componentLocation);            entries = new RpfTocEntry[numBoundaries];            // Read Boundary rectangle records            for (i = 0; i < n; i++) {                if (DEBUG_RPFTOCDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): read boundary rec#: "                            + i);                }                // All this stuff moved to RpfTocEntry.java - DFD                // 8/18/99                entries[i] = new RpfTocEntry(binFile, tocNumber, i);                if (DEBUG_RPFTOCDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): entry " + i                            + " has scale " + entries[i].scale + ", type "                            + (entries[i].Cib ? "CIB" : "CADRG") + " in zone "                            + entries[i].zone);                    if (entries[i].Cib)                        Debug.output("RpfTocHandler: parseToc(): entry noted as a Cib entry.");                }            }            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): Read frame file index section subheader at loc: "                        + locations[2].componentLocation);            }            // Read # of frame file index records            // Skip 1 byte security classification            // locations[2] is loc of frame file index section            // subheader            binFile.seek(locations[2].componentLocation + 1);            // NEW            frameIndexTableOffset = (long) binFile.readInteger();            numFrameIndexRecords = (long) binFile.readInteger();            numPathnameRecords = (int) binFile.readShort();            // indexRecordLength should now be 33, not 35            indexRecordLength = (int) binFile.readShort();            if (DEBUG_RPFTOCDETAIL) {                Debug.output("RpfTocHandler: parseToc(): frameIndexTableOffset: "                        + frameIndexTableOffset);                Debug.output("RpfTocHandler: parseToc(): # Frame file index recs: "                        + numFrameIndexRecords);                Debug.output("RpfTocHandler: parseToc(): # pathname records: "                        + numPathnameRecords);                Debug.output("RpfTocHandler: parseToc(): Index rec len(33): "                        + indexRecordLength);            }            // Read frame file index records            for (i = 0; i < numFrameIndexRecords; i++) {                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): Read frame file index rec #: "                            + i);                }                // Index_subhdr_len (9) instead of table_offset (11)                // indexRecordLength (33) instead of 35                // componentLocation, not index                // locations[3] is frame file index table subsection                binFile.seek(locations[3].componentLocation + indexRecordLength                        * i);                boundaryId = (int) binFile.readShort();                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("boundary id for frame: " + i + " is "                            + boundaryId);                }                // DKS NEW: changed from 1 to 0 to agree w/ spec. -1                // added also.                // if (boundaryId < 0 || boundaryId > numBoundaries -                // 1 )                if (boundaryId > numBoundaries - 1) {                    Debug.output("Bad boundary id in FF index record " + i);                    return false;                }                // DKS NEW: -1 removed to match spec                entry = entries[boundaryId];                frameRow = (int) binFile.readShort();                frameCol = (int) binFile.readShort();                // DKS. switched from horizFrames to vertFrames                // DKS NEW: CHANGED FROM 1 to 0 to agree w/spec. ALSO                // COL below                //    if (frameRow < 1 || frameRow > entry->vertFrames)                if (frameRow > entry.vertFrames - 1) {                    Debug.output(" Bad row number: " + frameRow                            + ", in FF index record " + i);                    Debug.output(" Min row num=0;  Max. row num:"                            + (entry.horizFrames - 1));                    return false;                }                // DKS. switched from vertFrames to horizFrames                if (frameCol > entry.horizFrames - 1) {                    Debug.output(" Bad col number in FF index record " + i);                    return false;                }                // DKS NEW: -1 removed on frameRow, col                // JRB                // frame = &entry->frames[frameRow][frameCol];                // [(entry->vertFrames - 1L)-frameRow] flips the array                // over, so that the frames can be referenced                // correctly from the top left, instead of the                // specification notation of bottom left.                frame = entry.frames[(entry.vertFrames - 1) - frameRow][frameCol];                if (frame.exists && DEBUG_RPFTOCDETAIL) {                    Debug.output("FF " + i + " is a duplicate");                }                // DKS: phys_loc deleted                // pathname offset                pathOffset = (long) binFile.readInteger();                // Save file position for later                currentPosition = (int) binFile.getFilePointer();                // Go to start of pathname record                // DKS. New pathOffset offset from start of frame file                // index section of TOC??                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): locations[1].componentLocation: "                            + locations[1].componentLocation);                }                // DKS. Add pathoffset wrt frame file index table                // subsection (loc[3])                binFile.seek(locations[3].componentLocation + pathOffset);                pathLength = (int) binFile.readShort();                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): pathLength:"                            + pathLength);                }                // 1st part of directory name is passed as arg:                // e.g. "../RPF2/"                frame.rpfdir = dir;                StringBuffer sBuf = new StringBuffer();                // read rest of directory name from toc                // DKS: skip 1st 2 chars: "./":                String pathTest = binFile.readFixedLengthString(2);                if (pathTest.equals("./")) {                    fullPathsInATOC = false;                } else {                    fullPathsInATOC = true;                }                if (!fullPathsInATOC) {                    // DKS: Make up for skipped 2 chars                    sBuf.append(binFile.readFixedLengthString(pathLength - 2));                } else {                    sBuf.append(pathTest);                    sBuf.append(binFile.readFixedLengthString(pathLength - 2));                }                // Add the trim because it looks like NIMA doesn't                // always get the pathLength correct...                frame.directory = sBuf.toString().trim();                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): frame directory: "                            + frame.directory);                }                /* Go back to get filename tail */                binFile.seek(currentPosition);                frame.filename = binFile.readFixedLengthString(12);                if (DEBUG_RPFTOCFRAMEDETAIL) {                    Debug.output("RpfTocHandler: parseToc(): frame filename: "                            + frame.filename);                }                // Figure out the chart series ID                int dot = frame.filename.lastIndexOf('.');                // Interned so we can look it up in the catalog                // later...                entry.setInfo(frame.filename.substring(dot + 1, dot + 3)                        .toUpperCase().intern());                // We duplicate this below!!!                //              frame.framePath = new String(frame.rpfdir +                // frame.directory +                //                                           "/" + frame.filename);                // DKS new DCHUM. Fill in last digit v of vv version                // #. fffffvvp.JNz or ffffffvp.IMz for CIB boundaryId                // will equal frame file number: 1 boundary rect. per                // frame.                //              if (Dchum)                //                  entries[boundaryId].version =                // frame.filename.charAt(6);                // do diskspace calculations                String tempPath;                if (!fullPathsInATOC) {                    tempPath = frame.rpfdir + frame.directory + frame.filename;                } else {                    tempPath = frame.directory + frame.filename;                    frame.rpfdir = null; // The path to the rpf dir is                                         // in frame.directory                }                long diskspace = 288000;                boolean exists = true;                // Turns out this check is wicked expensive!!!!!!                // Assume it's there, the RPFFrame has been modified                // to try lower case names if needed.                //                 if (local) {                //                     exists = BinaryFile.exists(tempPath);                //                     // This may fail because of FTP and/or CDROM                // filename                //                     // shinanagins. The A.TOC file should always think                //                     // that the filenames are uppercase. They may get                //                     // copied as lowercase, so we'll check that here.                // If                //                     // they are actually lowercase, we'll change it                // here                //                     // so that everything will work at runtime. - DFD                // 8/20/99                //                     // OK, with the advent of the new BinaryFile that                //                     // will let these files be read from a jar file or                //                     // from a URL, we have to assume that the files                //                     // are there, and deal with it if they are not.                //                 }                //                 if (exists) {                frame.diskspace = diskspace;                frame.framePath = tempPath;                frame.exists = true;                //                 } else if (!fullPathsInATOC) {                //                     // This should only be an issue for local files.                //                     tempPath = frame.rpfdir +                // frame.directory.toLowerCase() +                //                         frame.filename.toLowerCase();                // // if (BinaryFile.exists(tempPath)) {                //                         frame.diskspace = diskspace;                //                         frame.framePath = tempPath;                //                         frame.exists = true;                // // }                //                 }                if (frame.framePath == null) {                    Debug.output("RpfTocHandler: Frame "                            + tempPath                            + " doesn't exist.  Please rebuild A.TOC file using MakeToc, or check read permissions for the file.");                }            } /* for i = numFrameIndexRecords */        } catch (IOException ioe) {            Debug.error("RpfTocHandler: IO ERROR parsing file!\n\t" + ioe);            return false;        } catch (FormatException fe) {            Debug.error("RpfTocHandler: Format ERROR parsing file!\n\t" + fe);            return false;        }        if (DEBUG_RPFTOC) {            Debug.output("LEAVE TOC parsing...");        }        return true;    }