Skip to content

Commit 118b08a

Browse files
committed
fix - Fixed the issue where adding a signature could not be saved.
1 parent e5e3bce commit 118b08a

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

  • ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/CFileUtils.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ public static void createFile(File file, boolean isFile) {// 创建文件
104104
try {
105105
if (!file.exists()) {
106106
// 如果文件不存在
107-
File parentFile = file.getParentFile();
108-
if (parentFile != null && parentFile.exists()) {
107+
if (!file.getParentFile().exists()) {
109108
// 如果文件父目录不存在
110109
createFile(file.getParentFile(), false);
111110
} else {
@@ -130,10 +129,7 @@ public static String copyFileToInternalDirectory(
130129
) {
131130
try {
132131
File file = new File(dir, fileName);
133-
File parentFile = file.getParentFile();
134-
if (parentFile != null){
135-
parentFile.mkdirs();
136-
}
132+
file.getParentFile().mkdirs();
137133

138134
ContentResolver cr = context.getContentResolver();
139135
ParcelFileDescriptor fd = cr.openFileDescriptor(uri, "r");
@@ -532,18 +528,16 @@ public static boolean deleteDirectory(String filePath) {
532528
}
533529
boolean flag = true;
534530
File[] files = dirFile.listFiles();
535-
if (files != null){
536-
for (File file : files) {
537-
if (file.isFile()) {
538-
flag = deleteSingleFile(file.getAbsolutePath());
539-
if (!flag)
540-
break;
541-
} else if (file.isDirectory()) {
542-
flag = deleteDirectory(file
543-
.getAbsolutePath());
544-
if (!flag)
545-
break;
546-
}
531+
for (File file : files) {
532+
if (file.isFile()) {
533+
flag = deleteSingleFile(file.getAbsolutePath());
534+
if (!flag)
535+
break;
536+
} else if (file.isDirectory()) {
537+
flag = deleteDirectory(file
538+
.getAbsolutePath());
539+
if (!flag)
540+
break;
547541
}
548542
}
549543
if (!flag) {
@@ -586,9 +580,9 @@ public static void startPrint(Context context, String filePath, Uri uri) {
586580
public static void copyAssetsDirToPhone(Activity activity, String assetsPath, String outPutParentDir){
587581
try {
588582
String[] fileList = activity.getAssets().list(assetsPath);
589-
if(fileList != null && fileList.length>0) {//如果是目录
590-
File file = new File(outPutParentDir+ File.separator+assetsPath);
591-
boolean result = file.mkdirs();//如果文件夹不存在,则递归
583+
if(fileList.length>0) {//如果是目录
584+
File file=new File(outPutParentDir+ File.separator+assetsPath);
585+
file.mkdirs();//如果文件夹不存在,则递归
592586
for (String fileName:fileList){
593587
assetsPath=assetsPath+File.separator+fileName;
594588
copyAssetsDirToPhone(activity,assetsPath, outPutParentDir);

0 commit comments

Comments
 (0)