|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
* r5 e- d: ^1 upublic:
% h/ `: A& W" u% O( W static std::string GetSharePath() {
/ P+ v6 h7 B, J // 优先检查 share 目录
, H8 f2 p4 v# S if (DirectoryExists("./share/")) {0 z" m9 b% l {+ U' B+ W
return "./share/";; a& y5 W% e5 `9 _( ~! G: B% S$ b
}
2 |. d O- H1 ~) s7 i // 如果 share 目录不存在,使用当前目录! \# O( ^ w, J4 \* y. f8 w. G
return "./";
$ I: C1 I$ b# M. P6 g: t }5 F0 Q$ G. N* p) w; P
2 ~& ~+ t9 ?4 r' t7 V
static std::string GetItemetcPath() {
2 C& J `! M4 X7 s9 ] return GetSharePath() + "itemetc.csv";
9 `. ~/ Q( s, D. ]$ S) p }
M0 C8 C& }4 n/ l' R; w: c& _ ?& [" l1 y% G! p9 e7 n9 K' x/ Q
static std::string GetItemarmorPath() {
* }% @5 u8 P/ |$ P/ A l1 r return GetSharePath() + "itemarmor.csv";
: w$ ~3 m/ Q5 l' b }
9 h" R% f% h7 n; L3 x+ W
9 d$ S, \. h/ F: G1 T static std::string GetItemweaponPath() {
1 E. [- F2 o7 Y$ ] return GetSharePath() + "itemweapon.csv";: u, y/ G0 c% [4 p
}, F7 X5 Q/ W0 o3 m1 r
% K+ u/ e. G! y: P8 S static std::string GetSkillnamePath() {
# m1 w- N) K+ t2 L return GetSharePath() + "skillname.csv";1 g- T$ c( I5 R1 c* Q/ J1 X
}& [. z1 V! t6 u. i/ a& L) N& B, d
7 \( Y1 \7 b! t) }/ _private:: r9 I. p2 B8 V1 _. F2 \
static bool DirectoryExists(const std::string& path) {1 I4 U/ w' S7 Q8 H+ y
// 实现目录存在性检查
4 e7 f0 h9 k4 V3 m+ p struct stat info;) d a: \5 {& z9 i9 g
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
" h4 O# Q8 F/ ?1 y9 n }
{& ~# D5 D l0 H}; |
|