|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
# v, ]5 |/ I1 y4 Z/ w- t& {9 s) lpublic:
( J! e) [" l8 v% T( G8 ?) W E static std::string GetSharePath() {
: o* A% t# M$ U, I. Q1 v // 优先检查 share 目录
' ]& `! G: _* A$ E if (DirectoryExists("./share/")) {
: h0 ~0 P/ X+ z. ] A7 I return "./share/";
, G/ x- w+ M/ e. g$ S' n; u6 Y5 O) B }
0 e6 _) ?# ^4 T( i7 Q0 i6 R // 如果 share 目录不存在,使用当前目录
. q4 v; M6 N+ y% q0 D return "./";
. M; K; m& N, `( y- c/ F3 C8 w }; t5 N9 d# Q; C! k
3 F, `1 u3 Y) a: s8 P+ V$ x static std::string GetItemetcPath() {
8 B- {9 D5 @7 f2 H, l y return GetSharePath() + "itemetc.csv";
2 P% U4 | m4 h+ {( c6 N, H+ a j }
) D/ w/ s1 Y/ ^& Q y. [: H, [
c$ a( ?* [$ g2 c) ~. F static std::string GetItemarmorPath() {. `. m! H3 Q' b
return GetSharePath() + "itemarmor.csv";5 \. h7 L/ [& ^$ b+ l+ Z3 p# {6 x
}* i4 ?( f! D! f% D; D0 J
1 R# Y" H" c: j+ _$ F
static std::string GetItemweaponPath() {) F1 o$ G$ \6 u3 p' D+ R' W% P* l
return GetSharePath() + "itemweapon.csv";, A) ?% _9 G; `5 D# \7 z
}/ g$ o/ {7 Q8 T# [" f/ O& [
" U2 d. k9 u" Q' _( Z- f; ~( F
static std::string GetSkillnamePath() {
- L, E0 A+ D! u9 \1 Z return GetSharePath() + "skillname.csv";
V \5 D7 V: i r; s$ D, N! s }8 {) g% p! s8 c( z; ?) q% \
' r) y/ T, g: W$ z; pprivate:. F. {6 M6 x, Q; Z$ @8 C
static bool DirectoryExists(const std::string& path) {
4 ^6 [/ Y4 [) e- d0 s: w // 实现目录存在性检查
% f& t" Q0 ~. N2 A5 [1 ~+ @% T8 v struct stat info;6 t# N( a8 k. T1 i) g
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);5 M7 `6 j7 ?2 y5 ^5 z. ?# @2 Q
}" v' E- s; e# [) u
}; |
|