Here you can find the source of isZip64EndOfCentralDirectoryLocatorPresent(RandomAccessFile zip, long zipEndOfCentralDirectoryPosition)
Parameter | Description |
---|---|
zipEndOfCentralDirectoryPosition | offset of the ZIP End of Central Directory record in the file. |
Parameter | Description |
---|---|
IOException | if an I/O error occurs while reading the file. |
static final boolean isZip64EndOfCentralDirectoryLocatorPresent(RandomAccessFile zip, long zipEndOfCentralDirectoryPosition) throws IOException
//package com.java2s; /*//from ww w .j a v a 2 s . c om * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.IOException; import java.io.RandomAccessFile; public class Main { private static final int ZIP64_EOCD_LOCATOR_SIZE = 20; private static final int ZIP64_EOCD_LOCATOR_SIG_REVERSE_BYTE_ORDER = 0x504b0607; /** * Returns {@code true} if the provided file contains a ZIP64 End of Central Directory * Locator. * * @param zipEndOfCentralDirectoryPosition offset of the ZIP End of Central Directory record * in the file. * * @throws IOException if an I/O error occurs while reading the file. */ static final boolean isZip64EndOfCentralDirectoryLocatorPresent(RandomAccessFile zip, long zipEndOfCentralDirectoryPosition) throws IOException { // ZIP64 End of Central Directory Locator immediately precedes the ZIP End of Central // Directory Record. long locatorPosition = zipEndOfCentralDirectoryPosition - ZIP64_EOCD_LOCATOR_SIZE; if (locatorPosition < 0) { return false; } zip.seek(locatorPosition); // RandomAccessFile.readInt assumes big-endian byte order, but ZIP format uses // little-endian. return zip.readInt() == ZIP64_EOCD_LOCATOR_SIG_REVERSE_BYTE_ORDER; } }