Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / java / win32-host.c
bloba6e5309b105ece5bf902027c6583e5eaed1addcd
1 /* Platform-Specific Win32 Functions
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Java and all Java-based marks are trademarks or registered trademarks
22 of Sun Microsystems, Inc. in the United States and other countries.
23 The Free Software Foundation is independent of Sun Microsystems, Inc. */
25 /* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "jcf.h"
33 #ifdef WIN32
35 #define WIN32_LEAN_AND_MEAN
36 #include <windows.h>
37 #undef WIN32_LEAN_AND_MEAN
39 /* Simulate an open() failure with ENOENT */
40 static int
41 file_not_found (void);
43 static int
44 file_not_found (void)
46 errno = ENOENT;
47 return -1;
50 int
51 jcf_open_exact_case (const char *filename, int oflag)
53 int filename_len = strlen (filename);
54 int found_file_len;
55 HANDLE found_file_handle;
56 WIN32_FIND_DATA fd;
58 /* See if we can find this file. */
59 found_file_handle = FindFirstFile (filename, &fd);
60 if (found_file_handle == INVALID_HANDLE_VALUE)
61 return file_not_found ();
62 FindClose (found_file_handle);
64 found_file_len = strlen (fd.cFileName);
66 /* This should never happen. */
67 if (found_file_len > filename_len)
68 return file_not_found ();
70 /* Here, we're only actually comparing the filename and not
71 checking the case of any containing directory components.
72 Although we're not fully obeying our contract, checking
73 all directory components would be tedious and time-consuming
74 and it's a pretty safe assumption that mixed-case package
75 names are a fringe case.... */
76 if (strcmp (filename + filename_len - found_file_len, fd.cFileName))
78 /* Reject this because it is not a perfect-case match. */
79 /* printf("************\nRejected:\n%s\n%s\n************\n\n", filename, fd.cFileName); */
80 return file_not_found ();
82 else
84 return open (filename, oflag);
88 #endif /* WIN32 */