@@ -23,7 +23,10 @@ public ActionResult<List<OptionDirInfo>> GetOptionDirs()
2323 var isCustom = false ;
2424 if ( source != "A000" )
2525 {
26- var markPath = Path . Combine ( StaticSettings . GamePath , "bin" , "option" , source , "CustomChartsMark.txt" ) ;
26+ var optionPath = scanner . OptionPaths . TryGetValue ( source , out var discoveredPath )
27+ ? discoveredPath
28+ : OptionPathResolver . ResolveExisting ( StaticSettings . GamePath , source ) ;
29+ var markPath = optionPath == null ? "" : Path . Combine ( optionPath , "CustomChartsMark.txt" ) ;
2730 isCustom = System . IO . File . Exists ( markPath ) ;
2831 }
2932 var version = ReadOptVersion ( source ) ;
@@ -41,8 +44,8 @@ public ActionResult ToggleCustomMark([FromBody] string dirName)
4144 if ( dirName == "A000" )
4245 return BadRequest ( "不能修改基础包标记" ) ;
4346
44- var optionRoot = Path . Combine ( StaticSettings . GamePath , "bin" , "option" ) ;
45- var markPath = Path . Combine ( optionRoot , dirName , "CustomChartsMark.txt" ) ;
47+ var optionPath = OptionPathResolver . ResolveWritePath ( StaticSettings . GamePath , dirName ) ;
48+ var markPath = Path . Combine ( optionPath , "CustomChartsMark.txt" ) ;
4649
4750 if ( System . IO . File . Exists ( markPath ) )
4851 System . IO . File . Delete ( markPath ) ;
@@ -93,12 +96,10 @@ public ActionResult CreateOptionDir([FromBody] string dirName)
9396 if ( string . IsNullOrWhiteSpace ( dirName ) )
9497 return BadRequest ( "目录名不能为空" ) ;
9598
96- var optionRoot = Path . Combine ( StaticSettings . GamePath , "bin" , "option" ) ;
97- var target = Path . Combine ( optionRoot , dirName ) ;
98-
99- if ( Directory . Exists ( target ) )
99+ if ( OptionPathResolver . ResolveExisting ( StaticSettings . GamePath , dirName ) != null )
100100 return BadRequest ( "目录已存在" ) ;
101101
102+ var target = Path . Combine ( StaticSettings . GamePath , "bin" , "option" , dirName ) ;
102103 Directory . CreateDirectory ( target ) ;
103104 Directory . CreateDirectory ( Path . Combine ( target , "music" ) ) ;
104105
@@ -119,10 +120,9 @@ public ActionResult DeleteOptionDir([FromBody] string dirName)
119120 if ( dirName == "A000" )
120121 return BadRequest ( "不能删除基础包" ) ;
121122
122- var optionRoot = Path . Combine ( StaticSettings . GamePath , "bin" , "option" ) ;
123- var target = Path . Combine ( optionRoot , dirName ) ;
123+ var target = OptionPathResolver . ResolveExisting ( StaticSettings . GamePath , dirName ) ;
124124
125- if ( ! Directory . Exists ( target ) )
125+ if ( target == null || ! Directory . Exists ( target ) )
126126 return NotFound ( "目录不存在" ) ;
127127
128128 Directory . Delete ( target , true ) ;
@@ -162,7 +162,7 @@ public ActionResult ImportLocalOptionDir()
162162 var optionRoot = Path . Combine ( StaticSettings . GamePath , "bin" , "option" ) ;
163163 var dest = Path . Combine ( optionRoot , dirName ) ;
164164
165- if ( Directory . Exists ( dest ) )
165+ if ( OptionPathResolver . ResolveExisting ( StaticSettings . GamePath , dirName ) != null )
166166 {
167167 dirName = $ "{ dirName } _{ DateTime . Now : yyyyMMddHHmmss} ";
168168 dest = Path . Combine ( optionRoot , dirName ) ;
@@ -196,8 +196,8 @@ public ActionResult RescanOptions()
196196 return null ;
197197 var dataPath = Path . Combine ( StaticSettings . GamePath , "data" , dirName ) ;
198198 if ( Directory . Exists ( dataPath ) ) return dataPath ;
199- var optionPath = Path . Combine ( StaticSettings . GamePath , "bin" , "option" , dirName ) ;
200- if ( Directory . Exists ( optionPath ) ) return optionPath ;
199+ var optionPath = OptionPathResolver . ResolveExisting ( StaticSettings . GamePath , dirName ) ;
200+ if ( optionPath != null ) return optionPath ;
201201 return null ;
202202 }
203203
0 commit comments