1 module dco.findDC;
2 
3 import std.file;
4 import std..string;
5 import std.process;
6 import std.stdio;
7 
8 import dco.readConfigs;
9 import dco.globalInfo;
10 
11 bool findDCEnv()
12 {
13 	if(!readConfig(configFile)) return false;
14 	bool bLocal = readConfig(configFileLocal);
15 
16 	string strNoDC = "Not found '" ~ strDC ~ "' in your computer,please setup it.",strTemp,strTempFile;
17 	string strDCExe = separator ~ strDC.stripRight() ~ ".exe";
18 	string strFireWall = " Maybe FirWall stop checking the " ~ strDCExe ~ ",please stop it.";
19 
20 	auto len = strDCStandardEnvBin.length;
21 
22 	auto path = environment["PATH"];
23 	string[] strDCs = path.split(";");
24 	foreach(s;strDCs)
25 	{
26 		ptrdiff_t i = s.indexOf(strDCStandardEnvBin);
27 		if(i != -1)
28 		{
29 			if(checkDC(s,strDCExe)) break;
30 		}
31 	}
32 
33 	if(strDCEnvFile == "")
34 	{
35 		writeln(strNoDC);
36 		return false;
37 	}
38 	else
39 	{
40 		//writeln(strDC ~ " is " ~ strDCEnvFile);
41 		return true;
42 	}
43 }
44 
45 bool checkDC(string DCPath,string strDCExe)
46 { 
47 	if(exists(DCPath ~ strDCExe))
48 	{ 
49 		strDCEnv = DCPath;
50 		strDCEnvFile =  DCPath ~ strDCExe;
51 
52 		string strTempFile = DCPath ~ separator ~ "dco.exe";
53 		if(exists(strTempFile)) return true;
54 	}
55 	return false;
56 }
57