Skip to content

Commit

Permalink
chore(fs_posix): remove win32 support (lvgl#5365)
Browse files Browse the repository at this point in the history
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
  • Loading branch information
FASTSHIFT authored Jan 18, 2024
1 parent b9f6dfd commit 8cba067
Showing 1 changed file with 3 additions and 66 deletions.
69 changes: 3 additions & 66 deletions src/libs/fsdrv/lv_fs_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#ifndef WIN32
#include <dirent.h>
#include <unistd.h>
#else
#include <windows.h>
#endif
#include <dirent.h>
#include <unistd.h>

#include "../../core/lv_global.h"
/*********************
* DEFINES
*********************/
Expand Down Expand Up @@ -218,10 +213,6 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
return offset < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK;
}

#ifdef WIN32
static char next_fn[256];
#endif

/**
* Initialize a 'fs_read_dir_t' variable for directory reading
* @param drv pointer to a driver where this function belongs
Expand All @@ -232,38 +223,10 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
{
LV_UNUSED(drv);

#ifndef WIN32
/*Make the path relative to the current directory (the projects root folder)*/
char buf[256];
lv_snprintf(buf, sizeof(buf), LV_FS_POSIX_PATH "%s", path);
return opendir(buf);
#else
HANDLE d = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fdata;

/*Make the path relative to the current directory (the projects root folder)*/
char buf[256];
lv_snprintf(buf, sizeof(buf), LV_FS_POSIX_PATH "%s\\*", path);

lv_strcpy(next_fn, "");
d = FindFirstFile(buf, &fdata);
do {
if(lv_strcmp(fdata.cFileName, ".") == 0 || lv_strcmp(fdata.cFileName, "..") == 0) {
continue;
}
else {
if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
lv_snprintf(next_fn, sizeof(next_fn), "/%s", fdata.cFileName);
}
else {
lv_snprintf(next_fn, sizeof(next_fn), "%s", fdata.cFileName);
}
break;
}
} while(FindNextFileA(d, &fdata));

return d;
#endif
}

/**
Expand All @@ -278,7 +241,6 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn, uint3
{
LV_UNUSED(drv);

#ifndef WIN32
struct dirent * entry;
do {
entry = readdir(dir_p);
Expand All @@ -290,29 +252,7 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn, uint3
lv_strncpy(fn, "", fn_len);
}
} while(lv_strcmp(fn, "/.") == 0 || lv_strcmp(fn, "/..") == 0);
#else
lv_strncpy(fn, next_fn, fn_len);

lv_strncpy(next_fn, "", fn_len);
WIN32_FIND_DATA fdata;

if(FindNextFile(dir_p, &fdata) == false) return LV_FS_RES_OK;
do {
if(lv_strcmp(fdata.cFileName, ".") == 0 || lv_strcmp(fdata.cFileName, "..") == 0) {
continue;
}
else {
if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
lv_snprintf(next_fn, sizeof(next_fn), "/%s", fdata.cFileName);
}
else {
lv_snprintf(next_fn, sizeof(next_fn), "%s", fdata.cFileName);
}
break;
}
} while(FindNextFile(dir_p, &fdata));

#endif
return LV_FS_RES_OK;
}

Expand All @@ -325,11 +265,8 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn, uint3
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
{
LV_UNUSED(drv);
#ifndef WIN32

closedir(dir_p);
#else
FindClose(dir_p);
#endif
return LV_FS_RES_OK;
}
#else /*LV_USE_FS_POSIX == 0*/
Expand Down

0 comments on commit 8cba067

Please sign in to comment.