Shinobi/libs/folders.js

85 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-09-28 05:37:08 +00:00
var fs = require('fs');
2019-08-13 08:08:35 +00:00
module.exports = function(s,config,lang){
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
}
config.shmDir = `${s.checkCorrectPathEnding(config.streamDir)}`
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.listOfStorage = [{
2019-08-13 08:08:35 +00:00
name: lang['Default'],
value: ""
}]
2018-09-28 05:37:08 +00:00
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);
}
s.listOfStorage.push({
name: v.name,
value: v.path
})
})
//get audio files list
s.listOfAudioFiles = [
{
2019-08-13 08:08:35 +00:00
name:lang['No Sound'],
value:""
}
]
fs.readdirSync(s.mainDirectory + '/web/libs/audio').forEach(function(file){
s.listOfAudioFiles.push({
name: file,
value: file
})
})
//get themes list
s.listOfThemes = [
{
2019-08-13 08:08:35 +00:00
name:lang['Default'],
value:""
}
]
fs.readdirSync(s.mainDirectory + '/web/libs/themes').forEach(function(folder){
s.listOfThemes.push({
name: folder,
value: folder
})
2018-09-28 05:37:08 +00:00
})
}