Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createNewCsvFile(filePath: string, fileName: string, data: Map): boolean {
const file = path.join(filePath, fileName);
if (!IModelJsFs.existsSync(filePath)) createFilePath(filePath);
if (!IModelJsFs.existsSync(file)) {
try {
let colNames = "";
data.forEach((_value, colName) => {
colNames += colName + ",";
});
colNames += "\r\n";
IModelJsFs.writeFileSync(file, colNames);
} catch (err) {
/* Handle the error */
}
return true;
} else {
return false;
}
}
function setupStandaloneConfiguration() {
const filename = process.env.SVT_STANDALONE_FILENAME;
if (filename !== undefined) {
const configuration: any = {};
configuration.standalone = true;
configuration.standalonePath = filename;
configuration.viewName = process.env.SVT_STANDALONE_VIEWNAME; // optional
configuration.iModelName = filename;
IModelJsFs.writeFileSync(path.join(__dirname, "configuration.json"), JSON.stringify(configuration));
}
}
function setupStandaloneConfiguration() {
const filename = process.env.SVT_STANDALONE_FILENAME;
if (filename !== undefined) {
const configuration: any = {};
configuration.standalone = true;
configuration.standalonePath = process.env.SVT_STANDALONE_FILEPATH; // optional (browser-use only)
configuration.viewName = process.env.SVT_STANDALONE_VIEWNAME; // optional
configuration.iModelName = filename;
const configPathname = path.normalize(path.join(__dirname, "../webresources", "configuration.json"));
IModelJsFs.writeFileSync(configPathname, JSON.stringify(configuration));
}
}
count++;
if (opNames[opNamesIndex] === columns[columnsIndex + count])
columnsIndex += count;
else {
origFile = addColumn(origFile, opNames[opNamesIndex], columnsIndex);
columns.splice(columnsIndex, 0, opNames[opNamesIndex]);
opNamesIndex++;
columnsIndex++;
}
}
} else {
opNamesIndex++;
columnsIndex++;
}
}
IModelJsFs.writeFileSync(filePath, origFile);
}
public async savePng(fileName: string, png: string) {
let filePath;
if (MobileRpcConfiguration.isMobileBackend && process.env.DOCS) {
filePath = process.env.DOCS;
fileName = path.join(filePath, fileName);
} else {
filePath = this.getFilePath(fileName);
}
if (!IModelJsFs.existsSync(filePath)) createFilePath(filePath);
if (IModelJsFs.existsSync(fileName)) IModelJsFs.unlinkSync(fileName);
const buf = Buffer.from(png, "base64");
IModelJsFs.writeFileSync(fileName, buf);
}