Merge pull request #3898 from elms/intime_rtos/crl_directory_fix
INTIME: add support for directory file search
This commit is contained in:
commit
f201d65459
@ -14,7 +14,7 @@ extern "C" {
|
||||
#define INTIME_RTOS
|
||||
|
||||
#undef WOLF_EXAMPLES_STACK
|
||||
#define WOLF_EXAMPLES_STACK 65536
|
||||
#define WOLF_EXAMPLES_STACK (1<<17)
|
||||
|
||||
#undef WOLFSSL_GENERAL_ALIGNMENT
|
||||
#define WOLFSSL_GENERAL_ALIGNMENT 4
|
||||
@ -27,7 +27,7 @@ extern "C" {
|
||||
|
||||
/* disable directory support */
|
||||
#undef NO_WOLFSSL_DIR
|
||||
#define NO_WOLFSSL_DIR
|
||||
//#define NO_WOLFSSL_DIR
|
||||
|
||||
/* disable writev */
|
||||
#undef NO_WRITEV
|
||||
|
@ -66,7 +66,7 @@
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;_USE_64BIT_TIME_T;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -463,7 +463,7 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
XMEMSET(ctx->name, 0, MAX_FILENAME_SZ);
|
||||
XMEMSET(ctx, 0, sizeof(ReadDirCtx));
|
||||
pathLen = (int)XSTRLEN(path);
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
@ -496,6 +496,37 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
|
||||
return 0;
|
||||
}
|
||||
} while (FindNextFileA(ctx->hFind, &ctx->FindFileData));
|
||||
|
||||
#elif defined(INTIME_RTOS)
|
||||
if (pathLen > MAX_FILENAME_SZ - 3)
|
||||
return BAD_PATH_ERROR;
|
||||
|
||||
XSTRNCPY(ctx->name, path, MAX_FILENAME_SZ - 3);
|
||||
XSTRNCPY(ctx->name + pathLen, "\\*", MAX_FILENAME_SZ - pathLen);
|
||||
|
||||
if (!FindFirstRtFile(ctx->name, &ctx->FindFileData, 0)) {
|
||||
WOLFSSL_MSG("FindFirstFile for path verify locations failed");
|
||||
return BAD_PATH_ERROR;
|
||||
}
|
||||
|
||||
do {
|
||||
if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTR_DIRECTORY)) {
|
||||
dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
|
||||
|
||||
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
|
||||
return BAD_PATH_ERROR;
|
||||
}
|
||||
XSTRNCPY(ctx->name, path, pathLen + 1);
|
||||
ctx->name[pathLen] = '\\';
|
||||
XSTRNCPY(ctx->name + pathLen + 1,
|
||||
ctx->FindFileData.cFileName,
|
||||
MAX_FILENAME_SZ - pathLen - 1);
|
||||
if (name)
|
||||
*name = ctx->name;
|
||||
return 0;
|
||||
}
|
||||
} while (FindNextRtFile(&ctx->FindFileData));
|
||||
|
||||
#elif defined(WOLFSSL_ZEPHYR)
|
||||
if (fs_opendir(&ctx->dir, path) != 0) {
|
||||
WOLFSSL_MSG("opendir path verify locations failed");
|
||||
@ -619,6 +650,26 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(INTIME_RTOS)
|
||||
while (FindNextRtFile(&ctx->FindFileData)) {
|
||||
if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTR_DIRECTORY)) {
|
||||
dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
|
||||
|
||||
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
|
||||
return BAD_PATH_ERROR;
|
||||
}
|
||||
XSTRNCPY(ctx->name, path, pathLen + 1);
|
||||
ctx->name[pathLen] = '\\';
|
||||
XSTRNCPY(ctx->name + pathLen + 1,
|
||||
ctx->FindFileData.cFileName,
|
||||
MAX_FILENAME_SZ - pathLen - 1);
|
||||
if (name)
|
||||
*name = ctx->name;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_ZEPHYR)
|
||||
while ((fs_readdir(&ctx->dir, &ctx->entry)) != 0) {
|
||||
dnameLen = (int)XSTRLEN(ctx->entry.name);
|
||||
@ -701,6 +752,10 @@ void wc_ReadDirClose(ReadDirCtx* ctx)
|
||||
FindClose(ctx->hFind);
|
||||
ctx->hFind = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
#elif defined(INTIME_RTOS)
|
||||
FindRtFileClose(&ctx->FindFileData);
|
||||
|
||||
#elif defined(WOLFSSL_ZEPHYR)
|
||||
if (ctx->dirp) {
|
||||
fs_closedir(ctx->dirp);
|
||||
|
@ -764,6 +764,8 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
|
||||
M2MB_DIR_T* dir;
|
||||
struct M2MB_DIRENT* entry;
|
||||
struct M2MB_STAT s;
|
||||
#elif defined(INTIME_RTOS)
|
||||
FIND_FILE_DATA FindFileData;
|
||||
#else
|
||||
struct dirent* entry;
|
||||
DIR* dir;
|
||||
|
Loading…
Reference in New Issue
Block a user