|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
- t7 M( Y& I4 l4 W! l0 Qpublic:" C1 z7 L: d) R% g4 s7 c' t8 t
static std::string GetSharePath() {
+ Y: ?$ k+ R/ R. k/ m5 O // 优先检查 share 目录
! c; _4 o$ w5 r: N if (DirectoryExists("./share/")) {+ j$ W0 L7 ^( v8 X
return "./share/";
+ \/ U& H: z& s5 o h }2 Z( M) }. ?5 l5 t
// 如果 share 目录不存在,使用当前目录
% L7 f" N. k( z D5 I return "./";4 M# m' P2 m" h" q
}
! G/ G% `) c7 C0 ?
; u1 v) [1 \- @ static std::string GetItemetcPath() {
8 B. x1 n: ]5 D6 |. x return GetSharePath() + "itemetc.csv";
. ]: j+ w6 Z2 O- ^, i* g; q }
# ~4 G7 S7 \8 G- {7 y) ?) ? 5 ]# u7 |- f8 v
static std::string GetItemarmorPath() {0 G. z' h, B8 z- b$ [" G( B
return GetSharePath() + "itemarmor.csv";" L$ t2 u# s* D. A8 Z2 F& N
}6 T) z) y Q0 Y
: y+ H" N# e! g% A3 { static std::string GetItemweaponPath() {
1 W( B3 D2 w$ e7 _3 O return GetSharePath() + "itemweapon.csv";# c) c3 U3 r& ~- g* t2 |( k, U
}( V) r* ?1 P' L" i- y
/ g/ B9 r; y9 S) |
static std::string GetSkillnamePath() {
/ Q# x" U$ O4 w2 n8 f return GetSharePath() + "skillname.csv";
; V3 N7 g/ ^. }+ [9 l: Y/ Y }
! u4 _; e8 x/ J / H! \5 Y& q: J+ t+ D2 r6 L
private:
' m/ ~2 l$ \) f% ~ static bool DirectoryExists(const std::string& path) {1 e) i1 _& C( }2 N! u7 d
// 实现目录存在性检查( J) k* Z% r5 L8 n# G: ?* s6 N% |
struct stat info;
( C$ o7 l& P$ M& i return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);) r8 Q* ?- P1 H3 C) Y( m/ ^
}) k4 l- {. ?) D- ^# A
}; |
|