Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/SIL.Machine/Corpora/FileParatextProjectFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ public FileParatextProjectFileHandler(string projectDir)

public bool Exists(string fileName)
{
return File.Exists(Path.Combine(_projectDir, fileName));
return Directory
.EnumerateFiles(_projectDir)
.Any(f => Path.GetFileName(f).Equals(fileName, System.StringComparison.InvariantCultureIgnoreCase));
}

public Stream Open(string fileName)
{
return File.OpenRead(Path.Combine(_projectDir, fileName));
return File.OpenRead(
Path.Combine(
_projectDir,
Directory
.EnumerateFiles(_projectDir)
.FirstOrDefault(f =>
Path.GetFileName(f).Equals(fileName, System.StringComparison.InvariantCultureIgnoreCase)
)
)
);
}

public UsfmStylesheet CreateStylesheet(string fileName)
Expand Down
12 changes: 9 additions & 3 deletions src/SIL.Machine/Corpora/ZipParatextProjectFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ public ZipParatextProjectFileHandler(ZipArchive archive)

public bool Exists(string fileName)
{
return _archive.GetEntry(fileName) != null;
return _archive.Entries.Any(e =>
e.FullName.Equals(fileName, System.StringComparison.InvariantCultureIgnoreCase)
);
}

public Stream Open(string fileName)
{
ZipArchiveEntry entry = _archive.GetEntry(fileName);
ZipArchiveEntry entry = _archive.Entries.FirstOrDefault(e =>
e.FullName.Equals(fileName, System.StringComparison.InvariantCultureIgnoreCase)
);
if (entry == null)
return null;
return entry.Open();
}

public string Find(string extension)
{
ZipArchiveEntry entry = _archive.Entries.FirstOrDefault(e => e.FullName.EndsWith(extension));
ZipArchiveEntry entry = _archive.Entries.FirstOrDefault(e =>
e.FullName.EndsWith(extension, System.StringComparison.InvariantCultureIgnoreCase)
);
if (entry == null)
return null;
return entry.FullName;
Expand Down
Loading