解决,#843,录音文件排序错乱bug 1070/2
authorluozheng <1732036298@qq.com>
Mon, 30 Sep 2024 08:37:39 +0000 (16:37 +0800)
committerluozheng <1732036298@qq.com>
Mon, 30 Sep 2024 08:37:39 +0000 (16:37 +0800)
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp

index 9aa2e6e..35b31b4 100644 (file)
@@ -13,6 +13,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include "ConfigModel.h"
+#include "cstring"
 namespace OHOS
 {
     std::string RecordingModel::recordTempDuration = 0;
@@ -568,6 +569,19 @@ namespace OHOS
             }
             closedir(dir);
         }
+        // 使用冒泡排序进行排序
+        for (int i = 0; i < mp3FileCount - 1; i++)
+        {
+            for (int j = 0; j < mp3FileCount - i - 1; j++)
+            {
+                if (strcmp(info[j].recordingFileName, info[j + 1].recordingFileName) < 0)
+                {
+                    RecordingInfo temp = info[j];
+                    info[j] = info[j + 1];
+                    info[j + 1] = temp;
+                }
+            }
+        }
     }
 
     /*