Skip to content

Commit

Permalink
Support XML and file path in NDAttributesFile
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelldls committed Feb 5, 2024
1 parent 9d2c32a commit 02eb9e0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions ADApp/ADSrc/asynNDArrayDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,21 @@ asynStatus asynNDArrayDriver::readNDAttributesFile()
this->pAttributeList->clear();
if (fileName.length() == 0) return asynSuccess;

infile.open(fileName.c_str());
if (infile.fail()) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s error opening file %s\n",
driverName, functionName, fileName.c_str());
setIntegerParam(NDAttributesStatus, NDAttributesFileNotFound);
return asynError;
// Fill input buffer by XML string or reading from a file
if (fileName.find("<Attributes>") != std::string::npos){
buffer = fileName;
} else {
infile.open(fileName.c_str());
if (infile.fail()) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s error opening file %s\n",
driverName, functionName, fileName.c_str());
setIntegerParam(NDAttributesStatus, NDAttributesFileNotFound);
return asynError;
}
buff << infile.rdbuf();
buffer = buff.str();
}
buff << infile.rdbuf();
buffer = buff.str();

// We now have file in memory. Do macro substitution if required
if (attributesMacros.length() > 0) {
Expand Down

0 comments on commit 02eb9e0

Please sign in to comment.