|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {# J: P) f3 ]( V* W3 t+ s+ i( {
public:
9 a8 |& U( M- s9 ^5 h static std::string GetSharePath() {
q8 N$ {" D; Y // 优先检查 share 目录# }2 Y% [4 i" u0 @& `8 R4 O
if (DirectoryExists("./share/")) {3 g/ ~* y8 p5 k$ \( _
return "./share/";9 j& ]0 Z) F: T, i @& t# y. L+ r
}
- T8 W5 H( m9 Y; T8 A // 如果 share 目录不存在,使用当前目录$ T- |( H" i2 i- Y& [
return "./";
: D- l A# ~. `& ?( T* _ }8 y& @3 I: E0 I' o
' P5 Z5 S5 K: k6 J7 F. t
static std::string GetItemetcPath() {4 y3 o/ P! T, r/ A
return GetSharePath() + "itemetc.csv";
) x" {* R" F0 ^# |& `4 X }
+ q& c/ c; F- f f 6 |. m9 |$ @$ G
static std::string GetItemarmorPath() {
* s0 i& `* u g, U3 q return GetSharePath() + "itemarmor.csv";0 F* J- _9 h% B
}
! N2 b' s7 h8 T+ c0 [9 `7 Q( M+ x+ B : e. R( ^2 k9 v9 r; E9 A, r
static std::string GetItemweaponPath() {% L# D! ^$ V5 u$ f- u! G) j! O
return GetSharePath() + "itemweapon.csv";
( B# b3 ~0 v+ s0 D x) y6 | }
1 |% ]0 O7 G$ @, f3 Z* j
4 S& s9 h% Y+ M8 ?9 S static std::string GetSkillnamePath() {
+ e: i- G/ \! I3 Z6 L" V' I return GetSharePath() + "skillname.csv";
! M% z5 u. S g) P. `% q }
9 N2 T' q3 }& m k, t; d6 d6 M
- |& f1 }8 i& m) ^private:
; q& j s) ^# n9 L$ _ static bool DirectoryExists(const std::string& path) {4 K% v) o+ }9 g9 }: j
// 实现目录存在性检查$ j3 o+ x* J: n8 D+ H0 U) ^
struct stat info;& C- X7 U B# J
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
; D* U, y9 f4 _7 ` }- A$ K# \& n# o
}; |
|