|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {2 a: J; z& O0 l- F% z0 d
public:
) K; C/ K) }5 w( H static std::string GetSharePath() {, x" w5 |, h# X. B2 S$ G
// 优先检查 share 目录, `( Q8 w/ C# {; V9 [
if (DirectoryExists("./share/")) {
8 D( w% S ~( U: e0 x) {+ Z" Q& _ return "./share/"; B1 l7 I) N8 W4 ^; c8 `' j
}
! \6 b* o9 f* {' b4 z) Y `( \ // 如果 share 目录不存在,使用当前目录; g( O2 K/ v5 g- u" ~4 ~# J1 G
return "./";
$ _- \1 J \; T6 |9 q# q }3 a: f* m- Z! O
' a8 Z6 C3 ^, {5 c) Q {
static std::string GetItemetcPath() {% F" z1 a( n0 B! j6 z
return GetSharePath() + "itemetc.csv";2 y! X% _, |$ [( t6 ?- p; W
}1 H0 Q# {/ e9 N7 A) m4 c& G! O, f+ w
7 C. L9 {6 P7 B9 d static std::string GetItemarmorPath() {
! b0 Y% U7 V* @$ u+ w$ [, j return GetSharePath() + "itemarmor.csv";' N$ c+ F G; @% ~* z) q k
}
; H6 Z% j% n2 _. }
+ J( H" s& o8 ?( G5 O# q static std::string GetItemweaponPath() {
& D2 f N8 R7 Y2 [3 T9 I return GetSharePath() + "itemweapon.csv";
2 w7 ] O6 R, N4 ^# f }2 C5 b1 Q& w0 p
4 _& b2 T/ E. V; b% R$ g- v
static std::string GetSkillnamePath() {2 n5 p ]1 N! X4 R+ k. b
return GetSharePath() + "skillname.csv";
( q2 r, b9 w' N! x) ^- u }
! c3 {0 D2 p' j8 \- c+ O
1 r9 m; K* U) R$ o" D: c* I/ k) fprivate:1 b q5 |! C: p, w
static bool DirectoryExists(const std::string& path) {/ @4 x' v1 H& X
// 实现目录存在性检查
; K( H9 P( s7 o/ T* j8 j struct stat info;5 }, u* t1 ^% p2 l g
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
4 R1 `% N9 p6 N- v6 U }3 M+ Z! \1 s; x1 q& @6 v' X3 u
}; |
|