int main( int argc, char const ** argv ) { WHEFSApp.usageText = "[flags] vfs_file file1 [... fileN]"; WHEFSApp.helpText = "This program imports and exports local files to and from an EFS file." ; int rc = 0; bool gotHelp = false; rc = WHEFSApp_init( argc, argv, WHEFSApp_NoOpen, &gotHelp, CpArgSpec ); if( (0 != rc) ) { APPMSG("Initialization failed with error code #%d\n", rc); return rc; } if( (1==argc) || gotHelp ) { //cp_show_help(); return 0; } if( ! WHEFSApp.fe ) { APPERR("No source files specified!\n"); return whefs_rc.ArgError; } VERBOSE("Opening EFS [%s]\n", WHEFSApp.fsName); rc = whefs_openfs( WHEFSApp.fsName, &WHEFSApp.fs, ThisApp.exportMode ? false : true ); if( whefs_rc.OK != rc ) { APPERR("Open of EFS file [%s] failed with error code %d!\n", WHEFSApp.fsName, rc ); return rc; } WHEFSApp_fe * fe = WHEFSApp.fe; for( ; fe; fe = fe->next ) { VERBOSE("Copying file [%s] %s EFS\n", fe->name,(ThisApp.exportMode?"from":"to")); if( ThisApp.exportMode ) rc = cp_export(fe->name); else rc = cp_import(fe->name); if( whefs_rc.OK != rc ) { APPERR("%s failed for file [%s]! Error code=%d!\n", (ThisApp.exportMode?"Export":"Import"), fe->name, rc ); return rc; } continue; } //printf("vfs file=[%s]\n",WHEFSApp.fsName); //whefs_fs_dump_info( WHEFSApp.fs, stdout ); /* reminder: memory is cleaned up via atexit() */ return 0; }
int main( int argc, char const ** argv ) { WHEFSApp.usageText = "[flags] vfs_file"; WHEFSApp.helpText = "This program adds data blocks to an existing whefs container." ; int rc = 0; bool gotHelp = false; rc = WHEFSApp_init( argc, argv, WHEFSApp_OpenRW, &gotHelp, AddblocksArgSpec ); if( (0 != rc) ) { APPMSG("Initialization failed with error code #%d\n", rc); return rc; } if( (1==argc) || gotHelp ) { //cp_show_help(); return 0; } if( ! ThisApp.count ) { APPERR("You must specify -aNNN to set the number of blocks to add.\n"); return whefs_rc.ArgError; } whefs_fs_options const * fopt = whefs_fs_options_get( WHEFSApp.fs ); const whefs_id_type total = fopt->block_count + ThisApp.count; if( (total < fopt->block_count) ) /* this only catches once-around overflows :( */ { APPERR("Adding %"WHEFS_ID_TYPE_PFMT" blocks to the EFS would overflow its ID type!\n",ThisApp.count); return whefs_rc.RangeError; } VERBOSE("total blocks=%"WHEFS_ID_TYPE_PFMT"\n",total); rc = whefs_fs_append_blocks( WHEFSApp.fs, ThisApp.count ); if( whefs_rc.OK != rc ) { APPWARN("whefs_fs_append_blocks([%s], %"WHEFS_ID_TYPE_PFMT") failed with rc %d!\n", WHEFSApp.fsName, ThisApp.count,rc ); } else { VERBOSE("Appended %"WHEFS_ID_TYPE_PFMT".\n", ThisApp.count ); } return rc; }