@@ -235,9 +235,10 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
235
235
{
236
236
if (strcmp (findData.name , " ." ) == 0 || strcmp (findData.name , " .." ) == 0 )
237
237
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
+ }
241
242
emulate_vfs_mkdir (dir_full_path_d.c_str (), 1 );
242
243
parkFilesToRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ());
243
244
}
@@ -252,7 +253,9 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
252
253
}
253
254
break ;
254
255
}
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
+ }
256
259
}
257
260
258
261
} while (_findnext (handle, &findData) == 0 );
@@ -273,10 +276,11 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
273
276
274
277
if (ent->d_name [0 ] == ' .' ) // Ignore dir itself.
275
278
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
+ }
276
283
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
-
280
284
struct stat path_stat;
281
285
stat (dir_full_path_s.c_str (), &path_stat);
282
286
@@ -333,7 +337,7 @@ int Pack_fat::unparkFileFromRamFS(const char* path_src, const char* path_des)
333
337
334
338
size_t size = emulate_esp_vfs_lseek (f_src, 0 , SEEK_END);
335
339
emulate_esp_vfs_lseek (f_src, 0 , SEEK_SET);
336
- std::cout << " file size: " << size << std::endl;
340
+
337
341
if (g_debugLevel > 0 ) {
338
342
std::cout << " file size: " << size << std::endl;
339
343
}
@@ -375,26 +379,36 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
375
379
{
376
380
continue ;
377
381
}
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
+
380
386
dir_full_path_s = dir_RAM_fs + " /" + ent->d_name ;
381
387
#if defined(_WIN32)
382
388
dir_full_path_d = dir_pc + " \\ " + ent->d_name ;
383
389
#else
384
390
dir_full_path_d = dir_pc + " /" + ent->d_name ;
385
391
#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
+
387
397
struct stat path_stat;
388
398
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
+ }
390
402
391
403
#if defined(_WIN32)
392
404
if (S_ISDIR (path_stat.st_mode ))
393
405
#else
394
406
if (path_stat.st_mode & 0x4000 )
395
407
#endif
396
408
{
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
+ }
398
412
dirCreate (dir_full_path_d.c_str ());
399
413
if (unparkFilesFromRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ()) != 0 )
400
414
{
@@ -408,7 +422,6 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
408
422
#endif
409
423
{
410
424
// Add File to image.
411
- std::cerr << " unpark file......!" << std::endl;
412
425
if (unparkFileFromRamFS (dir_full_path_s.c_str (), dir_full_path_d.c_str ()) != 0 ) {
413
426
std::cerr << " error unpark file!" << std::endl;
414
427
error = true ;
@@ -464,7 +477,10 @@ int Pack_fat::actionPack(std::string s_dirName, std::string s_imageName, int s_i
464
477
}
465
478
466
479
// 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
+
468
484
fwrite (&g_flashmem[0 ], 4 , g_flashmem.size ()/4 , fdres); // write all data in RAM fatfs to *.bin.
469
485
fclose (fdres);
470
486
0 commit comments