为适配跨平台调整代码。此版本可以在Windows和Linux平台编译通过,但尚未进行测试。

pull/32/merge
Apex Liu 2017-01-11 23:50:29 +08:00
parent 4cc96b0025
commit 3ec1bea6ea
4 changed files with 15 additions and 9 deletions

View File

@ -9,6 +9,8 @@
#define WMU_INSTANCE_EXIT (WM_USER + 2)
#define WMU_SHOW_EXIST_DLGUI (WM_USER + 3)
static ExLogger g_ex_logger;
static ATOM MyRegisterClass();
static BOOL InitInstance();
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
@ -38,6 +40,7 @@ DWORD WINAPI ThreadProc(LPVOID lpParam)
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
EXLOG_USE_LOGGER(&g_ex_logger);
WORD wVersionRequested;
WSADATA wsaData;
@ -64,7 +67,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd
EXLOG_LEVEL(EX_LOG_LEVEL_INFO);
#endif
EXLOG_FILE(L"tp_assist.log", g_env.m_log_path.c_str(), 1024, 2);
EXLOG_FILE(L"tp_assist.log", g_env.m_log_path.c_str(), EX_LOG_FILE_MAX_SIZE, EX_LOG_FILE_MAX_COUNT);
g_cfgSSH.init();
g_cfgScp.init();

View File

@ -325,6 +325,8 @@ bool ExLogger::set_log_file(const ex_wstr& log_path, const ex_wstr& log_name, ex
m_path = log_path;
ex_abspath(m_path);
ex_mkdirs(m_path);
m_fullname = m_path;
ex_path_join(m_fullname, false, log_name.c_str(), NULL);
@ -549,6 +551,7 @@ bool ExLogger::write(const char* buf)
m_filesize += lenTime;
WriteFile(m_file, buf, len, &dwWritten, NULL);
m_filesize += len;
FlushFileBuffers(m_file);
#else
time_t timep;
struct tm *p;

View File

@ -146,17 +146,17 @@ void base_record::record(unsigned char* buf, int len, int cmd)
bool bRet = cached_buffer(&replay_header, buf, len);
if (!bRet)
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD>
//缓存已满,把缓存存文件,并且清空缓存
save_buffer_to_file(int(internal_time));
//<EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ļ<EFBFBD>
//打开下个文件
open_next_file();
bRet = cached_buffer(&replay_header, buf, len);
if (!bRet)
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD>󣬲<EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD>棬ֱ<EFBFBD>Ӵ<EFBFBD><EFBFBD>ļ<EFBFBD>
//如果还是太大,不能缓存,直接存文件
save_to_file(ex_u32(internal_time), &replay_header, buf, len);
open_next_file();
}
@ -171,7 +171,7 @@ bool base_record::cached_buffer(ts_replay_data_header* header, unsigned char* bu
return false;
}
//<EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ滺<EFBFBD><EFBFBD>
//长度够长直接存缓存
memcpy(m_buf + m_buf_offset, header, header_len);
m_buf_offset += header_len;
@ -208,7 +208,7 @@ bool base_record::save_buffer_to_file(int internal_time)
if(NULL == m_current_file)
return false;
int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* д<EFBFBD><EFBFBD>struct<EFBFBD>ļ<EFBFBD>*/
int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* 写的struct文件*/
m_totol_size += m_buf_offset;
m_buf_offset = 0;

View File

@ -19,9 +19,9 @@ bool TsEnv::init(void)
ex_dirname(m_exec_path);
// <EFBFBD><EFBFBD>λ log, etc ·<><C2B7>
// Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD>λ<EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ../ <20><><EFBFBD>λ<EFBFBD>ã<EFBFBD>
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>µ<EFBFBD>shareĿ¼<EFBFBD>в<EFBFBD><EFBFBD>ҡ<EFBFBD>
// 定位 log, etc 路径
// 默认情况下,以上三个目录均位于本可执行程序的 ../ 相对位置,
// 如果不存在则可能是开发调试模式则尝试从源代码仓库根目录下的share目录中查找。
ex_wstr base_path = m_exec_path;
ex_path_join(base_path, true, L"..", NULL);