|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
( L" N3 u" e, E+ i8 T# _public:
T2 j. l2 g) }" u) _/ b static std::string GetSharePath() {
# _0 z; U& \" C9 u' `9 m8 ` // 优先检查 share 目录
+ Q- @% T% c' p4 f+ t3 c/ O' f if (DirectoryExists("./share/")) {& i2 O. I4 |$ _0 o" ]2 G# {/ D5 T: q
return "./share/";) O3 g/ R) M1 G; _
}# f: P u3 j. L2 ~' {6 p
// 如果 share 目录不存在,使用当前目录! n) a4 |2 p. S- d6 _) J0 J
return "./";. h# V: F) j4 t
}$ n( X2 q3 ?2 w6 k+ y
: Q! ?! }% J+ s+ d: w static std::string GetItemetcPath() {$ }6 @/ j4 k- @
return GetSharePath() + "itemetc.csv";6 f8 u$ r H" x. E- Z+ l
}
# }. Y; Q4 H& h# j
) ^1 `0 O+ E. t; h" L static std::string GetItemarmorPath() {6 o. r2 ^/ Y' z# j4 A
return GetSharePath() + "itemarmor.csv";$ v' _% ]( x( S% ~; K& F& U
}
; K% r5 y" r u) M/ w; k ; a( M1 l9 s( j6 ~2 B% {2 @1 T
static std::string GetItemweaponPath() {
1 v( ]' t' Z4 U" A return GetSharePath() + "itemweapon.csv";4 ]4 i4 E5 l: z! D! x# z
}8 j2 n# J' S7 D) P4 X
# l; W$ J9 F8 d3 U% {8 B0 B: R, L
static std::string GetSkillnamePath() {
' n. Y5 n( i/ F: m0 i return GetSharePath() + "skillname.csv";
: z+ F* e' z+ z; y r: ^* u }
: O; }" G, F3 V; r# x/ F% C6 _ ) s9 t4 o7 D, b( \3 s! L
private:$ Z: R/ i9 h4 w" u2 f
static bool DirectoryExists(const std::string& path) {) `) v8 R: A+ P6 \
// 实现目录存在性检查
5 _: a+ N; B. a$ Z9 |3 j struct stat info;
3 q4 V0 w7 |. z, S( T. m return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);) G6 w$ s1 X5 M& P: j
}
4 b' k Q/ _5 a# O: `0 O3 T3 I}; |
|