47 void Title::Precent(
long long n,
bool bNew ,
long long nTotal ,
const char* label )
80 size_t nCur = ifile.tellg();
81 ifile.seekg(0, ios_base::end);
82 Precent(nCur,
true, ifile.tellg(), label);
94 long long nCur = _ftelli64(fp);
95 _fseeki64(fp, 0, SEEK_END);
96 Precent(nCur,
true, _ftelli64(fp), label);
97 _fseeki64(fp, nCur, SEEK_SET);
141 return (m_nBeginTime = clock());
145 if (m_bWork ==
false)
148 m_nEndTime = clock();
149 return m_nEndTime - m_nBeginTime;
153 return clock() - m_nBeginTime;
205 void Path::SearchFiles()
213 char *p = strtok(&
m_input[0],
"+\"");
216 p = strtok(NULL,
"+\"");
220 for (
int i = 0; i < aPaths.
GetNum(); i++)
225 HANDLE hFile = FindFirstFileA(aPaths[i], &fd);
226 while (hFile != INVALID_HANDLE_VALUE && bRed)
229 strcpy(p, aPaths[i]);
230 char *temp = strrchr(p,
'\\');
236 strcat(p, fd.cFileName);
240 bRed = FindNextFileA(hFile, &fd);
248 cout <<
"[Press any key to continue...]" << endl;
251 void outPrecent(
long long n,
bool bNew ,
long long nTotal ,
const char* title )
253 static int snLastPrecent = 0;
254 static long long snTotal = 100;
255 static char strTitle[500];
257 static clock_t begtime = 0;
259 bool bUpdate =
false;
264 snLastPrecent = n * 100 / snTotal;
265 strcpy(strTitle, title);
273 int nNew = (int)(1.0*n / snTotal * 100);
274 if (nNew > snLastPrecent)
276 snLastPrecent = nNew;
285 cout << title <<
":";
290 cout << snLastPrecent <<
"%";
294 void outPrecent(ifstream &ifile,
bool bNew,
const char* title)
298 ifile.seekg(0, ios_base::end);
300 ifile.seekg(0, ios_base::beg);
312 long long iCur = _ftelli64(fp);
313 _fseeki64(fp, 0, SEEK_END);
315 _fseeki64(fp, iCur, SEEK_SET);
bool Out(T *p_pT)
Move a value outof queue.
void outPrecent(long long n, bool bNew, long long nTotal, const char *title)
print precent in the cmd window
static long long m_precent_cur
for Precent function, the current value
A queue based the dynamic memory mangement.
static void SetGlobalTitle(const char *pstr)
set the global title
const int cn_title_max_len
clock_t Get()
get the time, but don't stop recording
Queue< char * > * m_paFiles
store all the files find in the queue
void Clean()
clean the queue. Donot release the memory
static const char * GetGlobalTitle()
get the global title
static string m_precent_label
the precent output label
static long long m_precent_max
for Precent function, the maxiumn value
clock_t Begin()
begin to record
Provide the toolkits for cmd window of window platform.
static string m_global_title
the global title. All the other information are follow the global title
string m_input
stroe the input string
static void Fraction(long long n=m_precent_cur+1, bool bNew=false, long long nTotal=100, const char *label="")
output rate to title
static void Puts(const char *pStr)
output string to title
static int m_precent_last
record the last output precent value (from 0 to 100)
int GetNum() const
Get Array number.
void Add(T t)
Add a value to the tail of array.
static void Precent(long long n=m_precent_cur+1, bool bNew=false, long long nTotal=100, const char *label="")
output precent to title
Path(const char *path=NULL)
void Reset(const char *path=NULL)
reset the path
clock_t End()
record end and return the time
bool GetPath(char *path)
Get pathes.
void In(T p_t)
Add a value into queue.
void Clean()
clean the clock
define all the code written by Bin Wang.
void Sleep(clock_t n)
wait for sveral millissecond