1/* Copyright (C) 2021 Free Software Foundation, Inc.
2   Contributed by Oracle.
3
4   This file is part of GNU Binutils.
5
6   This program 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 3, or (at your option)
9   any later version.
10
11   This program 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 this program; if not, write to the Free Software
18   Foundation, 51 Franklin Street - Fifth Floor, Boston,
19   MA 02110-1301, USA.  */
20
21#ifndef _DBE_FILE_H
22#define _DBE_FILE_H
23
24#include <fcntl.h>
25
26class DbeJarFile;
27class Experiment;
28template <class ITEM> class Vector;
29
30class DbeFile
31{
32public:
33
34  enum
35  {
36    F_NOT_FOUND     = 0,
37    F_FICTION       = 1,
38    F_LOADOBJ       = 2,
39    F_SOURCE        = 4,
40    F_JAVACLASS     = 8,
41    F_JAVA_SOURCE   = 16,
42    F_DOT_O         = 32,
43    F_DEBUG_FILE    = 64,
44    F_DOT_A_LIB     = 128,
45    F_DIR_OR_JAR    = 256,
46    F_DIRECTORY     = 512,
47    F_FILE          = 1024,
48    F_JAR_FILE      = 2048,
49    F_UNKNOWN       = 65536
50  };
51
52  DbeFile (const char *filename);
53  ~DbeFile ();
54
55  char *
56  get_name ()
57  {
58    return name;
59  };
60
61  bool
62  get_need_refind ()
63  {
64    return need_refind;
65  };
66
67  char *get_location (bool find_needed = true);
68  char *getResolvedPath ();
69  char *get_location_info ();
70  struct stat64 *get_stat ();
71  bool compare (DbeFile *df);
72  void set_need_refind (bool val);
73  void set_location (const char *filename);
74  int check_access (const char *filename);
75  char *find_file (const char *filename);
76  DbeFile *getJarDbeFile (char *fnm, int sym);
77  char *find_in_jar_file (const char *filename, DbeJarFile *jfile);
78  DbeJarFile *get_jar_file ();
79
80  bool inArchive;
81  int filetype;
82  struct stat64 sbuf;
83  DbeFile *container;
84  char *orig_location;
85  Experiment *experiment;
86
87protected:
88  static bool isJarOrZip (const char *fnm);
89  char *find_package_name (const char *filename, const char *dirname);
90  char *find_in_directory (const char *filename, const char *dirname);
91  bool find_in_pathmap (char *filename);
92  void find_in_archives (char *filename);
93  void find_in_setpath (char *filename, Vector<char*> *searchPath);
94  void find_in_classpath (char *filename, Vector<DbeFile*> *classPath);
95
96  char *name;
97  char *location;
98  char *location_info;
99  bool need_refind;
100  DbeJarFile *jarFile;
101};
102
103#endif /* _DBE_FILE_H */
104