mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
improve file browser
This commit is contained in:
parent
394acbb5d2
commit
dd5a70a5c2
@ -159,12 +159,16 @@ static ret_t file_browser_remove_item_recursive(file_browser_t* fb, const char*
|
||||
return fs_remove_file(fb->fs, fullpath);
|
||||
} else if (st.is_dir) {
|
||||
fs_dir_t* dir = fs_open_dir(fb->fs, fullpath);
|
||||
if(dir != NULL) {
|
||||
if (dir != NULL) {
|
||||
fs_item_t info;
|
||||
char path[MAX_PATH + 1];
|
||||
while (fs_dir_read(dir, &info) == RET_OK) {
|
||||
if (tk_str_eq(info.name, ".") || tk_str_eq(info.name, "..")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ENSURE(path_build(path, MAX_PATH, fullpath, info.name, NULL) == RET_OK);
|
||||
if(file_browser_remove_item_recursive(fb->fs, fullpath) != RET_OK) {
|
||||
if (file_browser_remove_item_recursive(fb, fullpath) != RET_OK) {
|
||||
log_warn("file_browser_remove_item_recursive failed\n");
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ ret_t fs_os_remove_dir(fs_t* fs, const char* name) {
|
||||
if (rmdir(name) == 0) {
|
||||
return RET_OK;
|
||||
} else {
|
||||
perror("rmdir");
|
||||
perror(name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
@ -281,7 +281,7 @@ ret_t fs_os_create_dir(fs_t* fs, const char* name) {
|
||||
if (mkdir(name, 0755) == 0) {
|
||||
return RET_OK;
|
||||
} else {
|
||||
perror("mkdir");
|
||||
perror(name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "ext_widgets/file_browser/file_browser.h"
|
||||
|
||||
TEST(FileBrowser, prepare) {
|
||||
file_browser_t* fb = file_browser_create(os_fs());
|
||||
ASSERT_EQ(file_browser_set_cwd(fb, "./tests"), RET_OK);
|
||||
ASSERT_EQ(file_browser_refresh(fb), RET_OK);
|
||||
file_browser_remove(fb, "fbtest");
|
||||
ASSERT_EQ(file_browser_refresh(fb), RET_OK);
|
||||
|
||||
file_browser_create_dir(fb, "fbtest");
|
||||
file_browser_destroy(fb);
|
||||
}
|
||||
|
||||
TEST(FileBrowser, dir) {
|
||||
fb_item_t* item = NULL;
|
||||
file_browser_t* fb = file_browser_create(os_fs());
|
||||
|
Loading…
Reference in New Issue
Block a user