entry.zipEntryPath = zipEntryPath;
return new MapCSSStyleSource(entry);
}
zipEntryPath = cf.findZipEntryPath("xml", "style");
if (zipEntryPath != null)
return new XmlStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".mapcss"))
return new MapCSSStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".xml"))
return new XmlStyleSource(entry);
else {
try (InputStreamReader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) {
WHILE: while (true) {
int c = reader.read();
switch (c) {
case -1:
break WHILE;
case ' ':
case '\t':
case '\n':
case '\r':
continue;
case '<':
return new XmlStyleSource(entry);
default:
return new MapCSSStyleSource(entry);
}
}
}
Main.warn("Could not detect style type. Using default (xml).");
return new XmlStyleSource(entry);
}
} catch (IOException e) {
Main.warn(tr("Failed to load Mappaint styles from ''{0}''. Exception was: {1}", entry.url, e.toString()));
Main.error(e);
}