|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {
9 A3 L }1 S- gpublic:
0 I$ p8 E" {1 ~$ d# I' B( p static std::string GetSharePath() {0 a5 M; b. O: D
// 优先检查 share 目录
+ w1 P8 n6 L8 x- d; h3 S" Z if (DirectoryExists("./share/")) {, e( s$ R; @# n' i/ b
return "./share/";
, \5 i' L) T; N7 l6 q }9 N r2 y. ~) o: K7 {+ d3 K- ~
// 如果 share 目录不存在,使用当前目录
9 Y5 T2 `; [9 J& T6 I4 ]7 N return "./";
, U3 q2 P$ P( h/ y# D( s8 y }' T) s4 B# H; P
3 z! N5 n, a2 }5 u* G
static std::string GetItemetcPath() {
# ], Y$ W ?+ i( \ return GetSharePath() + "itemetc.csv";9 d& K* H6 Z! m- c
}
: B$ P7 u/ Z2 n7 w% P+ d # U! w1 I4 c0 l
static std::string GetItemarmorPath() {* j+ r* g6 P' C$ [. A _. k; n' g% I
return GetSharePath() + "itemarmor.csv";! x- Z9 X% P! l3 e Y6 I3 ~/ E& L
}4 ]& \' k$ C+ F
' A N2 y+ M+ w3 b* X
static std::string GetItemweaponPath() {- [# i3 o5 Y7 ~) ^# h( F2 O
return GetSharePath() + "itemweapon.csv";
, O) e+ {; i# p& J }! }) K" H% V z0 u, f8 b; s4 u" F
' V/ o- D+ _; o( K% |, E+ {
static std::string GetSkillnamePath() {
2 [* k# `2 _ `8 S2 \ return GetSharePath() + "skillname.csv";8 ]# X# [+ W4 s& W/ X7 h
}( K+ i: f, D$ [& ?% K
5 m3 t2 I5 _$ R) y* hprivate:- x1 S( e7 y: L K- L- |7 S- G
static bool DirectoryExists(const std::string& path) {
9 H0 [$ ^7 U' Q0 c // 实现目录存在性检查
) i% o+ f& b4 G+ ~1 S struct stat info;1 s' }7 e O7 Z/ q
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
4 b4 s' G( w% F9 V% v# j3 Q6 Q }
4 g1 W* g2 B& f6 m1 o1 }( ?/ v}; |
|