Add already opened file logic
This commit is contained in:
parent
602c9f6dfa
commit
7d9976cd90
|
@ -30,7 +30,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lfs_api.h"
|
#include "lfs_api.h"
|
||||||
#include "iCunit.h"
|
|
||||||
|
|
||||||
lfs_t g_lfs;
|
lfs_t g_lfs;
|
||||||
FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
|
FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
|
||||||
|
@ -57,7 +56,7 @@ LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
|
||||||
g_handle[i].useFlag = 1;
|
g_handle[i].useFlag = 1;
|
||||||
g_handle[i].pathName = (char *)malloc(len);
|
g_handle[i].pathName = (char *)malloc(len);
|
||||||
if (g_handle[i].pathName) {
|
if (g_handle[i].pathName) {
|
||||||
memcpy_s(g_handle[i].pathName, len, fileName, len);
|
memcpy_s(g_handle[i].pathName, LITTLE_FS_MAX_NAME_LEN, fileName, len);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_FslocalMutex);
|
pthread_mutex_unlock(&g_FslocalMutex);
|
||||||
return &(g_handle[i]);
|
return &(g_handle[i]);
|
||||||
|
@ -68,17 +67,17 @@ LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckFileIsOpen(const char *fileName)
|
BOOL CheckFileIsOpen(const char *fileName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
|
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
|
||||||
if (g_handle[i].useFlag == 1) {
|
if (g_handle[i].useFlag == 1) {
|
||||||
if (strcmp(g_handle[i].pathName, fileName) == 0) {
|
if (strcmp(g_handle[i].pathName, fileName) == 0) {
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lfs_dir_t *GetFreeDir()
|
lfs_dir_t *GetFreeDir()
|
||||||
|
@ -101,7 +100,7 @@ int InitMountInfo(const char *fileSystemType, const struct MountOps *fsMops)
|
||||||
for (int i = 0; i < MAX_FILE_SYSTEM_LEN; i++) {
|
for (int i = 0; i < MAX_FILE_SYSTEM_LEN; i++) {
|
||||||
if (g_fsmap[i].fileSystemtype == NULL) {
|
if (g_fsmap[i].fileSystemtype == NULL) {
|
||||||
g_fsmap[i].fileSystemtype = (char*)malloc(len);
|
g_fsmap[i].fileSystemtype = (char*)malloc(len);
|
||||||
memcpy_s(g_fsmap[i].fileSystemtype, len, fileSystemType, len);
|
memcpy_s(g_fsmap[i].fileSystemtype, LITTLE_FS_MAX_NAME_LEN, fileSystemType, len);
|
||||||
g_fsmap[i].fsMops = fsMops;
|
g_fsmap[i].fsMops = fsMops;
|
||||||
return VFS_OK;
|
return VFS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ typedef struct {
|
||||||
|
|
||||||
#define LITTLE_FS_MAX_OPEN_FILES 100
|
#define LITTLE_FS_MAX_OPEN_FILES 100
|
||||||
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
||||||
|
#define LITTLE_FS_MAX_NAME_LEN 255
|
||||||
|
|
||||||
#define MAX_DEF_BUF_NUM 21
|
#define MAX_DEF_BUF_NUM 21
|
||||||
#define MAX_BUFFER_LEN 100
|
#define MAX_BUFFER_LEN 100
|
||||||
|
|
Loading…
Reference in New Issue