|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
3 g7 S: `, {" O, spublic:; n- p8 ^* d! Q
static std::string GetSharePath() {) ` |9 q2 Z8 p6 j
// 优先检查 share 目录' N# h- R2 J4 e
if (DirectoryExists("./share/")) {
) n1 w& }$ B+ ^1 Q8 o return "./share/";
6 f# q. {& C( j: n8 r' T }
7 `1 W8 u/ Q5 F2 E$ D& d7 A // 如果 share 目录不存在,使用当前目录( Q0 ]7 X: }* P p. Z- H F. h
return "./";4 V0 K% [+ V' c+ o( x
}5 s T1 e4 N! i, _
: B. p) L$ Q" ~
static std::string GetItemetcPath() {
' O6 y$ R* ~3 {: U- M return GetSharePath() + "itemetc.csv";8 s# u' f x7 d$ u0 h$ |
}
) [! x: q8 J7 m# U
: r' J2 _% V' ~0 J/ d static std::string GetItemarmorPath() {
8 M& q" H8 G9 a- ?' q( \2 ] return GetSharePath() + "itemarmor.csv";, { D2 P# M. C6 |6 g) O+ l) r
}
) S3 K# R& @( m. b 5 m7 [# i/ h+ h# O# r
static std::string GetItemweaponPath() {
) |7 t, l! L# ]" `; x. S8 S return GetSharePath() + "itemweapon.csv";
0 V6 _9 [- ~% h }: x& c# x8 Z2 g
1 G G4 a+ { u7 j; x static std::string GetSkillnamePath() {
4 y0 ~4 q6 Q4 h3 D3 ` return GetSharePath() + "skillname.csv";" H) S$ T4 s/ M. l4 a3 N L
}
! r; u+ Z) ~4 x, ~) ~' @
2 O& u( R. R. n4 Q) I$ ^private:4 T$ k- Y" O) F- t
static bool DirectoryExists(const std::string& path) {
; O- ?. b+ u [+ }/ ?) k // 实现目录存在性检查
! s- o& z9 A6 f U: q6 a% _ struct stat info;
V: \: l# j: D return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
& f5 c2 A6 i& M3 R* E }
( h. Z I+ u0 T}; |
|