added minimal NeXus IDF 2 support.
This commit is contained in:
@@ -11,7 +11,7 @@ LD = g++
|
||||
LDFLAGS = -g
|
||||
|
||||
LIBS = -L /usr/local/lib -lNeXus
|
||||
LIBS += -L /opt/hdf5/lib -lhdf5
|
||||
LIBS += -L /usr/lib -lhdf5
|
||||
|
||||
EXEC = nexus_read_test
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <iostream>
|
||||
@@ -37,8 +38,6 @@
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
#include "napi.h"
|
||||
|
||||
#include "PNeXus.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
@@ -46,12 +45,13 @@ using namespace std;
|
||||
void nexus_read_test_syntax()
|
||||
{
|
||||
cout << endl << ">>---------------------------------------------------------------------------------------";
|
||||
cout << endl << ">> usage: nexus_read_test <nexus-in-filename> <nexus-out-filename> <nexus-write-format>";
|
||||
cout << endl << ">> usage: nexus_read_test <nexus-in-filename> [<nexus-out-filename> <nexus-write-format> <idf>]";
|
||||
cout << endl << ">> This will try to read a nexus-files <nexus-in-filename> and send the relevant";
|
||||
cout << endl << ">> information to the standard output.";
|
||||
cout << endl << ">> At the same time the read file is written back to <nexus-out-filename>, where";
|
||||
cout << endl << ">> the extension will be added based on the <nexus-write-format>.";
|
||||
cout << endl << ">> <nexus-write-format>: hdf4, hdf5, xml";
|
||||
cout << endl << ">> <idf>: 1 | 2";
|
||||
cout << endl << ">>---------------------------------------------------------------------------------------";
|
||||
cout << endl << endl;
|
||||
}
|
||||
@@ -60,29 +60,39 @@ void nexus_read_test_syntax()
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 4) {
|
||||
if ((argc != 5) && (argc !=2)) {
|
||||
nexus_read_test_syntax();
|
||||
return -1;
|
||||
}
|
||||
|
||||
PNeXus *nxs_file = new PNeXus(argv[1]);
|
||||
|
||||
if (nxs_file->IsValid()) {
|
||||
if (nxs_file->IsValid(true)) {
|
||||
nxs_file->Dump();
|
||||
|
||||
char filename[128];
|
||||
if (strstr(argv[3], "hdf") || strstr(argv[3], "xml")) {
|
||||
snprintf(filename, sizeof(filename), "%s.%s", argv[2], argv[3]);
|
||||
} else {
|
||||
cerr << endl << "**ERROR** unkown nexus write format found" << endl;
|
||||
nexus_read_test_syntax();
|
||||
return -1;
|
||||
}
|
||||
if (argc == 5) {
|
||||
long int idf = strtol(argv[4], (char **)NULL, 10);
|
||||
if ((idf != 1) && (idf != 2)) {
|
||||
if (nxs_file)
|
||||
delete nxs_file;
|
||||
nexus_read_test_syntax();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nxs_file->WriteFile(filename, argv[3]) != NX_OK) {
|
||||
cerr << endl << nxs_file->GetErrorMsg() << " (" << nxs_file->GetErrorCode() << ")" << endl << endl;
|
||||
} else {
|
||||
cout << endl << "file " << filename << " written successfully." << endl << endl;
|
||||
char filename[128];
|
||||
if (strstr(argv[3], "hdf") || strstr(argv[3], "xml")) {
|
||||
snprintf(filename, sizeof(filename), "%s.%s", argv[2], argv[3]);
|
||||
} else {
|
||||
cerr << endl << "**ERROR** unkown nexus write format found" << endl;
|
||||
nexus_read_test_syntax();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nxs_file->WriteFile(filename, argv[3], (unsigned int)idf) != NX_OK) {
|
||||
cerr << endl << nxs_file->GetErrorMsg() << " (" << nxs_file->GetErrorCode() << ")" << endl << endl;
|
||||
} else {
|
||||
cout << endl << "file " << filename << " written successfully." << endl << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user