added description

This commit is contained in:
coderaiser 2012-11-30 06:30:54 -05:00
parent 4db2f9f93e
commit c8345f531c
3 changed files with 56 additions and 25 deletions

View file

@ -2,6 +2,15 @@
(function(){
"use strict";
if(!global.cloudcmd)
return console.log(
'# appcache.js' + '\n' +
'# -----------' + '\n' +
'# Module is part of Cloud Commander,' + '\n' +
'# used for work with Aplication Cache.' + '\n' +
'# If you wont to see at work set appcache: true' + '\n' +
'# in config.json and start cloudcmd.js' + '\n');
var main = global.cloudcmd.main,
fs = main.fs,
Util = main.util,

View file

@ -11,7 +11,10 @@
SLASH,
ISWIN32,
fs,
path,
zlib,
OK = 200,
ERROR = 404,
@ -30,7 +33,7 @@
/* Native Modules*/
exports.crypto = require('crypto'),
exports.child_process = require('child_process'),
exports.fs = require('fs'),
exports.fs = fs = require('fs'),
exports.http = require('http'),
exports.https = require('https'),
exports.path = path = require('path'),
@ -60,7 +63,7 @@
/* Needed Modules */
exports.util = Util = require(LIBDIR + 'util'),
exports.zlib = mrequire('zlib'),
exports.zlib = zlib = mrequire('zlib'),
/* Main Information */
exports.config = rootrequire('config');
@ -181,29 +184,34 @@
lEnc = lReq.headers['accept-encoding'] || '',
lGzip = lEnc.match(/\bgzip\b/),
lReadStream;
lReadStream,
main.fs.exists(lName, function(pExist){
lRet = pExist;
if(pExist){
lReadStream = main.fs.createReadStream(lName, {
'bufferSize': 4 * 1024
});
lRes.writeHead(OK, generateHeaders(lName, lGzip) );
if (lGzip)
lReadStream = lReadStream.pipe( main.zlib.createGzip() );
lReadStream.pipe(lRes);
}
else{
lSendError = function(pError){
var lJson = JSON.stringify({
error: 'File not Found'
error: pError
});
lRes.writeHead(ERROR, 'OK');
lRes.end(lJson);
}
};
main.fs.exists(lName, function(pExist){
lRet = pExist;
if(pExist)
Util.tryCatch(function(){
lReadStream = fs.createReadStream(lName, {
'bufferSize': 4 * 1024
});
lRes.writeHead(OK, generateHeaders(lName, lGzip) );
if (lGzip)
lReadStream = lReadStream.pipe( zlib.createGzip() );
lReadStream.pipe(lRes);
}, lSendError);
else
lSendError('File not Found');
});
return lRet;

View file

@ -303,10 +303,10 @@ var Util, exports;
* function execute param function in
* try...catch block and log result
*
* @param pCallBack
* @param pTryFunc
*/
Util.tryCatchDebug = function(pCallBack){
var lRet = Util.tryCatch(pCallBack);
Util.tryCatchDebug = function(pTryFunc){
var lRet = Util.tryCatch(pTryFunc);
if(lRet)
Util.debug();
@ -318,16 +318,30 @@ var Util, exports;
* function execute param function in
* try...catch block and log result
*
* @param pCallBack
* @param pTryFunc
*/
Util.tryCatchLog = function(pCallBack){
Util.tryCatchLog = function(pTryFunc){
var lRet;
lRet = Util.tryCatch(pCallBack);
lRet = Util.tryCatch(pTryFunc);
return Util.log(lRet);
};
/**
* function execute param function in
* try...catch block and log result
*
* @param pCallBack
*/
Util.tryCatchCall = function(pTryFunc, pCallBack){
var lRet;
lRet = Util.tryCatch(pTryFunc);
return Util.exec(pCallBack, lRet);
};
/**
* function do save exec of function
* @param pCallBack