*** C:/Users/ggz/Desktop/storescu (1).cc Tue Aug 28 19:13:03 2012 --- C:/Users/ggz/Desktop/storescu.cc Tue Aug 28 19:13:03 2012 *************** *** 99,104 **** --- 99,105 ---- static OFBool opt_scanDir = OFFalse; static OFBool opt_recurse = OFFalse; + static OFBool opt_renameFile = OFFalse; static const char *opt_scanPattern = ""; static OFBool opt_haltOnUnsuccessfulStore = OFTrue; *************** *** 239,244 **** --- 240,246 ---- #endif cmd.addOption("--no-recurse", "-r", "do not recurse within directories (default)"); cmd.addOption("--recurse", "+r", "recurse within specified directories"); + cmd.addOption("--file-rename", "+fr", "append done/bad to processed files"); cmd.addGroup("network options:"); cmd.addSubGroup("application entity titles:"); cmd.addOption("--aetitle", "-aet", 1, "[a]etitle: string", "set my calling AE title (default: " APPLICATIONTITLE ")"); *************** *** 411,416 **** --- 413,420 ---- } cmd.endOptionBlock(); + if (cmd.findOption("--file-rename")) opt_renameFile = OFTrue; + if (cmd.findOption("--aetitle")) app.checkValue(cmd.getValue(opt_ourTitle)); if (cmd.findOption("--call")) app.checkValue(cmd.getValue(opt_peerTitle)); *************** *** 1458,1463 **** --- 1462,1477 ---- } } + static void + renameFile (const char *fname, const char *fext) + { + if (!opt_renameFile) return; + OFString fnewname(fname); + fnewname += fext; + if( rename(fname, fnewname.c_str()) != 0 ) + OFLOG_WARN(storescuLogger, "cannot rename file '" << fname << "' to '" << fnewname.c_str() << "'"); + } + static OFCondition storeSCU(T_ASC_Association *assoc, const char *fname) /* *************** *** 1493,1498 **** --- 1507,1513 ---- /* figure out if an error occured while the file was read*/ if (cond.bad()) { OFLOG_ERROR(storescuLogger, "Bad DICOM file: " << fname << ": " << cond.text()); + renameFile(fname,".bad"); return cond; } *************** *** 1505,1510 **** --- 1520,1526 ---- if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance, opt_correctUIDPadding)) { OFLOG_ERROR(storescuLogger, "No SOP Class or Instance UID in file: " << fname); + renameFile(fname,".bad"); return DIMSE_BADDATA; } *************** *** 1530,1535 **** --- 1546,1552 ---- if (!modalityName) modalityName = dcmFindNameOfUID(sopClass); if (!modalityName) modalityName = "unknown SOP class"; OFLOG_ERROR(storescuLogger, "No presentation context for: (" << modalityName << ") " << sopClass); + renameFile(fname,".bad"); return DIMSE_NOVALIDPRESENTATIONCONTEXTID; } *************** *** 1572,1577 **** --- 1589,1599 ---- */ if (cond == EC_Normal && (rsp.DimseStatus == STATUS_Success || DICOM_WARNING_STATUS(rsp.DimseStatus))) { unsuccessfulStoreEncountered = OFFalse; + renameFile(fname,".done"); + } + else + { + renameFile(fname,".bad"); } /* remember the response's status for later transmissions of data */