function mkdir(path)
{
var fs=require('fs');
fs.exists(path, function (exists) {
if(exists){
}
else
{
fs.mkdir(path, 0777, function(err){
if(err)
{
document.getElementById("om").innerHTML+='<br><font color=red>Error: Connot create directory Please Check Path '+path+'</font>';
}
else
document.getElementById("om").innerHTML+='<br>'+path+' dir created succesfully....';
});
}
});
}
function makedir(root,baseurl,fromd,tod){
var step=require('step');
step(
function firstFunction(){
mkdir(root);
Ext.getCmp('pbar3').updateText('Creating directory'+root);
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function secondFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
mkdir(root+'/downloads');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads');
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function thirdFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
mkdir(root+'/reports');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/reports');
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function fourthFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
mkdir(root+'/logs');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/logs');
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function fifveFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
mkdir(root+'/std_csv');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/std_csv');
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function sixFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
setTimeout(function(){mkdir(root+'/downloads/unzip');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/unzip');
Ext.getCmp('pbar3').updateProgress(1.0);
},1000);
return this;
},
function sevenFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
setTimeout(function(){mkdir(root+'/downloads/temp');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/temp');
Ext.getCmp('pbar3').updateProgress(1.0);
},1000);
return this;
},
function eightFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
setTimeout(function(){mkdir(root+'/downloads/mcxindia');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/mcxindia');
Ext.getCmp('pbar3').updateProgress(1.0);
},1000);
return this;
},
function nineFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
setTimeout(function(){mkdir(root+'/downloads/temp_yahoo');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/temp_yahoo');
Ext.getCmp('pbar3').updateProgress(1.0);
},1000);
return this;
},
function tenthFunction(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
setTimeout(function(){mkdir(root+'/downloads/unzip/unzip1');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/unzip/unzip1');
Ext.getCmp('pbar3').updateProgress(1.0);
},2000);
return this;
},
function mkEventDir(err, text){
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
mkdir(root+'/events');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/events');
Ext.getCmp('pbar3').updateProgress(1.0);
return this;
},
function elventhFunction(err, text)
{
var csv = require('ya-csv');
var reader = csv.createCsvFileReader('settings.csv',{'separator': ','});
reader.addListener('data', function(data)
{
if(data[0]=='format')
{
if(data[1].search('AmiBroker')>=0)
{
mkdir(root+'/amibroker');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/amibroker');
Ext.getCmp('pbar3').updateProgress(1.0);
}
if(data[1].search('FChart')>=0)
{
mkdir(root+'/fchart');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/fchart');
Ext.getCmp('pbar3').updateProgress(1.0);
}
if(data[1].search('MetaStock')>=0)
{
mkdir(root+'/metastock');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/metastock');
Ext.getCmp('pbar3').updateProgress(1.0);
}
if(data[1].search('Ninja')>=0)
{
mkdir(root+'/ninja');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/ninja');
Ext.getCmp('pbar3').updateProgress(1.0);
}
if(data[1].search('Advanced_Get')>=0)
{
mkdir(root+'/advanceget');
Ext.getCmp('pbar3').updateText('Creating directory'+root+'/advanceget');
Ext.getCmp('pbar3').updateProgress(1.0);
}
}
});
return this;
},
function newfunction()
{
var downloadpath=root+'/downloads/';
var unzippath=root+'/downloads/unzip/';
var logpath=root+'/logs/';
var outputpath=root+'/std_csv/';
setTimeout(performtask,2000,baseurl,downloadpath,unzippath,outputpath,logpath,fromd, tod);
return this;
}
);
}