diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-10 18:24:42 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-10 18:24:42 +0000 |
commit | a1b2d596c5e1b82621145fadb4714ec4d6a56701 (patch) | |
tree | 98f513bd1a000a4d78b65f788485eb0f3dd32eeb /gcc/java/win32-host.c | |
parent | d2cfc12473c22b1289f6326d978474cc5700589e (diff) | |
download | gcc-a1b2d596c5e1b82621145fadb4714ec4d6a56701.tar.gz |
2003-03-16 Mohan Embar <gnustuff@thisiscool.com>
* Make-lang.in: added win32-host.c
* jcf.h: defined macro JCF_OPEN_EXACT_CASE which
resolves to open() on non-Win32 platforms and
Win32-specific jcf_open_exact_case() on Win32
* jcf-io.c (find_class): use JCF_OPEN_EXACT_CASE
when trying .java and .class files
* win32-host.c: added to repository. Defines
Win32-specific jcf_open_exact_case()
2003-04-10 Andrew Haley <aph@redhat.com>
* jcf-write.c (struct jcf_partial): num_jsrs: new field.
(maybe_free_localvar): Renamed from localvar_free.
Add new arg, really.
(generate_bytecode_insns): Set new variable, jsrs.
Only free local vars if no jsr insns have been emittted.
Call maybe_free_localvar, not localvar_free.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65430 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/win32-host.c')
-rw-r--r-- | gcc/java/win32-host.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/java/win32-host.c b/gcc/java/win32-host.c new file mode 100644 index 00000000000..7ab8fa53f96 --- /dev/null +++ b/gcc/java/win32-host.c @@ -0,0 +1,85 @@ +/* Platform-Specific Win32 Functions + Copyright (C) 2003 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */ + +#ifdef WIN32 + +#include "config.h" +#include "system.h" + +#include "jcf.h" + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN + +/* Simulate an open() failure with ENOENT */ +static int +file_not_found (void); + +static int +file_not_found (void) +{ + errno = ENOENT; + return -1; +} + +int +jcf_open_exact_case (const char *filename, int oflag) +{ + int filename_len = strlen (filename); + int found_file_len; + HANDLE found_file_handle; + WIN32_FIND_DATA fd; + + /* See if we can find this file. */ + found_file_handle = FindFirstFile (filename, &fd); + if (found_file_handle == INVALID_HANDLE_VALUE) + return file_not_found (); + FindClose (found_file_handle); + + found_file_len = strlen (fd.cFileName); + + /* This should never happen. */ + if (found_file_len > filename_len) + return file_not_found (); + + /* Here, we're only actually comparing the filename and not + checking the case of any containing directory components. + Although we're not fully obeying our contract, checking + all directory components would be tedious and time-consuming + and it's a pretty safe assumption that mixed-case package + names are a fringe case.... */ + if (strcmp (filename + filename_len - found_file_len, fd.cFileName)) + { + /* Reject this because it is not a perfect-case match. */ + /* printf("************\nRejected:\n%s\n%s\n************\n\n", filename, fd.cFileName); */ + return file_not_found (); + } + else + { + return open (filename, oflag); + } +} + +#endif /* WIN32 */ |