-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
63 lines (54 loc) · 1.25 KB
/
utils.cpp
File metadata and controls
63 lines (54 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "main.h"
#include <cctype>
#include <functional>
#include <fstream>
#include <iostream>
#include <io.h>
string wordToStrWithZeros(WORD value, unsigned short digitCount)
{
char _buf[8];
sprintf_s(_buf, "%hu", value);
string _retStr(_buf);
for(int i = 1; i < digitCount; i++)
{
value /= 10;
if (value == 0)
_retStr = "0" + _retStr;
}
return _retStr;
}
inline string twoDigitWordToStr(WORD value)
{
return wordToStrWithZeros(value, 2);
}
string getNowTimeStamp()
{
SYSTEMTIME _time;
GetLocalTime( &_time );
string _retStr("");
_retStr = "[" + twoDigitWordToStr(_time.wHour)+ ":" + twoDigitWordToStr(_time.wMinute) + ":"
+ twoDigitWordToStr(_time.wSecond) + "] ";
return _retStr;
}
string getNowToString()
{
SYSTEMTIME _time;
GetLocalTime( &_time );
string _retStr("");
_retStr += wordToStrWithZeros(_time.wYear, 4);
_retStr += "_";
_retStr += twoDigitWordToStr(_time.wMonth);
_retStr += "_";
_retStr += twoDigitWordToStr(_time.wDay);
_retStr += "_";
_retStr += twoDigitWordToStr(_time.wHour);
_retStr += "_";
_retStr += twoDigitWordToStr(_time.wMinute);
_retStr += "_";
_retStr += twoDigitWordToStr(_time.wSecond);
return _retStr;
}
bool FileExists (const char *fname)
{
return _access(fname,0) != -1;
}