|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
3 P' j$ R5 ^5 H4 A, c" g, Npublic:6 H7 G5 i+ H* }
static std::string GetSharePath() {
% k5 d; n; }2 i4 K1 Y // 优先检查 share 目录
) ?' b3 j! v; `9 O/ v4 ~ if (DirectoryExists("./share/")) {# K, C: }0 z r8 I6 A
return "./share/";2 X/ n( ?0 P# k+ a3 _
}) r. `! J- U: ^- }- T" v
// 如果 share 目录不存在,使用当前目录
" v2 C6 t. l4 v# ~- j5 c! d return "./";& E1 i) t( {4 P4 E- F' S, |0 q0 ^
}
+ [5 T _# K2 L, [. Y4 b0 A7 U V" \0 H S# b3 R
static std::string GetItemetcPath() { r/ j2 M! u5 X5 Q2 M
return GetSharePath() + "itemetc.csv";
e% n1 a1 ~; |: } T+ g6 K8 E7 Y }: d# u! H- z3 Y9 y$ f2 I( N
+ R0 G1 ]- W0 [& o# F: ~
static std::string GetItemarmorPath() {0 } X7 m6 n: f( t' \, d. g( d
return GetSharePath() + "itemarmor.csv";- P$ \$ ~$ n/ p
}
4 S# n" ^& `5 a- S5 A: H% @4 {* S ) M# M! y8 F' v& V3 l
static std::string GetItemweaponPath() {- {5 c7 P' q- D' S
return GetSharePath() + "itemweapon.csv";
2 V7 H% Z$ M% u% { }
( D! Z+ G; O* `! d) M d' V4 t2 F# n* {3 x" t7 V
static std::string GetSkillnamePath() {
! Z5 L" } ]- c- z0 |$ f" x return GetSharePath() + "skillname.csv";3 e. u# ]) H6 m5 c- G8 _6 [ }
}0 Z; O9 k/ z6 }' H# s- R" h6 ~! S8 C
/ y( A# a+ s( u& l( k `! uprivate:4 Z- t' d" {0 B. D6 W
static bool DirectoryExists(const std::string& path) {5 S9 A' J5 w: @! K/ g1 f
// 实现目录存在性检查7 E/ M: z: B2 o. z# i# G3 m3 u
struct stat info;3 E. U- @8 y1 O# Q& a
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
/ t3 k- p9 J$ O) t }
5 H7 a8 \+ w" V# H}; |
|