MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / create

Method create

ij/src/main/java/ij/astro/io/FitsReader.java:102–124  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

100 }
101
102 public static FitsReader create(String path) throws IOException {
103 OpenDialog od = new OpenDialog("Open FITS...", path);
104 var directory = od.getDirectory();
105 var fileName = od.getFileName();
106 if (fileName == null) {
107 throw new FitsException("Null filename.");
108 }
109
110 IJ.showStatus("Opening: " + directory + fileName);
111
112 if (isFileWithinZip(path)) {
113 var s = path.split("\\.zip");
114
115 try (var zip = new ZipFile(s[0] + ".zip")) {
116 var m = new ProgressMonitorInputStream(IJ.getInstance(),
117 "Reading FITS image", zip.getInputStream(zip.getEntry(s[1].substring(1))));
118 FitsFactory.setAllowHeaderRepairs(true);
119 return new FitsReader(new Fits(m), directory, fileName);
120 }
121 }
122
123 return new FitsReader(Path.of(path), directory, fileName);
124 }
125
126 private static boolean isFileWithinZip(String path) {
127 if (path.contains(".zip")) {

Callers 3

runMethod · 0.95
AIJStartupHandlerClass · 0.95
paintIconMethod · 0.45

Calls 9

getDirectoryMethod · 0.95
getFileNameMethod · 0.95
showStatusMethod · 0.95
isFileWithinZipMethod · 0.95
getInstanceMethod · 0.95
setAllowHeaderRepairsMethod · 0.95
substringMethod · 0.80
splitMethod · 0.45
getInputStreamMethod · 0.45

Tested by

no test coverage detected