diff --git a/src/platforms/pc/fs_os.c b/src/platforms/pc/fs_os.c index b0c3ae56d..e205e2287 100644 --- a/src/platforms/pc/fs_os.c +++ b/src/platforms/pc/fs_os.c @@ -170,8 +170,17 @@ static ret_t fs_os_dir_read(fs_dir_t* dir, fs_item_t* item) { memset(item, 0x00, sizeof(fs_item_t)); if (ent != NULL) { #ifdef QNX - /*FIXME*/ - item->is_reg_file = 1; + struct stat st; + char filename[MAX_PATH + 1] = {0}; + tk_snprintf(filename, sizeof(filename) - 1, "%s/%s", dir->dirname, ent->d_name); + + if (stat(filename, &st) == 0) { + item->is_dir = (st.st_mode & S_IFDIR) != 0; + item->is_link = (st.st_mode & S_IFLNK) != 0; + item->is_reg_file = (st.st_mode & S_IFREG) != 0; + } else { + item->is_reg_file = 1; + } #else uint8_t type = ent->d_type; item->is_dir = (type & DT_DIR) != 0; diff --git a/src/tkc/fs.c b/src/tkc/fs.c index b926930c2..9176821f7 100644 --- a/src/tkc/fs.c +++ b/src/tkc/fs.c @@ -145,7 +145,7 @@ ret_t fs_dir_read(fs_dir_t* dir, fs_item_t* item) { ret_t fs_dir_close(fs_dir_t* dir) { return_value_if_fail(dir != NULL && dir->vt != NULL && dir->vt->close != NULL, RET_BAD_PARAMS); - + TKMEM_FREE(dir->dirname); return dir->vt->close(dir); } @@ -175,9 +175,14 @@ ret_t fs_file_rename(fs_t* fs, const char* name, const char* new_name) { } fs_dir_t* fs_open_dir(fs_t* fs, const char* name) { + fs_dir_t* dir = NULL; return_value_if_fail(fs != NULL && fs->open_dir != NULL && name != NULL, NULL); - return fs->open_dir(fs, name); + dir = fs->open_dir(fs, name); + return_value_if_fail(dir != NULL, NULL); + dir->dirname = tk_strdup(name); + + return dir; } ret_t fs_remove_dir(fs_t* fs, const char* name) { diff --git a/src/tkc/fs.h b/src/tkc/fs.h index 854bfd87c..7407941dc 100644 --- a/src/tkc/fs.h +++ b/src/tkc/fs.h @@ -364,6 +364,7 @@ typedef struct _fs_dir_vtable_t { struct _fs_dir_t { const fs_dir_vtable_t* vt; void* data; + char* dirname; }; /**