getDirName static method
Implementation
static String getDirName(String filePath) {
if (filePath.isEmpty) return "";
// 規範化路徑並轉換為系統分隔符
final normalized = path.normalize(filePath);
// 查找最後一個分隔符位置
final lastSep = normalized.lastIndexOf(path.separator);
// 若找不到分隔符返回空字符串
if (lastSep == -1) return "";
// 截取目錄路徑 (包含結尾分隔符)
return normalized.substring(0, lastSep + 1);
}