mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve importing Markdown folder https://github.com/siyuan-note/siyuan/issues/11567
This commit is contained in:
parent
d7407b74a5
commit
36493a8a3a
2 changed files with 27 additions and 0 deletions
|
|
@ -35,6 +35,28 @@ import (
|
|||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
func GetFilePathsByExts(dirPath string, exts []string) (ret []string) {
|
||||
filelock.Walk(dirPath, func(path string, info os.FileInfo, err error) error {
|
||||
if nil != err {
|
||||
logging.LogErrorf("get file paths by ext failed: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, ext := range exts {
|
||||
if strings.HasSuffix(path, ext) {
|
||||
ret = append(ret, path)
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func GetUniqueFilename(filePath string) string {
|
||||
if !gulu.File.IsExist(filePath) {
|
||||
return filePath
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue