问题:路径含 ( ) & % ! ^ @ 等字符时报"文件路径包含不允许的命令行特殊字符",
(D2-f)、(1) 这类正常业务文件名直接命中。
根因:读取统一入口把路径拼进命令行(cmd.exe /d /c type "..."),为"防炸"在 03d9b8b
引入 ForbiddenPathChars 黑名单——并非业务需求,是实现的自我约束。
实测:真正会坏的只有 %VAR%(必坏) 与延迟展开开启时的 !VAR!,而 ( ) & ^ @ 空格在
双引号内均正常;且 type 是字节透传,这层 cmd 对当初的编码问题毫无帮助。
改动:
- 新增 AnsiFileReader.cs:FileStream + StreamReader(默认 936 解码 + BOM 探测,
与旧 StreamReader 解码路径逐字符等价),不经命令行
- 删除 CommandTypeFileReader.cs 及其 ForbiddenPathChars 字符校验
- 路径只保留"非空"与"文件存在"校验;IO 异常包装为
InvalidOperationException("读取文件失败:{路径}({原因})")并保留 InnerException
- 15 处调用点同步改名;更新 CLAUDE.md 与 Docs 说明
验证:14 个 demo_drl 样例新旧实现字符串/行数逐字符一致;含特殊字符路径(含 %TEMP% 字面
路径,旧实现 rc=1)可读可解析;UTF-8/UTF-16 BOM 结果与旧实现一致;
dotnet build -p:Platform=x86 0 错误且警告集与基线逐条相同。
3.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
DrillTools (钻带处理工具) is a Windows desktop application for processing PCB drill tape files. It parses drill tape data, displays tool information (tool number, diameter, hole count, parameters), and supports reordering tools with various sorting methods.
Build & Run
dotnet build # Build the project
dotnet build -c Release # Build in Release mode
dotnet publish # Publish as single-file exe (win-x86)
Target: .NET 6.0, WPF, x86 only. No external NuGet dependencies.
No test framework is configured. Do not write unit tests for this project.
Architecture
MVVM pattern with three windows:
- MainWindow — primary UI for loading, viewing, and reordering drill tape tools
- ToolDetailWindow — displays detailed tool parameters
- ToolReorderConfirmationWindow — confirmation dialog for reorder operations
Key files:
| File | Role |
|---|---|
MainWindowViewModel.cs (~2400 lines) |
Central business logic: tool management, drill tape parsing/generation, sort seed management, reference tape comparison |
DrillTapeProcessor.cs |
Core drill tape parsing engine (DrillTools.Integration namespace) |
ToolItem.cs |
Data model for drill tools (implements INotifyPropertyChanged) |
SlotHoleCalculator.cs |
Geometry calculations for slot hole counts and positions |
DragDropHelper.cs |
WPF ListView drag-drop with visual insertion indicator |
Namespaces: DrillTools (UI/models), DrillTools.Integration (parsing logic).
Drill Tape Format
The app parses a specific PCB drill tape format:
M48 ← Header start
T01C0.799H05000Z+0.000S060.00 ← Tool definitions (Txx=tool#, C=diameter, rest=machine params)
T02C0.656H01500Z+0.150S070.00
% ← Header end / data start
T01 ← Active tool
X-167525Y013500 ← Hole coordinates
X-069659Y016450G85X-094159Y016450 ← Slot hole (start G85 end)
M30 ← End of file
Supported file extensions: .txt, .drl, .dr2, .dpin
Tool types by diameter suffix digit: 0/8/9=Drill, 1=Slot, 2/6=EA Slot, 3=Dust Slot, 4=Deburr, 5=NonStandard, 7=Special.
Important Technical Details
- File encoding: ANSI/GB2312 (code page 936) — drill tape files use this encoding, not UTF-8
- File reading: Drill tape / parameter files are read through
AnsiFileReader(directFileStream+StreamReaderwith ANSI/936 as the default encoding, BOM detection kept as before), never through a command line. Paths containing(,),&,%,!,^,@or spaces read fine. The oldcmd.exe /c typereader was removed on 2026-09-20 — there is no encryption layer (verified: alldemo_drl/samples decode identically via plain file I/O). - Slot hole calculation: Uses CAM350 standard tolerance (0.0127mm) for computing hole counts along slot paths
- Backup strategy: Creates
.bakfiles when saving modified drill tape data - Command-line support: App accepts a file path argument to auto-load a drill tape file on startup
- Documentation: All docs under
Docs/are in Chinese (Simplified). The UI is also in Chinese.