路径里的反斜杠在 Linux 上换成斜杠
- 教材写 AppDomain.CurrentDomain.BaseDirectory + "Camera\\",Linux 上反斜杠会成为文件名的一部分 - 编译时把传给 System.IO(File、Directory、Path、各种 Stream)和 Image / Bitmap 读写文件方法的 路径参数包上 Sim.Host.WindowsPaths.Fix;只包语义上确实是这些方法里名字带 path / file / dir 的 字符串参数,不换行,编辑器里看到的仍是原代码 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2cd0111967
commit
5ae07b851d
3 files changed
+92
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Sim.Host;
|
||||
|
||||
/// <summary>
|
||||
/// Windows 写法的路径(教材里常见 BaseDirectory + "Camera\\")在 Linux 上要把反斜杠换成斜杠,否则反斜杠成了文件名的一部分。
|
||||
/// 编译时把学生代码里传给文件、文件夹、图片读写方法的路径参数包上这个方法(见 Sim.Runner/PathRewriter.cs)。
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class WindowsPaths
|
||||
{
|
||||
public static string Fix(string path) => path?.Replace('\\', '/')!;
|
||||
}
|
||||
Reference in new issue
Block a user