1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/ProjectPath.ts

35 lines
921 B
TypeScript
Raw Normal View History

2018-03-31 03:30:30 +08:00
import * as path from 'path';
import {Config} from '../common/config/private/Config';
class ProjectPathClass {
public Root: string;
public ImageFolder: string;
public ThumbnailFolder: string;
2017-07-04 01:17:49 +08:00
public FrontendFolder: string;
isAbsolutePath(pathStr: string) {
return path.resolve(pathStr) === path.normalize(pathStr);
}
2016-06-25 20:13:06 +08:00
normalizeRelative(pathStr: string) {
return path.join(pathStr, path.sep);
}
2016-12-28 21:26:19 +08:00
2017-07-15 04:56:25 +08:00
getAbsolutePath(pathStr: string): string {
return this.isAbsolutePath(pathStr) ? pathStr : path.join(this.Root, pathStr);
}
constructor() {
2017-07-19 16:21:52 +08:00
this.reset();
}
reset() {
2018-03-31 03:30:30 +08:00
this.Root = path.join(__dirname, '/../');
2017-07-15 04:56:25 +08:00
this.ImageFolder = this.getAbsolutePath(Config.Server.imagesFolder);
this.ThumbnailFolder = this.getAbsolutePath(Config.Server.thumbnail.folder);
2018-03-31 03:30:30 +08:00
this.FrontendFolder = path.join(this.Root, 'dist');
}
}
export const ProjectPath = new ProjectPathClass();