mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Backup.
This commit is contained in:
parent
15c42d8f1a
commit
cc493b6c3d
|
@ -9,8 +9,6 @@ include_directories(
|
|||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||
# )
|
||||
|
||||
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES ./sqlite3.c)
|
||||
|
||||
set(TARGET_NAME sqlite3)
|
||||
|
|
|
@ -6,10 +6,10 @@ set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
|||
include_directories(
|
||||
./src
|
||||
./include
|
||||
${EXTERNAL_SOURCE_PATH}/sqlite3/sqlite-3430000
|
||||
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
# ${UTILS_SOURCE_PATH}/McuProtocol/include
|
||||
# ${UTILS_SOURCE_PATH}/UartDevice/include
|
||||
)
|
||||
#do not rely on any other library
|
||||
|
@ -22,7 +22,7 @@ aux_source_directory(./src/sqlite3 SRC_FILES)
|
|||
set(TARGET_NAME FilesManager)
|
||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} StatusCode Log)
|
||||
target_link_libraries(${TARGET_NAME} sqlite3 StatusCode Log)
|
||||
|
||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||
add_custom_target(
|
||||
|
|
|
@ -4,7 +4,13 @@
|
|||
|
||||
  IPC产品的文件管理模块。抓拍的图片或者视频的保存/删除/查询等操作通过该模块实现。
|
||||
|
||||
## 1.2. 文件夹管理
|
||||
## 1.2. 数据库管理设计
|
||||
|
||||
  考虑到拓展性,使用数据库salite3对文件的各种属性进行管理。
|
||||
|
||||
### 1.2.1. 数据库表
|
||||
|
||||
## 1.3. 文件夹管理
|
||||
|
||||
```
|
||||
DCIM/ // 根目录
|
||||
|
@ -19,7 +25,7 @@ DCIM/ // 根目录
|
|||
└── xxx.MP4
|
||||
```
|
||||
|
||||
## 1.3. 文件命名规则
|
||||
## 1.4. 文件命名规则
|
||||
|
||||
**文件类型**
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ class FilesDatabase : public FilesHandle
|
|||
public:
|
||||
FilesDatabase() = default;
|
||||
virtual ~FilesDatabase() = default;
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
StatusCode DatabaseSaveFile(const SaveFileInfo &fileInfo);
|
||||
};
|
||||
#endif
|
|
@ -16,6 +16,7 @@
|
|||
#include "IStorageManager.h"
|
||||
StatusCode FilesManagerImpl::Init(void)
|
||||
{
|
||||
FilesDatabase::Init();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode FilesManagerImpl::UnInit(void)
|
||||
|
|
|
@ -15,6 +15,15 @@
|
|||
#include "FilesDatabase.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "SqliteHandle.h"
|
||||
void FilesDatabase::Init(void)
|
||||
{
|
||||
SqliteHandle::GetInstance()->Init();
|
||||
}
|
||||
void FilesDatabase::UnInit(void)
|
||||
{
|
||||
SqliteHandle::GetInstance()->UnInit();
|
||||
}
|
||||
StatusCode FilesDatabase::DatabaseSaveFile(const SaveFileInfo &fileInfo)
|
||||
{
|
||||
std::string saveFile = FilesHandle::CreateFilePathName(fileInfo.mFileName);
|
||||
|
|
46
middleware/FilesManager/src/sqlite3/SqliteHandle.cpp
Normal file
46
middleware/FilesManager/src/sqlite3/SqliteHandle.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "SqliteHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "sqlite3.h"
|
||||
std::shared_ptr<SqliteHandle> &SqliteHandle::GetInstance(std::shared_ptr<SqliteHandle> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<SqliteHandle>();
|
||||
if (impl) {
|
||||
if (instance.use_count() == 1) {
|
||||
LogInfo("Instance changed succeed.\n");
|
||||
instance = *impl;
|
||||
}
|
||||
else {
|
||||
LogError("Can't changing the instance becase of using by some one.\n");
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
void SqliteHandle::Init(void)
|
||||
{
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
rc = sqlite3_open("test.db", &db);
|
||||
if (rc) {
|
||||
fprintf(stderr, "无法打开数据库: %s\n", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
return;
|
||||
}
|
||||
}
|
||||
void SqliteHandle::UnInit(void)
|
||||
{
|
||||
|
||||
}
|
27
middleware/FilesManager/src/sqlite3/SqliteHandle.h
Normal file
27
middleware/FilesManager/src/sqlite3/SqliteHandle.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef SQLITE_HANDLE_H
|
||||
#define SQLITE_HANDLE_H
|
||||
#include <memory>
|
||||
class SqliteHandle
|
||||
{
|
||||
public:
|
||||
SqliteHandle() = default;
|
||||
virtual ~SqliteHandle() = default;
|
||||
static std::shared_ptr<SqliteHandle> &GetInstance(std::shared_ptr<SqliteHandle> *impl = nullptr);
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user