|
|
class Config {9 G; K, o5 B, I C0 {9 z' C& z2 ?
public:
' Y1 Q1 R( p7 }# n# Y- C0 M+ H( J static std::string GetSharePath() {
5 a1 ^& {! P% H9 E // 优先检查 share 目录! z1 Y1 K; Q5 h1 I- k
if (DirectoryExists("./share/")) {
- T$ } u) Q" A$ q# u* Z( k) f; L: P return "./share/";1 H0 v, G7 T' Q% ?
}
" n5 K" H& _; ~4 y) C // 如果 share 目录不存在,使用当前目录
' V( R6 l* v; y/ y return "./"; w2 ]6 d( c0 e! Q6 g, a4 [
}1 l3 J0 ^5 @$ o+ C: ]3 ~
* m. j% W" Q6 O2 `8 z
static std::string GetItemetcPath() {
% A" d4 ]9 h) U( @3 I return GetSharePath() + "itemetc.csv";
h, |1 L1 R1 m }/ V! K l; Z5 K ^7 }* P) ]3 E
& w3 C& e& h6 Z. |6 y! n% G5 ^
static std::string GetItemarmorPath() {
9 k' O: b) K2 _2 ^$ e return GetSharePath() + "itemarmor.csv";
/ Y3 B' s, T# G0 e }
6 B4 R. d# k6 M [7 i : @0 i* G8 k' g9 A" {6 Q
static std::string GetItemweaponPath() {# N5 N; I* j5 _9 Z
return GetSharePath() + "itemweapon.csv";9 ~* v6 C7 J) S$ ]4 V
}
3 o8 [* T9 z$ ]5 c u" N
4 ~2 B' j7 B/ ~' H7 V static std::string GetSkillnamePath() {9 y0 N0 {) f6 o2 r
return GetSharePath() + "skillname.csv";
" |; a+ ?, {5 ^ } l; x3 I5 _( H* E) u2 y/ ^
) j4 t8 z' C" X3 p0 g7 }6 yprivate:
- N' F8 Z3 E7 ~, U static bool DirectoryExists(const std::string& path) {
: I' @* w& x0 a( T7 O- K // 实现目录存在性检查2 n" v) {/ _( \1 u3 S! ^9 w1 ~
struct stat info;
X( s" n0 `2 x7 r g return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);( L {" m" k5 z$ @4 y$ a) M
}/ H, Z% i' U# J
}; |
|