tboox / tbox

🎁 A glib-like multi-platform c library
https://docs.tboox.org
Apache License 2.0
4.89k stars 725 forks source link

检测并避免 复制父目录到子目录 #270

Closed Doekin closed 3 days ago

Doekin commented 4 days ago

你在什么场景下需要该功能?

当文件结构如下时

.
└── ParentDir
    └── SubDir

调用tb_directory_copy("./ParentDir", "./ParentDir/SubDir",TB_FILE_COPY_NONE) ,会 coredump,并产生 ParentDir/SubDir/SubDir/SubDir/SubDir/SubDir/... 的结构

描述可能的解决方案

当路径参数有问题,会形成循环时,tb_directory_copy 返回 false

Issues-translate-bot commented 4 days ago

Bot detected the issue body's language is not English, translate it automatically.


Title: Detect and avoid copying parent directory to subdirectory

In what scenario do you need this function?

When the file structure is as follows

.
└── ParentDir
    └── SubDir

Calling tb_directory_copy("./ParentDir", "./ParentDir/SubDir",TB_FILE_COPY_NONE) will coredump and generate the structure of ParentDir/SubDir/SubDir/SubDir/SubDir/SubDir/...

Describe possible solutions

When there is a problem with the path parameters and a loop is formed, tb_directory_copy returns false

waruqi commented 3 days ago

这种你自己在外面检测下就好了,这边只提供最基础的跨平台实现,有些复杂的参数有效性检测,你外面自己也能做。。

Issues-translate-bot commented 3 days ago

Bot detected the issue body's language is not English, translate it automatically.


Just do the testing yourself outside. Here we only provide the most basic cross-platform implementation. You can also do some complex parameter validity testing outside. .

Doekin commented 3 days ago

OK