-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXPathMonitor.cpp
More file actions
69 lines (57 loc) · 1.63 KB
/
XPathMonitor.cpp
File metadata and controls
69 lines (57 loc) · 1.63 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
64
65
66
67
68
69
/**************************************************************************
/* FileName: XPathMonitor.cpp
/* FileDesc:
/* FileAuthor: YangCao
/* CreateTime: 2015/08/05 21:39:03
/* CopyRight: yc
/*************************************************************************/
#include "XPathMonitor.h"
#include "XSys.h"
#include "XLog.h"
XPathMon& XPathMon::GetInstance()
{
static XPathMon inst;
return inst;
}
bool XPathMon::Init(const char* writable_path, const char* bundle_path)
{
this->writable_path = writable_path;
AddPath("writable", this->writable_path.c_str());
this->bundle_path = bundle_path;
AddPath("bundle", this->bundle_path.c_str());
this->init_asset_path = this->bundle_path + "init_asset/";
AddPath("init_asset", init_asset_path.c_str());
asset_update_path = this->writable_path + "AssetUpdate/";
AddPath("asset_update", asset_update_path.c_str());
tmp_path = this->writable_path + "Tmp/";
AddPath("tmp", tmp_path.c_str());
game_data_path = this->writable_path + "GameData/";
AddPath("game_data", game_data_path.c_str());
log_path = this->writable_path + "Log/";
AddPath("log", log_path.c_str());
return true;
}
bool XPathMon::AddPath(const char* tag, const char* full_path)
{
if (!tag || !full_path)
{
return false;
}
if( XSys::XCreateDirectory(full_path) )
{
std::string str_tag = tag;
std::string str_full_path = full_path;
tag_map_path[str_tag] = str_full_path;
return true;
}
return false;
}
std::string XPathMon::GetPathByTag(const char* tag) const
{
PathCacheMap::const_iterator iter = tag_map_path.find(tag);
if (iter != tag_map_path.end())
{
return iter->second;
}
return std::string("");
}