aboutsummaryrefslogtreecommitdiff
path: root/gprofng/src/DbeFile.h
blob: abd7180dc753d09230fd8f368927b760a8182005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Copyright (C) 2021 Free Software Foundation, Inc.
   Contributed by Oracle.

   This file is part of GNU Binutils.

   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 3, 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 this program; if not, write to the Free Software
   Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

#ifndef _DBE_FILE_H
#define _DBE_FILE_H

#include <fcntl.h>

class DbeJarFile;
class Experiment;
template <class ITEM> class Vector;

class DbeFile
{
public:

  enum
  {
    F_NOT_FOUND     = 0,
    F_FICTION       = 1,
    F_LOADOBJ       = 2,
    F_SOURCE        = 4,
    F_JAVACLASS     = 8,
    F_JAVA_SOURCE   = 16,
    F_DOT_O         = 32,
    F_DEBUG_FILE    = 64,
    F_DOT_A_LIB     = 128,
    F_DIR_OR_JAR    = 256,
    F_DIRECTORY     = 512,
    F_FILE          = 1024,
    F_JAR_FILE      = 2048,
    F_UNKNOWN       = 65536
  };

  DbeFile (const char *filename);
  ~DbeFile ();

  char *
  get_name ()
  {
    return name;
  };

  bool
  get_need_refind ()
  {
    return need_refind;
  };

  char *get_location (bool find_needed = true);
  char *getResolvedPath ();
  char *get_location_info ();
  struct stat64 *get_stat ();
  bool compare (DbeFile *df);
  void set_need_refind (bool val);
  void set_location (const char *filename);
  int check_access (const char *filename);
  char *find_file (const char *filename);
  DbeFile *getJarDbeFile (char *fnm, int sym);
  char *find_in_jar_file (const char *filename, DbeJarFile *jfile);
  DbeJarFile *get_jar_file ();

  bool inArchive;
  int filetype;
  struct stat64 sbuf;
  DbeFile *container;
  char *orig_location;
  Experiment *experiment;

protected:
  static bool isJarOrZip (const char *fnm);
  char *find_package_name (const char *filename, const char *dirname);
  char *find_in_directory (const char *filename, const char *dirname);
  bool find_in_pathmap (char *filename);
  void find_in_archives (char *filename);
  void find_in_setpath (char *filename, Vector<char*> *searchPath);
  void find_in_classpath (char *filename, Vector<DbeFile*> *classPath);

  char *name;
  char *location;
  char *location_info;
  bool need_refind;
  DbeJarFile *jarFile;
};

#endif /* _DBE_FILE_H */