mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Changed short variable names to something longer
This commit is contained in:
parent
bde4580806
commit
7a41281993
2 changed files with 21 additions and 31 deletions
|
@ -41,7 +41,6 @@ Exportált funkciók:
|
||||||
2. WriteFile
|
2. WriteFile
|
||||||
3. writeFileAsync
|
3. writeFileAsync
|
||||||
4. AppendToFile
|
4. AppendToFile
|
||||||
5. Beep
|
|
||||||
6. WriteBackup
|
6. WriteBackup
|
||||||
7. FileExists
|
7. FileExists
|
||||||
8. CreatePath
|
8. CreatePath
|
||||||
|
|
|
@ -4,7 +4,6 @@ module.exports = {
|
||||||
WriteFile: WriteFile,
|
WriteFile: WriteFile,
|
||||||
writeFileAsync: WriteFileAsync,
|
writeFileAsync: WriteFileAsync,
|
||||||
AppendToFile: AppendToFile,
|
AppendToFile: AppendToFile,
|
||||||
Beep: Beep,
|
|
||||||
WriteBackup: WriteBackup,
|
WriteBackup: WriteBackup,
|
||||||
FileExists: FileExists,
|
FileExists: FileExists,
|
||||||
CreatePath: CreatePath,
|
CreatePath: CreatePath,
|
||||||
|
@ -21,19 +20,19 @@ var logger = require('../utils/logger.js')
|
||||||
const dataFile = './qminingPublic/data.json'
|
const dataFile = './qminingPublic/data.json'
|
||||||
|
|
||||||
function GetDateString() {
|
function GetDateString() {
|
||||||
const m = new Date()
|
const date = new Date()
|
||||||
return (
|
return (
|
||||||
m.getFullYear() +
|
date.getFullYear() +
|
||||||
'-' +
|
'-' +
|
||||||
('0' + (m.getMonth() + 1)).slice(-2) +
|
('0' + (date.getMonth() + 1)).slice(-2) +
|
||||||
'-' +
|
'-' +
|
||||||
('0' + m.getDate()).slice(-2) +
|
('0' + date.getDate()).slice(-2) +
|
||||||
' ' +
|
' ' +
|
||||||
('0' + m.getHours()).slice(-2) +
|
('0' + date.getHours()).slice(-2) +
|
||||||
':' +
|
':' +
|
||||||
('0' + m.getMinutes()).slice(-2) +
|
('0' + date.getMinutes()).slice(-2) +
|
||||||
':' +
|
':' +
|
||||||
('0' + m.getSeconds()).slice(-2)
|
('0' + date.getSeconds()).slice(-2)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +48,8 @@ function ReadDir(path) {
|
||||||
function ReadJSON(name) {
|
function ReadJSON(name) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(ReadFile(name))
|
return JSON.parse(ReadFile(name))
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.log(e)
|
console.error(err)
|
||||||
throw new Error('Coulndt parse JSON in "ReadJSON", file: ' + name)
|
throw new Error('Coulndt parse JSON in "ReadJSON", file: ' + name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +67,7 @@ function FileExists(path) {
|
||||||
|
|
||||||
function WatchFile(file, callback) {
|
function WatchFile(file, callback) {
|
||||||
if (FileExists(file)) {
|
if (FileExists(file)) {
|
||||||
fs.watchFile(file, (curr, prev) => {
|
fs.watchFile(file, () => {
|
||||||
fs.readFile(file, 'utf8', (err, data) => {
|
fs.readFile(file, 'utf8', (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log(err)
|
// console.log(err)
|
||||||
|
@ -90,20 +89,20 @@ function CreatePath(path, onlyPath) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = path.split('/')
|
var spath = path.split('/')
|
||||||
var currDir = p[0]
|
var currDir = spath[0]
|
||||||
for (var i = 1; i < p.length; i++) {
|
for (var i = 1; i < spath.length; i++) {
|
||||||
if (currDir !== '' && !fs.existsSync(currDir)) {
|
if (currDir !== '' && !fs.existsSync(currDir)) {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(currDir)
|
fs.mkdirSync(currDir)
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.log('Failed to make ' + currDir + ' directory... ')
|
console.log('Failed to make ' + currDir + ' directory... ')
|
||||||
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currDir += '/' + p[i]
|
currDir += '/' + spath[i]
|
||||||
}
|
}
|
||||||
if (onlyPath === undefined || onlyPath === false) {
|
if (onlyPath) {
|
||||||
} else {
|
|
||||||
fs.mkdirSync(path)
|
fs.mkdirSync(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,21 +128,13 @@ function AppendToFile(data, file) {
|
||||||
CreatePath(file)
|
CreatePath(file)
|
||||||
try {
|
try {
|
||||||
fs.appendFileSync(file, '\n' + data)
|
fs.appendFileSync(file, '\n' + data)
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
logger.Log(
|
logger.Log(
|
||||||
'Error appendig to file log file: ' + file + ' (sync)',
|
'Error appendig to file log file: ' + file + ' (sync)',
|
||||||
logger.GetColor('redbg')
|
logger.GetColor('redbg')
|
||||||
)
|
)
|
||||||
logger.Log(data)
|
logger.Log(data)
|
||||||
console.log(e)
|
console.error(err)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Beep() {
|
|
||||||
try {
|
|
||||||
process.stdout.write('\x07')
|
|
||||||
} catch (e) {
|
|
||||||
console.log('error beepin')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,8 +144,8 @@ function WriteBackup() {
|
||||||
ReadFile(dataFile),
|
ReadFile(dataFile),
|
||||||
'public/backs/data_' + new Date().toString()
|
'public/backs/data_' + new Date().toString()
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
logger.Log('Error backing up data json file!', logger.GetColor('redbg'))
|
logger.Log('Error backing up data json file!', logger.GetColor('redbg'))
|
||||||
console.log(e)
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue