|
@@ -34,8 +34,6 @@ import com.dmdirc.util.resourcemanager.ResourceManager;
|
34
|
34
|
|
35
|
35
|
import java.util.ArrayList;
|
36
|
36
|
import java.util.List;
|
37
|
|
-import java.util.Map;
|
38
|
|
-import java.util.Map.Entry;
|
39
|
37
|
import java.io.File;
|
40
|
38
|
import java.io.IOException;
|
41
|
39
|
|
|
@@ -94,34 +92,6 @@ public class WindowsMediaSourcePlugin extends Plugin implements MediaSourceManag
|
94
|
92
|
return new MediaInfoOutput(-1, "Error executing GetMediaInfo.exe");
|
95
|
93
|
}
|
96
|
94
|
|
97
|
|
- /**
|
98
|
|
- * Use the given resource manager to extract files ending with the given suffix
|
99
|
|
- *
|
100
|
|
- * @param res ResourceManager
|
101
|
|
- * @param newDir Directory to extract to.
|
102
|
|
- * @param suffix Suffix to extract
|
103
|
|
- */
|
104
|
|
- private void extractFiles(final ResourceManager res, final File newDir, final String suffix) {
|
105
|
|
- final Map<String, byte[]> resources = res.getResourcesEndingWithAsBytes(suffix);
|
106
|
|
- for (Entry<String, byte[]> resource : resources.entrySet()) {
|
107
|
|
- try {
|
108
|
|
- final String key = resource.getKey();
|
109
|
|
- final String resourceName = key.substring(key.lastIndexOf('/'), key.length());
|
110
|
|
-
|
111
|
|
- final File newFile = new File(newDir, resourceName);
|
112
|
|
-
|
113
|
|
- if (!newFile.isDirectory()) {
|
114
|
|
- if (newFile.exists()) {
|
115
|
|
- newFile.delete();
|
116
|
|
- }
|
117
|
|
- ResourceManager.getResourceManager().resourceToFile(resource.getValue(), newFile);
|
118
|
|
- }
|
119
|
|
- } catch (IOException ex) {
|
120
|
|
- Logger.userError(ErrorLevel.LOW, "Failed to extract " + suffix + "s for windowsmediasource: " + ex.getMessage(), ex);
|
121
|
|
- }
|
122
|
|
- }
|
123
|
|
- }
|
124
|
|
-
|
125
|
95
|
/** {@inheritDoc} */
|
126
|
96
|
@Override
|
127
|
97
|
public void onLoad() {
|
|
@@ -144,8 +114,12 @@ public class WindowsMediaSourcePlugin extends Plugin implements MediaSourceManag
|
144
|
114
|
}
|
145
|
115
|
|
146
|
116
|
// Now extract the .dlls and .exe
|
147
|
|
- extractFiles(res, newDir, ".dll");
|
148
|
|
- extractFiles(res, newDir, ".exe");
|
|
117
|
+ try {
|
|
118
|
+ res.extractResoucesEndingWith(newDir, ".dll");
|
|
119
|
+ res.extractResoucesEndingWith(newDir, ".exe");
|
|
120
|
+ } catch (IOException ex) {
|
|
121
|
+ Logger.userError(ErrorLevel.MEDIUM, "Unable to extract files for windows media source: " + ex.getMessage(), ex);
|
|
122
|
+ }
|
149
|
123
|
} catch (IOException ioe) {
|
150
|
124
|
Logger.userError(ErrorLevel.LOW, "Unable to open ResourceManager for windowsmediasource: " + ioe.getMessage(), ioe);
|
151
|
125
|
}
|