From 68892d649715f15451c7584c6be6d3ef3dd3687f Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 21 Sep 2024 11:23:00 +0800 Subject: [PATCH] =?utf8?q?#575,=E8=A7=A3=E5=86=B3=EF=BC=8CAl=20=E5=AE=89?= =?utf8?q?=E5=8D=93=20=E6=96=87=E5=BF=83=E4=B8=80=E8=A8=80=20=E6=89=8B?= =?utf8?q?=E8=A1=A8=E7=AB=AF=E4=B8=8D=E8=BE=93=E5=87=BA=E7=BB=93=E6=9E=9C?= =?utf8?q?=EF=BC=8C=E6=89=8B=E6=9C=BA=E8=BE=93=E5=87=BA=E7=BB=93=E6=9E=9Cb?= =?utf8?q?ug=EF=BC=8C=E5=8E=9F=E5=9B=A0=E4=B8=BA=E6=96=87=E4=BB=B6?= =?utf8?q?=E8=B7=AF=E5=BE=84=E4=B8=8D=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModel.h | 4 +++- .../nativeui/aivoice/src/AiVoiceModel.cpp | 23 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index ded12eb54..d5110ac2f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 11:14:50 + * @LastEditTime: 2024-09-21 11:07:14 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h */ #ifndef AI_VOICE_MODEL_H @@ -102,6 +102,8 @@ namespace OHOS int GetSelectAiModel(void); int GetAiModelTextId(void); + bool CreateDirectory(const char* path); + private: AiVoiceModel(); ~AiVoiceModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index cd0f1fd1d..d2ce77f7c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 17:08:17 + * @LastEditTime: 2024-09-21 11:13:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -24,6 +24,8 @@ #include #include "ConfigModel.h" #include "settings/include/SettingModel.h" +#include +#include namespace OHOS { // 声明定时器变量 @@ -32,7 +34,10 @@ namespace OHOS static int Time = THIRTY_TIME; static int AiModelConnectTimeout = 5; - AiVoiceModel::AiVoiceModel() {} + AiVoiceModel::AiVoiceModel() + { + CreateDirectory("/user/userdata/AiRecording/"); + } AiVoiceModel::~AiVoiceModel() {} @@ -42,6 +47,20 @@ namespace OHOS return instance; } + bool AiVoiceModel::CreateDirectory(const char* path) + { + if (access(path, F_OK) == -1) { // 如果路径不存在 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s not exist, creating directory\n", path); + if (mkdir(path, 0777)!= 0) { // 尝试创建目录,如果创建失败 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create directory %s failed\n", path); + return false; + } + } else { // 如果路径存在 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s already exists\n", path); + } + return true; + } + // 跳转到返回结果界面 bool AiVoiceModel::ChangeToReturnResultTextView(void) { -- 2.17.1