@@ -235,9 +235,10 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
235235 {
236236 if (strcmp (findData.name , " ." ) == 0 || strcmp (findData.name , " .." ) == 0 )
237237 continue ;
238-
239- std::cout << " \n " << " dir_RAM_fs: " << dir_RAM_fs.c_str () << " dir_pc: " << dir_pc.c_str () << std::endl;
240- std::cout << " Sub dir: " << findData.name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
238+ if (g_debugLevel > 0 ) {
239+ std::cout << " \n " << " dir_RAM_fs: " << dir_RAM_fs.c_str () << " dir_pc: " << dir_pc.c_str () << std::endl;
240+ std::cout << " Sub dir: " << findData.name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
241+ }
241242 emulate_vfs_mkdir (dir_full_path_d.c_str (), 1 );
242243 parkFilesToRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ());
243244 }
@@ -252,7 +253,9 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
252253 }
253254 break ;
254255 }
255- std::cout << " Pack file, dir_full_path_s: " << dir_full_path_s.c_str () << " dir_full_path_d: " << dir_full_path_d.c_str () << " file name: " << findData.name << std::endl;
256+ if (g_debugLevel > 0 ) {
257+ std::cout << " Pack file, dir_full_path_s: " << dir_full_path_s.c_str () << " dir_full_path_d: " << dir_full_path_d.c_str () << " file name: " << findData.name << std::endl;
258+ }
256259 }
257260
258261 } while (_findnext (handle, &findData) == 0 );
@@ -273,10 +276,11 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
273276
274277 if (ent->d_name [0 ] == ' .' ) // Ignore dir itself.
275278 continue ;
279+ if (g_debugLevel > 0 ) {
280+ std::cout << " \n " << " dir_RAM_fs: " << dir_RAM_fs.c_str () << " dir_pc: " << dir_pc.c_str () << std::endl;
281+ std::cout << " Sub dir: " << ent->d_name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
282+ }
276283
277- std::cout << " \n " << " dir_RAM_fs: " << dir_RAM_fs.c_str () << " dir_pc: " << dir_pc.c_str () << std::endl;
278- std::cout << " Sub dir: " << ent->d_name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
279-
280284 struct stat path_stat;
281285 stat (dir_full_path_s.c_str (), &path_stat);
282286
@@ -333,7 +337,7 @@ int Pack_fat::unparkFileFromRamFS(const char* path_src, const char* path_des)
333337
334338 size_t size = emulate_esp_vfs_lseek (f_src, 0 , SEEK_END);
335339 emulate_esp_vfs_lseek (f_src, 0 , SEEK_SET);
336- std::cout << " file size: " << size << std::endl;
340+
337341 if (g_debugLevel > 0 ) {
338342 std::cout << " file size: " << size << std::endl;
339343 }
@@ -375,26 +379,36 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
375379 {
376380 continue ;
377381 }
378-
379- std::cout << " ent->d_name: " << ent->d_name << std::endl;
382+ if (g_debugLevel > 0 ) {
383+ std::cout << " ent->d_name: " << ent->d_name << std::endl;
384+ }
385+
380386 dir_full_path_s = dir_RAM_fs + " /" + ent->d_name ;
381387 #if defined(_WIN32)
382388 dir_full_path_d = dir_pc + " \\ " + ent->d_name ;
383389 #else
384390 dir_full_path_d = dir_pc + " /" + ent->d_name ;
385391 #endif
386- std::cout << " RAM dir: " << dir_full_path_s.c_str () << std::endl;
392+
393+ if (g_debugLevel > 0 ) {
394+ std::cout << " RAM dir: " << dir_full_path_s.c_str () << std::endl;
395+ }
396+
387397 struct stat path_stat;
388398 emulate_esp_vfs_stat (dir_full_path_s.c_str (), &path_stat); // get file info.
389- std::cout << " file mode: " << path_stat.st_mode << std::endl;
399+ if (g_debugLevel > 0 ) {
400+ std::cout << " file mode: " << path_stat.st_mode << std::endl;
401+ }
390402
391403 #if defined(_WIN32)
392404 if (S_ISDIR (path_stat.st_mode ))
393405 #else
394406 if (path_stat.st_mode & 0x4000 )
395407 #endif
396408 {
397- std::cout << " Sub dir: " << ent->d_name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
409+ if (g_debugLevel > 0 ) {
410+ std::cout << " Sub dir: " << ent->d_name << " full dir_full_path_s: " << dir_full_path_s.c_str () << " full dir_full_path_d: " << dir_full_path_d.c_str () << " \n " << std::endl;
411+ }
398412 dirCreate (dir_full_path_d.c_str ());
399413 if (unparkFilesFromRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ()) != 0 )
400414 {
@@ -408,7 +422,6 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
408422 #endif
409423 {
410424 // Add File to image.
411- std::cerr << " unpark file......!" << std::endl;
412425 if (unparkFileFromRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ()) != 0 ) {
413426 std::cerr << " error unpark file!" << std::endl;
414427 error = true ;
@@ -464,7 +477,10 @@ int Pack_fat::actionPack(std::string s_dirName, std::string s_imageName, int s_i
464477 }
465478
466479 // 6. copy all data in g_flashmem to *.bin file.
467- std::cout << " g_flashmem[0]: " << g_flashmem[0 ] << " size: " << g_flashmem.size () << std::endl;
480+ if (g_debugLevel > 0 ) {
481+ std::cout << " g_flashmem[0]: " << g_flashmem[0 ] << " size: " << g_flashmem.size () << std::endl;
482+ }
483+
468484 fwrite (&g_flashmem[0 ], 4 , g_flashmem.size ()/4 , fdres); // write all data in RAM fatfs to *.bin.
469485 fclose (fdres);
470486
0 commit comments