Shinobi/libs/folders.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-09-28 05:37:08 +00:00
var fs = require('fs');
2018-09-29 01:38:14 +00:00
module.exports = function(s,config){
2018-09-28 05:37:08 +00:00
//directories
s.group = {}
2018-09-28 05:37:08 +00:00
if(!config.windowsTempDir&&s.isWin===true){config.windowsTempDir='C:/Windows/Temp'}
if(!config.defaultMjpeg){config.defaultMjpeg=s.mainDirectory+'/web/libs/img/bg.jpg'}
2018-09-28 05:37:08 +00:00
//default stream folder check
if(!config.streamDir){
if(s.isWin === false){
config.streamDir = '/dev/shm'
2018-09-28 05:37:08 +00:00
}else{
config.streamDir = config.windowsTempDir
2018-09-28 05:37:08 +00:00
}
if(!fs.existsSync(config.streamDir)){
config.streamDir = s.mainDirectory+'/streams/'
2018-09-28 05:37:08 +00:00
}else{
config.streamDir += '/streams/'
2018-09-28 05:37:08 +00:00
}
}
if(!config.videosDir){config.videosDir=s.mainDirectory+'/videos/'}
if(!config.binDir){config.binDir=s.mainDirectory+'/fileBin/'}
2018-09-28 05:37:08 +00:00
if(!config.addStorage){config.addStorage=[]}
s.dir={
videos: s.checkCorrectPathEnding(config.videosDir),
streams: s.checkCorrectPathEnding(config.streamDir),
fileBin: s.checkCorrectPathEnding(config.binDir),
addStorage: config.addStorage,
languages: s.location.languages+'/'
2018-09-28 05:37:08 +00:00
};
//streams dir
if(!fs.existsSync(s.dir.streams)){
fs.mkdirSync(s.dir.streams);
}
//videos dir
if(!fs.existsSync(s.dir.videos)){
fs.mkdirSync(s.dir.videos);
}
//fileBin dir
if(!fs.existsSync(s.dir.fileBin)){
fs.mkdirSync(s.dir.fileBin);
}
//additional storage areas
s.dir.addStorage.forEach(function(v,n){
v.path = s.checkCorrectPathEnding(v.path)
2018-09-28 05:37:08 +00:00
if(!fs.existsSync(v.path)){
fs.mkdirSync(v.path);
}
})
}