Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
Base
Commits
d9e10c4f
Commit
d9e10c4f
authored
May 16, 2016
by
Martin Marinov
Browse files
Refactored the Debug::File::Impl::add_time() implementation to System::Environment::time().
parent
cd991428
Changes
3
Hide whitespace changes
Inline
Side-by-side
Debug/DebFile.cc
View file @
d9e10c4f
...
...
@@ -4,6 +4,7 @@
#include
"DebFile.hh"
#include
"DebCallStack.hh"
#include
"DebDefault.hh"
#include
"Base/Utils/Environment.hh"
#include
<string>
#include
<fstream>
...
...
@@ -16,7 +17,6 @@
#include
<map>
#include
<sstream>
#include
<cstring>
#include
<time.h>
#ifndef WIN32
#define sprintf_s snprintf
...
...
@@ -276,32 +276,7 @@ public:
}
// Append current asctime to given string
bool
add_time
(
std
::
string
&
str
)
{
time_t
rawtime
;
time
(
&
rawtime
);
struct
tm
timeinfo
;
#ifdef WIN32
int
err
=
localtime_s
(
&
timeinfo
,
&
rawtime
);
if
(
err
==
0
)
{
char
buffer
[
256
];
err
=
asctime_s
(
buffer
,
sizeof
(
buffer
),
&
timeinfo
);
if
(
err
==
0
)
{
str
.
append
(
buffer
);
return
true
;
}
}
#else//WIN32
//TODO: Implement a secure version of this code for Linux, OSX
//timeinfo = *localtime(&rawtime);
//char* buffer = asctime(&timeinfo);
str
.
append
(
"TODO: add_time()"
);
#endif//WIN32
return
false
;
}
void
add_time
(
std
::
string
&
str
)
{
str
+=
System
::
Environment
::
time
();
}
#if 1
bool
hover
(
std
::
string
&
_str
,
const
std
::
string
&
_hover
,
const
bool
_open
)
...
...
Utils/Environment.cc
View file @
d9e10c4f
...
...
@@ -7,6 +7,7 @@
#include
<cstdlib>
#include
<locale.h>
#include
<locale>
#include
<time.h>
namespace
System
{
namespace
Environment
{
...
...
@@ -47,5 +48,29 @@ LocaleSession::~LocaleSession()
std
::
locale
::
global
(
lcl_bckp_
);
}
std
::
string
time
()
{
time_t
rawtime
;
::
time
(
&
rawtime
);
struct
tm
timeinfo
;
#ifdef WIN32
int
err
=
::
localtime_s
(
&
timeinfo
,
&
rawtime
);
if
(
err
==
0
)
{
char
buffer
[
256
];
err
=
asctime_s
(
buffer
,
sizeof
(
buffer
),
&
timeinfo
);
if
(
err
==
0
)
return
std
::
string
(
buffer
);
}
#else//WIN32
//TODO: Implement a secure version of this code for Linux, OSX
//timeinfo = *localtime(&rawtime);
//char* buffer = asctime(&timeinfo);
str
.
append
(
"TODO: add_time()"
);
#endif//WIN32
return
std
::
string
();
}
}
//namespace Environment
}
//namespace System
Utils/Environment.hh
View file @
d9e10c4f
...
...
@@ -48,6 +48,10 @@ private:
std
::
locale
lcl_bckp_
;
};
//! Return the system time in a string
std
::
string
time
();
}
//namespace Environment
}
//namespace System
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment