chore(fs): treat '/' as valid driver letter (#6986)

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu
2024-10-29 17:34:55 +08:00
committed by GitHub
parent d7e1f265c6
commit 133d2fe4be
10 changed files with 26 additions and 90 deletions

View File

@@ -163,7 +163,7 @@ for line in fin.read().splitlines():
fout.write(f'{line}\n') fout.write(f'{line}\n')
fout.write( fout.write(
''' r'''
/*---------------------------------- /*----------------------------------
* End of parsing lv_conf_template.h * End of parsing lv_conf_template.h
@@ -214,6 +214,9 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
#endif #endif
#endif #endif
/*Allow only upper case letters and '/' ('/' is a special case for backward compatibility)*/
#define LV_FS_IS_VALID_LETTER(l) ((l) == '/' || ((l) >= 'A' && (l) <= 'Z'))
/* If running without lv_conf.h, add typedefs with default value. */ /* If running without lv_conf.h, add typedefs with default value. */
#ifdef LV_CONF_SKIP #ifdef LV_CONF_SKIP
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/

View File

@@ -4,17 +4,8 @@
#include "../../core/lv_global.h" #include "../../core/lv_global.h"
#include "LittleFS.h" #include "LittleFS.h"
#if LV_FS_ARDUINO_ESP_LITTLEFS_LETTER == '\0' #if !LV_FS_IS_VALID_LETTER(LV_FS_ARDUINO_ESP_LITTLEFS_LETTER)
#error "LV_FS_ARDUINO_ESP_LITTLEFS_LETTER must be set to a valid value" #error "Invalid drive letter"
#else
#if (LV_FS_ARDUINO_ESP_LITTLEFS_LETTER < 'A') || (LV_FS_ARDUINO_ESP_LITTLEFS_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_ARDUINO_ESP_LITTLEFS_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_ARDUINO_ESP_LITTLEFS_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
typedef struct ArduinoEspLittleFile { typedef struct ArduinoEspLittleFile {
@@ -198,4 +189,3 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
#endif #endif
#endif /*LV_USE_FS_ARDUINO_ESP_LITTLEFS*/ #endif /*LV_USE_FS_ARDUINO_ESP_LITTLEFS*/

View File

@@ -5,17 +5,8 @@
#include <SPI.h> #include <SPI.h>
#include "SD.h" #include "SD.h"
#if LV_FS_ARDUINO_SD_LETTER == '\0' #if !LV_FS_IS_VALID_LETTER(LV_FS_ARDUINO_SD_LETTER)
#error "LV_FS_ARDUINO_SD_LETTER must be set to a valid value" #error "Invalid drive letter"
#else
#if (LV_FS_ARDUINO_SD_LETTER < 'A') || (LV_FS_ARDUINO_SD_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_ARDUINO_SD_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_ARDUINO_SD_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
typedef struct SdFile { typedef struct SdFile {

View File

@@ -20,17 +20,8 @@
#define DIR FF_DIR /* ESP IDF typedefs `DIR` as `FF_DIR` in its version of ff.h. Use `FF_DIR` in LVGL too */ #define DIR FF_DIR /* ESP IDF typedefs `DIR` as `FF_DIR` in its version of ff.h. Use `FF_DIR` in LVGL too */
#endif #endif
#if LV_FS_FATFS_LETTER == '\0' #if !LV_FS_IS_VALID_LETTER(LV_FS_FATFS_LETTER)
#error "LV_FS_FATFS_LETTER must be set to a valid value" #error "Invalid drive letter"
#else
#if (LV_FS_FATFS_LETTER < 'A') || (LV_FS_FATFS_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_FATFS_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_FATFS_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
/********************** /**********************

View File

@@ -4,17 +4,8 @@
#include "lfs.h" #include "lfs.h"
#include "../../core/lv_global.h" #include "../../core/lv_global.h"
#if LV_FS_LITTLEFS_LETTER == '\0' #if !LV_FS_IS_VALID_LETTER(LV_FS_LITTLEFS_LETTER)
#error "LV_FS_LITTLEFS_LETTER must be set to a valid value" #error "Invalid drive letter"
#else
#if (LV_FS_LITTLEFS_LETTER < 'A') || (LV_FS_LITTLEFS_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_LITTLEFS_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_LITTLEFS_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
typedef struct LittleFile { typedef struct LittleFile {

View File

@@ -47,17 +47,9 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#if LV_FS_MEMFS_LETTER == '\0'
#error "LV_FS_MEMFS_LETTER must be set to a valid value" #if !LV_FS_IS_VALID_LETTER(LV_FS_MEMFS_LETTER)
#else #error "Invalid drive letter"
#if (LV_FS_MEMFS_LETTER < 'A') || (LV_FS_MEMFS_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_MEMFS_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_MEMFS_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
/********************** /**********************

View File

@@ -22,17 +22,8 @@
* DEFINES * DEFINES
*********************/ *********************/
#if LV_FS_POSIX_LETTER == '\0' #if !LV_FS_IS_VALID_LETTER(LV_FS_POSIX_LETTER)
#error "LV_FS_POSIX_LETTER must be set to a valid value" #error "Invalid drive letter"
#else
#if (LV_FS_POSIX_LETTER < 'A') || (LV_FS_POSIX_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_POSIX_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_POSIX_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
/** The reason for 'fd + 1' is because open() may return a legal fd with a value of 0, /** The reason for 'fd + 1' is because open() may return a legal fd with a value of 0,

View File

@@ -21,17 +21,9 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#if LV_FS_STDIO_LETTER == '\0'
#error "LV_FS_STDIO_LETTER must be set to a valid value" #if !LV_FS_IS_VALID_LETTER(LV_FS_STDIO_LETTER)
#else #error "Invalid drive letter"
#if (LV_FS_STDIO_LETTER < 'A') || (LV_FS_STDIO_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_STDIO_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_STDIO_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
#define MAX_PATH_LEN 256 #define MAX_PATH_LEN 256

View File

@@ -17,17 +17,9 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#if LV_FS_WIN32_LETTER == '\0'
#error "LV_FS_WIN32_LETTER must be set to a valid value" #if !LV_FS_IS_VALID_LETTER(LV_FS_WIN32_LETTER)
#else #error "Invalid drive letter"
#if (LV_FS_WIN32_LETTER < 'A') || (LV_FS_WIN32_LETTER > 'Z')
#if LV_FS_DEFAULT_DRIVE_LETTER != '\0' /*When using default drive letter, strict format (X:) is mandatory*/
#error "LV_FS_WIN32_LETTER must be an upper case ASCII letter"
#else /*Lean rules for backward compatibility*/
#warning LV_FS_WIN32_LETTER should be an upper case ASCII letter. \
Using a slash symbol as drive letter should be replaced with LV_FS_DEFAULT_DRIVE_LETTER mechanism
#endif
#endif
#endif #endif
#define MAX_PATH_LEN 256 #define MAX_PATH_LEN 256

View File

@@ -4078,6 +4078,9 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
#endif #endif
#endif #endif
/*Allow only upper case letters and '/' ('/' is a special case for backward compatibility)*/
#define LV_FS_IS_VALID_LETTER(l) ((l) == '/' || ((l) >= 'A' && (l) <= 'Z'))
/* If running without lv_conf.h, add typedefs with default value. */ /* If running without lv_conf.h, add typedefs with default value. */
#ifdef LV_CONF_SKIP #ifdef LV_CONF_SKIP
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/