diff --git a/src/main/java/com/conveyal/gtfs/loader/Table.java b/src/main/java/com/conveyal/gtfs/loader/Table.java index c131ef5c..2f778c15 100644 --- a/src/main/java/com/conveyal/gtfs/loader/Table.java +++ b/src/main/java/com/conveyal/gtfs/loader/Table.java @@ -46,6 +46,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -782,7 +783,7 @@ public CsvReader getCsvReader(ZipFile zipFile, SQLErrorStorage sqlErrorStorage) Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry e = entries.nextElement(); - if (e.getName().endsWith(tableFileName)) { + if (Paths.get(e.getName()).getFileName().toString().equals(tableFileName)) { entry = e; if (sqlErrorStorage != null) sqlErrorStorage.storeError(NewGTFSError.forTable(this, TABLE_IN_SUBDIRECTORY)); break; diff --git a/src/main/java/com/conveyal/gtfs/model/Entity.java b/src/main/java/com/conveyal/gtfs/model/Entity.java index c6810ea2..20ba9248 100644 --- a/src/main/java/com/conveyal/gtfs/model/Entity.java +++ b/src/main/java/com/conveyal/gtfs/model/Entity.java @@ -30,6 +30,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.Charset; +import java.nio.file.Paths; import java.sql.JDBCType; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -282,15 +283,16 @@ protected V getRefField(String column, boolean required, Map target * @param zip the zip file from which to read a table */ public void loadTable(ZipFile zip) throws IOException { - ZipEntry entry = zip.getEntry(tableName + ".txt"); + String fileName = tableName + ".txt"; + ZipEntry entry = zip.getEntry(fileName); if (entry == null) { Enumeration entries = zip.entries(); // check if table is contained within sub-directory while (entries.hasMoreElements()) { ZipEntry e = entries.nextElement(); - if (e.getName().equals(tableName + ".txt")) { + if (Paths.get(e.getName()).getFileName().toString().equals(fileName)) { entry = e; - feed.errors.add(new TableInSubdirectoryError(tableName, entry.getName().replace(tableName + ".txt", ""))); + feed.errors.add(new TableInSubdirectoryError(tableName, entry.getName().replace(fileName, ""))); } } /* This GTFS table did not exist in the zip. */