Jelajahi Sumber

Rolling 20220910

jomjol 3 tahun lalu
induk
melakukan
64b472d6bc

+ 13 - 3
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -706,7 +706,7 @@ void delete_all_in_directory(std::string _directory)
     closedir(dir);
 }
 
-std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin)
+std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main)
 {
     int i, sort_iter;
     mz_bool status;
@@ -760,14 +760,24 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
 
             // Save to File.
             zw = std::string(archive_filename);
-            if (toUpper(getFileType(zw)) == "BIN")
+            if (toUpper(zw) == "FIRMWARE.BIN")
             {
                 zw = _target_bin + zw;
                 ret = zw;
             }
             else
             {
-                zw = _target_zip + zw;
+                std::string _dir = getDirectory(zw);
+
+                if (_dir.length() > 0)
+                {
+                    zw = _main + zw;
+                }
+                else
+                {
+                    zw = _target_zip + zw;
+                }
+
             }
 
             printf("Filename to extract: %s", zw.c_str());

+ 1 - 1
code/components/jomjol_fileserver_ota/server_file.h

@@ -4,7 +4,7 @@
 void register_server_file_uri(httpd_handle_t server, const char *base_path);
 
 void unzip(std::string _in_zip_file, std::string _target_directory);
-std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin);
+std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main = "/sdcard/");
 
 
 void delete_all_in_directory(std::string _directory);

+ 14 - 2
code/components/jomjol_helper/Helper.cpp

@@ -268,14 +268,26 @@ string getFileFullFileName(string filename)
 	if (lastpos == string::npos)
 		return "";
 
-	printf("Last position: %d\n", lastpos);
+//	printf("Last position: %d\n", lastpos);
 
 	string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
-//	zw = toUpper(zw);
 
 	return zw;
 }
 
+string getDirectory(string filename)
+{
+	size_t lastpos = filename.find('/');
+
+	if (lastpos == string::npos)
+		return "";
+
+//	printf("Directory: %d\n", lastpos);
+
+	string zw = filename.substr(0, lastpos - 1);
+	return zw;
+}
+
 string getFileType(string filename)
 {
 	size_t lastpos = filename.find(".", 0);

+ 1 - 0
code/components/jomjol_helper/Helper.h

@@ -21,6 +21,7 @@ bool ctype_space(const char c, string adddelimiter);
 
 string getFileType(string filename);
 string getFileFullFileName(string filename);
+string getDirectory(string filename);
 
 int mkdir_r(const char *dir, const mode_t mode);
 int removeFolder(const char* folderPath, const char* logTag);

+ 1 - 1
code/main/version.cpp

@@ -1,4 +1,4 @@
 const char* GIT_REV="N/A";
 const char* GIT_TAG="N/A";
 const char* GIT_BRANCH="N/A";
-const char* BUILD_TIME="2022-09-10 20:27";
+const char* BUILD_TIME="2022-09-10 23:06";

+ 1 - 1
code/version.cpp

@@ -1,4 +1,4 @@
 const char* GIT_REV="N/A";
 const char* GIT_TAG="N/A";
 const char* GIT_BRANCH="N/A";
-const char* BUILD_TIME="2022-09-10 20:27";
+const char* BUILD_TIME="2022-09-10 23:06";

TEMPAT SAMPAH
firmware/bootloader.bin


TEMPAT SAMPAH
firmware/firmware.bin