diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index e2d891fc..e6802dc0 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/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()); diff --git a/code/components/jomjol_fileserver_ota/server_file.h b/code/components/jomjol_fileserver_ota/server_file.h index fefd5b16..9dbcc88f 100644 --- a/code/components/jomjol_fileserver_ota/server_file.h +++ b/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); diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index b9bb284a..411553b0 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/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); diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index f2585e65..ab263cf2 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/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); diff --git a/code/main/version.cpp b/code/main/version.cpp index ee19b6f1..b3344b25 100644 --- a/code/main/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2022-09-10 23:06"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index ee19b6f1..b3344b25 100644 --- a/code/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2022-09-10 23:06"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 29d7bede..ab2c3edb 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 79effd03..ba347797 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ