This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: fastjar on Windows
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Subject: Patch: fastjar on Windows
- From: Tom Tromey <tromey at redhat dot com>
- Date: 04 Jul 2001 12:54:33 -0600
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>
- Reply-To: tromey at redhat dot com
I'm checking this in to the trunk. It changes fastjar to use O_BINARY
when available. This is important for using fastjar on Windows.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
Modified from patch by Julian Hall <jules@acris.co.uk>:
* jartool.c (errno): Conditionally declare.
(O_BINARY): Conditionally define.
(main): Use open, not creat. Use O_BINARY everywhere.
(make_manifest): Use O_BINARY.
(add_to_jar): Likewise.
Index: jartool.c
===================================================================
RCS file: /cvs/gcc/gcc/fastjar/jartool.c,v
retrieving revision 1.5
diff -u -r1.5 jartool.c
--- jartool.c 2001/05/03 21:40:47 1.5
+++ jartool.c 2001/07/04 18:32:24
@@ -212,8 +212,14 @@
static char version_string[] = VERSION;
+#ifndef errno
extern int errno;
+#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
void usage(const char*);
void add_entry(struct zipentry *);
void init_headers(void);
@@ -370,8 +376,9 @@
/* create the jarfile */
if(action == ACTION_CREATE){
if(file){
- jarfd = creat(jarfile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
+ jarfd = open(jarfile, O_CREAT | O_BINARY | O_WRONLY | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
if(jarfd < 0){
fprintf(stderr, "Error opening %s for writing!\n", jarfile);
perror(jarfile);
@@ -395,7 +402,7 @@
} else if(action == ACTION_LIST || action == ACTION_EXTRACT){
if(file){
- jarfd = open(jarfile, O_RDONLY);
+ jarfd = open(jarfile, O_RDONLY | O_BINARY);
if(jarfd < 0){
fprintf(stderr, "Error opening %s for reading!\n", jarfile);
@@ -417,7 +424,7 @@
init_headers();
if((action == ACTION_UPDATE) && file) {
- if((jarfd = open(jarfile, O_RDWR)) < 0) {
+ if((jarfd = open(jarfile, O_RDWR | O_BINARY)) < 0) {
fprintf(stderr, "Error opening %s for reading!\n", jarfile);
perror(jarfile);
exit(1);
@@ -728,7 +735,7 @@
exit(1);
}
- mfd = open(mf_name, O_RDONLY);
+ mfd = open(mf_name, O_RDONLY | O_BINARY);
if(mfd < 0){
fprintf(stderr, "Error opening %s.\n", mf_name);
@@ -874,7 +881,7 @@
} else if(S_ISREG(statbuf.st_mode)){
int add_fd;
- add_fd = open(file, O_RDONLY);
+ add_fd = open(file, O_RDONLY | O_BINARY);
if(add_fd < 0){
fprintf(stderr, "Error opening %s.\n", file);
return 0;