@@ -36,7 +36,7 @@ public final class PciIds {
36
36
/**
37
37
* Name of pciids file in code.
38
38
*/
39
- private static final String PCIIDS_FILENAME = "pci.ids" ;
39
+ private static final String PCIIDS_FILENAME = "/ pci.ids" ;
40
40
41
41
/**
42
42
* This pci ids file can be in different places on different distributions.
@@ -65,6 +65,8 @@ public final class PciIds {
65
65
//Configure the PCI IDs Database object.
66
66
static {
67
67
if (!DB .isReady ()) {
68
+
69
+ // if pciids file is found on the system, then process using this
68
70
String dbFile = null ;
69
71
for (final String path : PCI_IDS_PATH ) {
70
72
if ((new File (path )).exists ()) {
@@ -73,21 +75,13 @@ public final class PciIds {
73
75
break ;
74
76
}
75
77
}
76
- // if pciids file is not found on the system, then attempt to grab it from code
78
+
77
79
if (dbFile != null ) {
78
- pciidsFileStatus = UefiConstants .FILESTATUS_FROM_FILESYSTEM ;
79
- }
80
- else {
81
- dbFile = PciIds .class .getResource (PCIIDS_FILENAME ).getPath ();
82
- }
83
- if (dbFile != null ) {
84
- if (!pciidsFileStatus .equals (UefiConstants .FILESTATUS_FROM_FILESYSTEM )) {
85
- pciidsFileStatus = UefiConstants .FILESTATUS_FROM_CODE ;
86
- }
87
80
InputStream is = null ;
88
81
try {
89
82
is = new FileInputStream (new File (dbFile ));
90
83
DB .loadStream (is );
84
+ pciidsFileStatus = UefiConstants .FILESTATUS_FROM_FILESYSTEM ;
91
85
} catch (IOException e ) {
92
86
// DB will not be ready, hardware IDs will not be translated
93
87
dbFile = null ;
@@ -101,8 +95,28 @@ public final class PciIds {
101
95
}
102
96
}
103
97
}
104
- else {
105
- log .info ("PCI IDs file was NOT found" );
98
+
99
+ // if pciids file is not found on the system or not accessible, then attempt to grab it from code
100
+ if (pciidsFileStatus == UefiConstants .FILESTATUS_NOT_ACCESSIBLE ) {
101
+ InputStream istemp = PciIds .class .getResourceAsStream (PCIIDS_FILENAME );
102
+ try {
103
+ DB .loadStream (istemp );
104
+ pciidsFileStatus = UefiConstants .FILESTATUS_FROM_CODE ;
105
+ } catch (IOException e ) {
106
+ // DB will not be ready, hardware IDs will not be translated
107
+ } finally {
108
+ if (istemp != null ) {
109
+ try {
110
+ istemp .close ();
111
+ } catch (IOException e ) {
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ // if pciids file is not accessible on system or from within code, then log error
118
+ if (pciidsFileStatus == UefiConstants .FILESTATUS_NOT_ACCESSIBLE ) {
119
+ log .info ("PCI IDs file was NOT accessible from within the system or within the code" );
106
120
}
107
121
}
108
122
}
0 commit comments