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
|
2018-11-02 23:44:53 +00:00
|
|
|
s.group = {}
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!config.windowsTempDir&&s.isWin===true){config.windowsTempDir='C:/Windows/Temp'}
|
2018-09-29 02:02:53 +00:00
|
|
|
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){
|
2018-11-02 23:44:53 +00:00
|
|
|
if(s.isWin === false){
|
|
|
|
config.streamDir = '/dev/shm'
|
2018-09-28 05:37:08 +00:00
|
|
|
}else{
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir = config.windowsTempDir
|
2018-09-28 05:37:08 +00:00
|
|
|
}
|
|
|
|
if(!fs.existsSync(config.streamDir)){
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir = s.mainDirectory+'/streams/'
|
2018-09-28 05:37:08 +00:00
|
|
|
}else{
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir += '/streams/'
|
2018-09-28 05:37:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-29 02:02:53 +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={
|
2018-11-02 23:44:53 +00:00
|
|
|
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){
|
2018-11-02 23:44:53 +00:00
|
|
|
v.path = s.checkCorrectPathEnding(v.path)
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!fs.existsSync(v.path)){
|
|
|
|
fs.mkdirSync(v.path);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|