OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [java/] [win32-host.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Platform-Specific Win32 Functions
2
   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
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.
10
 
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.
15
 
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.
20
 
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.  */
24
 
25
/* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */
26
 
27
 
28
#include "config.h"
29
#include "system.h"
30
#include "coretypes.h"
31
#include "jcf.h"
32
 
33
#ifdef WIN32
34
 
35
#define WIN32_LEAN_AND_MEAN
36
#include <windows.h>
37
#undef WIN32_LEAN_AND_MEAN
38
 
39
/* Simulate an open() failure with ENOENT */
40
static int
41
file_not_found (void);
42
 
43
static int
44
file_not_found (void)
45
{
46
  errno = ENOENT;
47
  return -1;
48
}
49
 
50
int
51
jcf_open_exact_case (const char *filename, int oflag)
52
{
53
  int filename_len = strlen (filename);
54
  int found_file_len;
55
  HANDLE found_file_handle;
56
  WIN32_FIND_DATA fd;
57
 
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);
63
 
64
  found_file_len = strlen (fd.cFileName);
65
 
66
  /* This should never happen. */
67
  if (found_file_len > filename_len)
68
    return file_not_found ();
69
 
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))
77
    {
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 ();
81
    }
82
  else
83
    {
84
      return open (filename, oflag);
85
    }
86
}
87
 
88
#endif /* WIN32 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.