mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
修复FileUtil无法正确识别Smb网络存储的路径问题
This commit is contained in:
parent
d2beedbf78
commit
e58a6055d6
@ -16,6 +16,7 @@
|
||||
* 【core 】 修复PathUtil.moveContent当target不存在时会报错问题(issue#3238@Github)
|
||||
* 【db 】 修复SqlUtil.formatSql 格式化的sql换行异常(pr#3247@Github)
|
||||
* 【core 】 修复DateUtil.parse 给定一个时间解析错误问题(issue#I7QI6R@Gitee)
|
||||
* 【core 】 修复FileUtil无法正确识别Smb网络存储的路径问题(issue#3253@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.21(2023-07-29)
|
||||
|
@ -1607,6 +1607,11 @@ public class FileUtil extends PathUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
//兼容Windows下的共享目录路径(原始路径如果以\\开头,则保留这种路径)
|
||||
if (path.startsWith("\\\\")) {
|
||||
return path;
|
||||
}
|
||||
|
||||
// 兼容Spring风格的ClassPath路径,去除前缀,不区分大小写
|
||||
String pathToUse = StrUtil.removePrefixIgnoreCase(path, URLUtil.CLASSPATH_URL_PREFIX);
|
||||
// 去除file:前缀
|
||||
@ -1621,10 +1626,6 @@ public class FileUtil extends PathUtil {
|
||||
pathToUse = pathToUse.replaceAll("[/\\\\]+", StrUtil.SLASH);
|
||||
// 去除开头空白符,末尾空白符合法,不去除
|
||||
pathToUse = StrUtil.trimStart(pathToUse);
|
||||
//兼容Windows下的共享目录路径(原始路径如果以\\开头,则保留这种路径)
|
||||
if (path.startsWith("\\\\")) {
|
||||
pathToUse = "\\" + pathToUse;
|
||||
}
|
||||
|
||||
String prefix = StrUtil.EMPTY;
|
||||
int prefixIndex = pathToUse.indexOf(StrUtil.COLON);
|
||||
|
@ -182,7 +182,9 @@ public class FileUtilTest {
|
||||
Assert.assertEquals("../../bar", FileUtil.normalize("../../bar"));
|
||||
Assert.assertEquals("C:/bar", FileUtil.normalize("/C:/bar"));
|
||||
Assert.assertEquals("C:", FileUtil.normalize("C:"));
|
||||
Assert.assertEquals("\\/192.168.1.1/Share/", FileUtil.normalize("\\\\192.168.1.1\\Share\\"));
|
||||
|
||||
// issue#3253,smb保留格式
|
||||
Assert.assertEquals("\\\\192.168.1.1\\Share\\", FileUtil.normalize("\\\\192.168.1.1\\Share\\"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
44
hutool-extra/src/test/java/cn/hutool/extra/qrcode/IssueI7RUIVTest.java
Executable file
44
hutool-extra/src/test/java/cn/hutool/extra/qrcode/IssueI7RUIVTest.java
Executable file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2023 looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package cn.hutool.extra.qrcode;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
|
||||
public class IssueI7RUIVTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void generateTest() {
|
||||
final QrConfig config = new QrConfig(300, 300);
|
||||
|
||||
// 设置前景色,既二维码颜色(青色)
|
||||
config.setForeColor(Color.CYAN);
|
||||
// 设置背景色(灰色)
|
||||
config.setBackColor(Color.GRAY);
|
||||
|
||||
// 生成二维码到文件,也可以到流
|
||||
final File file = QrCodeUtil.generate("https://hutool.cn/", config, FileUtil.file("d:/test/qrcode.jpg"));
|
||||
|
||||
// 识别二维码
|
||||
// decode -> "http://hutool.cn/"
|
||||
final String decode = QrCodeUtil.decode(ImgUtil.read("d:/test/qrcode.jpg"), true, true);
|
||||
Console.log("decode info = " + decode);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user