UNPKG

@shapediver/sdk.sdtf-v1

Version:
31 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SdtfFileUtils = void 0; const sdk_sdtf_core_1 = require("@shapediver/sdk.sdtf-core"); const path = require('path'); const fs = require('fs'); class SdtfFileUtils { toAbsolutePath(relativePath) { try { return path.resolve(relativePath); } catch (e) { throw new sdk_sdtf_core_1.SdtfError(`Could not resolve path '${relativePath}': ${e.message}`); } } readFile(absolutePath) { if (!fs.existsSync(absolutePath)) { throw new sdk_sdtf_core_1.SdtfError(`Cannot find file at location '${absolutePath}'.`); } return new Promise((resolve, reject) => { fs.readFile(absolutePath, (error, buffer) => { if (error) reject(error); const data = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength); resolve(data); }); }); } } exports.SdtfFileUtils = SdtfFileUtils; //# sourceMappingURL=SdtfFileUtils.js.map