|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {# w9 c8 }- K6 U/ q
public:$ d }4 z e, |' E' V9 I
static std::string GetSharePath() {/ N9 M2 Y4 I+ |
// 优先检查 share 目录
/ W' f9 I) ~/ D2 {+ a if (DirectoryExists("./share/")) {, j, S5 b& \/ Y1 y
return "./share/";
2 ^7 q# {1 ^. r. {8 h }0 Y6 t% y; q9 J0 R. B
// 如果 share 目录不存在,使用当前目录3 F* i" `+ `! [" a1 {. p, K
return "./";+ R& T+ c8 [, [, b! Q3 g
}5 C5 h9 `# R1 u8 O5 j
9 n8 s+ n: t% O- {7 A
static std::string GetItemetcPath() {
: f, |: ^' x4 \9 a4 g+ P; } ~ return GetSharePath() + "itemetc.csv";
1 e5 Y8 h# y" f1 ^( O, F3 T }
$ X! z) l" f% M5 V( p; g
7 t0 }' r; d. q4 d0 k! _" Z static std::string GetItemarmorPath() {2 {3 H7 v+ l m% _* E G2 y
return GetSharePath() + "itemarmor.csv";# z+ c3 {1 I% Z/ g- c1 J" H* F" n
}* }1 e, l3 H$ E `2 H
% V" G4 n! G2 Y: S* d
static std::string GetItemweaponPath() {1 {7 z4 I; o0 a9 K6 X/ [
return GetSharePath() + "itemweapon.csv";9 s* C1 y5 S- m! w! C9 O2 C
}
# i0 U" u1 g! _0 k) w/ w3 b
+ |, Z' f- H E static std::string GetSkillnamePath() {
( S: y9 q% N2 A+ l0 ^' B3 w3 ] j1 g return GetSharePath() + "skillname.csv";
4 T7 y" m2 \) R" i+ L/ [2 M- h$ f6 ]9 l }0 q& d! N A( }' w
" P7 p0 l `: A* h7 N! \& N( `. g% X3 A
private:
$ N. o2 q8 c( c& g, f+ ] static bool DirectoryExists(const std::string& path) {
8 M/ k: v0 |' L // 实现目录存在性检查
I/ D- G/ u/ C+ a( d struct stat info;+ d7 t2 n+ k' R; ]: a- D* a5 C
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
6 V$ B2 ~6 @# x; I- K }" i) q( W0 A3 ]/ I
}; |
|