12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import fs from 'node:fs';
- import path from 'node:path';
- const STORE_PATH_NAME = 'store';
- const TEMP_PATH_NAME = 'temp';
- export function getResourcesDir() {
- return process.env.NODE_ENV === 'development'
- ? path.join(__dirname, '../../resources/')
- : path.join(__dirname, '../../../app.asar.unpacked/resources/');
- }
- export function getRootDir() {
- return process.env.NODE_ENV === 'development'
- ? path.join(__dirname, '../../')
- : path.join(__dirname, '../../../../');
- }
- export function getDatabasePath() {
- return path.join(getRootDir(), 'database', 'database.sqlite');
- }
- export function getStoreDir() {
- return path.join(getRootDir(), STORE_PATH_NAME);
- }
- export function getTempPath() {
- return path.join(getStoreDir(), TEMP_PATH_NAME);
- }
- export function getImagicPath() {
- return path.join(getResourcesDir(), './imagemagick-7.1.1-11/');
- }
- export function makeDirSync(pathContent: string) {
- const mkPathList: string[] = [];
- let curPath = pathContent;
- while (!fs.existsSync(curPath)) {
- mkPathList.unshift(curPath);
- curPath = path.dirname(curPath);
- }
- mkPathList.forEach((mpath) => {
- fs.mkdirSync(mpath);
- });
- }
- makeDirSync(getTempPath());
|