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)
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, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, 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. */
30 #include "coretypes.h"
35 #define WIN32_LEAN_AND_MEAN
37 #undef WIN32_LEAN_AND_MEAN
39 /* Simulate an open() failure with ENOENT */
41 file_not_found (void);
51 jcf_open_exact_case (const char *filename
, int oflag
)
53 int filename_len
= strlen (filename
);
55 HANDLE found_file_handle
;
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 ();
84 return open (filename
, oflag
);