mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 08:56:20 +00:00
added linux and windows versions of watch functions
This commit is contained in:
parent
f46cd4a1ff
commit
f1bf2d7598
4 changed files with 28 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html> <!-- manifest=cloudcmd.appcache -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- mobile first design -->
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ var CloudFunc = {
|
|||
SHORTNAMELENGTH : 16
|
||||
};
|
||||
|
||||
/*
|
||||
/*1
|
||||
* Функция убирает последний слеш,
|
||||
* если он - последний символ строки
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
var fs = require('fs');
|
||||
var crypto = require('crypto');
|
||||
|
||||
/* varible contain all watched file names
|
||||
* {name: true}
|
||||
*/
|
||||
var FileNames = {};
|
||||
var i=0;
|
||||
var FileNames = {};
|
||||
|
||||
/* function thet use for crossplatform
|
||||
* access to fs.watch or fs.watchFile function
|
||||
*/
|
||||
var fs_watch = null;
|
||||
var on_fs_watch =null;
|
||||
var fs_watch = null;
|
||||
var on_fs_watch = null;
|
||||
var firstFileRead_b = true;
|
||||
var Manifest = '';
|
||||
|
||||
setWatachFunctions();
|
||||
|
||||
|
|
@ -38,9 +40,13 @@ exports.watch = function(pFileName){
|
|||
catch(pError){
|
||||
console.log(pError);
|
||||
}
|
||||
|
||||
Manifest += pFileName + '\n';
|
||||
FileNames[pFileName] = true;
|
||||
}
|
||||
else if(firstFileRead_b){
|
||||
processManifest();
|
||||
firstFileRead_b = false;
|
||||
}
|
||||
};
|
||||
|
||||
function onWatch (pFileName){
|
||||
|
|
@ -55,4 +61,18 @@ function onWatchFile(pFileName){
|
|||
if(pCurr.mtime !== pCurr.pPrev.mtime)
|
||||
console.log('file ' + pFileName + 'is changed');
|
||||
};
|
||||
}
|
||||
|
||||
function processManifest(){
|
||||
Manifest = 'CACHE MANIFEST\n' +
|
||||
'#' + new Date() + '\n' +
|
||||
'CACHE:\n' +
|
||||
Manifest +
|
||||
'NETWORK:\n' +
|
||||
'*';
|
||||
|
||||
console.log(Manifest);
|
||||
fs.writeFile('cloudcmd.appcache', Manifest, function(){
|
||||
console.log('cloudcmd.appcache refreshed');
|
||||
});
|
||||
}
|
||||
|
|
@ -338,7 +338,7 @@ CloudServer._controller = function(pReq, pRes)
|
|||
console.log('reading '+lName);
|
||||
|
||||
/* watching is file changed */
|
||||
CloudServer.AppCache.watch(lName);
|
||||
//CloudServer.AppCache.watch(lName);
|
||||
|
||||
/* сохраняем указатель на response и имя */
|
||||
CloudServer.Responses[lName] = pRes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue