1 /*
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
676 return false;
677 }
678 nameBuf[k++] = args[i];
679 }
680 }
681 } catch (ArrayIndexOutOfBoundsException e) {
682 usageError(getMsg("error.bad.file.arg"));
683 return false;
684 }
685 // associate remaining files, if any, with a version
686 if (k > 0) {
687 String[] files = new String[k];
688 System.arraycopy(nameBuf, 0, files, 0, k);
689 filesMap.put(version, files);
690 isMultiRelease = version > BASE_VERSION;
691 }
692 } else if (cflag && (mname == null)) {
693 usageError(getMsg("error.bad.cflag"));
694 return false;
695 } else if (uflag) {
696 if ((mname != null) || (ename != null)) {
697 /* just want to update the manifest */
698 return true;
699 } else {
700 usageError(getMsg("error.bad.uflag"));
701 return false;
702 }
703 }
704 return true;
705 }
706
707 /*
708 * Add the package of the given resource name if it's a .class
709 * or a resource in a named package.
710 */
711 void addPackageIfNamed(Set<String> packages, String name) {
712 if (name.startsWith(VERSIONS_DIR)) {
713 // trim the version dir prefix
714 int i0 = VERSIONS_DIR_LENGTH;
715 int i = name.indexOf('/', i0);
716 if (i <= 0) {
|
1 /*
2 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
676 return false;
677 }
678 nameBuf[k++] = args[i];
679 }
680 }
681 } catch (ArrayIndexOutOfBoundsException e) {
682 usageError(getMsg("error.bad.file.arg"));
683 return false;
684 }
685 // associate remaining files, if any, with a version
686 if (k > 0) {
687 String[] files = new String[k];
688 System.arraycopy(nameBuf, 0, files, 0, k);
689 filesMap.put(version, files);
690 isMultiRelease = version > BASE_VERSION;
691 }
692 } else if (cflag && (mname == null)) {
693 usageError(getMsg("error.bad.cflag"));
694 return false;
695 } else if (uflag) {
696 if ((mname != null) || (ename != null) || moduleVersion != null) {
697 /* just want to update the manifest */
698 return true;
699 } else {
700 usageError(getMsg("error.bad.uflag"));
701 return false;
702 }
703 }
704 return true;
705 }
706
707 /*
708 * Add the package of the given resource name if it's a .class
709 * or a resource in a named package.
710 */
711 void addPackageIfNamed(Set<String> packages, String name) {
712 if (name.startsWith(VERSIONS_DIR)) {
713 // trim the version dir prefix
714 int i0 = VERSIONS_DIR_LENGTH;
715 int i = name.indexOf('/', i0);
716 if (i <= 0) {
|