|
|
发表于 2025-11-4 08:38:23
|
显示全部楼层
class Config {, l& z) p! n8 c. ^2 `
public:6 _% {: L/ H! m
static std::string GetSharePath() {
7 p) i9 C4 Z6 u# X$ f9 s% v6 w" c // 优先检查 share 目录
' q5 U( n3 d! E if (DirectoryExists("./share/")) {/ T7 K4 ^$ o* b5 _2 I
return "./share/";& }$ l3 _& h+ V1 p! b) f a
}. h3 h. L$ f: j+ h' y- L
// 如果 share 目录不存在,使用当前目录/ J. @: f q5 z6 K
return "./";( F z, X& \' y+ w( b+ f' O
}& y9 R0 L+ S4 [
6 y1 `8 b3 @, ~; m- g5 U2 Y. g: J f7 K static std::string GetItemetcPath() {2 a+ V+ U7 @) J4 g* |5 k# W6 ]
return GetSharePath() + "itemetc.csv";7 Z) H/ c+ r' i3 W
}
( E% H: H+ D% [9 w4 v# Q3 s
1 p7 H2 b% z9 V, v& g0 C2 d static std::string GetItemarmorPath() {
; v! k( g! ~7 j* U4 [4 D9 o return GetSharePath() + "itemarmor.csv";. q3 N) ^* ?; s, _
}
7 T7 Q. W# p9 A( w* G
* b5 k0 z) i( ~4 T- c static std::string GetItemweaponPath() {
! R* A+ F- |4 s: t$ x" m: ]4 O return GetSharePath() + "itemweapon.csv";
g, |, Z0 H# d9 }+ M }& F7 ?% ^) v O1 Z% W" U+ ?
* A% b$ \* {" `+ x. Q) E
static std::string GetSkillnamePath() {
/ v& [+ O) I3 f- D0 m! N- F- J; a return GetSharePath() + "skillname.csv";
+ h( q r1 k' y. r+ ] }7 `. g- S& L+ t1 C1 m+ X! B
2 f# M. Q6 ^3 d- y# R. R
private:4 o! L9 t. n: T- d1 y9 l( a' V, R/ H
static bool DirectoryExists(const std::string& path) {; v, ^% i* m0 g5 X7 y$ j
// 实现目录存在性检查6 L! d! c) f4 m
struct stat info;; U# ?' {7 v, o. `; |* N- Z
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
! w) K! `4 ]* ^% K+ s- h( F. H+ `2 M }
9 N4 T, i6 p* \}; |
|