Add case insensitivity checks for Mac and Linux platforms
This commit is contained in:
@@ -4,20 +4,44 @@ import _ from "lodash";
|
||||
import deepLowerCaseKeys from "../../util/deepLowercaseKeys";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import { DecodedTtl, DecodedTtlLine } from "./decode-ttl.interface";
|
||||
import { platform } from "@electron-toolkit/utils";
|
||||
import { findFileCaseInsensitive } from "./decoder-utils";
|
||||
|
||||
const DecodeTtl = async (
|
||||
extensionlessFilePath: string,
|
||||
): Promise<DecodedTtl> => {
|
||||
let dbf: DBFFile | null = null;
|
||||
try {
|
||||
dbf = await DBFFile.open(`${extensionlessFilePath}.TTL`);
|
||||
} catch (error) {
|
||||
log.error("Error opening TTL File.", errorTypeCheck(error));
|
||||
}
|
||||
if (platform.isWindows) {
|
||||
try {
|
||||
dbf = await DBFFile.open(`${extensionlessFilePath}.TTL`);
|
||||
} catch (error) {
|
||||
log.error("Error opening TTL File.", errorTypeCheck(error));
|
||||
}
|
||||
|
||||
if (!dbf) {
|
||||
log.error(`Could not find any TTL files at ${extensionlessFilePath}`);
|
||||
throw new Error(`Could not find any TTL files at ${extensionlessFilePath}`);
|
||||
if (!dbf) {
|
||||
log.error(`Could not find any TTL files at ${extensionlessFilePath}`);
|
||||
throw new Error(
|
||||
`Could not find any TTL files at ${extensionlessFilePath}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const possibleExtensions: string[] = ["ttl"];
|
||||
const filePath = await findFileCaseInsensitive(
|
||||
extensionlessFilePath,
|
||||
possibleExtensions,
|
||||
);
|
||||
try {
|
||||
if (!filePath) {
|
||||
log.error(`Could not find any TTL files at ${extensionlessFilePath}`);
|
||||
throw new Error(
|
||||
`Could not find any TTL files at ${extensionlessFilePath}`,
|
||||
);
|
||||
}
|
||||
dbf = await DBFFile.open(filePath);
|
||||
} catch (error) {
|
||||
log.error("Error opening TTL File.", errorTypeCheck(error));
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const rawDBFRecord = await dbf.readRecords(1);
|
||||
|
||||
Reference in New Issue
Block a user