Ticket #173 (closed defect: fixed)

Opened 3 years ago

Last modified 16 months ago

getinfo does not return available space

Reported by: Pete Jemian Owned by: Unassigned
Priority: critical Milestone:
Component: python bindings Version: trunk
Keywords: Cc: Paul Kienzle

Description

For the following:

NXmakedata(10 element NX_CHAR) NXopendata() NXgetinfo()

NXgetinfo returned 0 for the array size when the data type was NX_CHAR, but size 10 for any other data type.

The python binding needs the length in order to prepare the data for writing.

The problem is related to the default stripping of spaces from strings by the NeXus API – passing NOSTRIP to NXopen() results in NXgetinfo returning 10 for the string size.

This raises the general question: how can you determine the maximum size you can write to a NX_CHAR array? The NeXus file may not have been opened NOSTRIP by a user of the python API, so to use the NOSTRIP workaround would mean python opening the file with NOSTRIP and then emulating the stripping behaviour. The documentation for NXgetinfo() does not say whether, for a string, it should return the current or declared size - is a new API function the only way? If NXgetinfo() has only been used to determine how much memory to allocate for a string then changing it would not break anything; however if code relies on it effectively doing a strlen() then this may break.


(copied from  http://trac.nexusformat.org/definitions/ticket/59)

Change History

comment:1 Changed 3 years ago by Mark Koennecke

(In [1220]) - Added a NXgetrawinfo function in the internal section. This function does

not do any special processing for strings and rather returns the raw data size as read from file for strings. This is a special for Paul Kienzle. I marked this function as internal becuase for all normal cases, NXgetinfo as is does the right thing. Refs #173 We may even consider supressing documentation for NXgetrawinfo.

comment:2 Changed 3 years ago by Paul Kienzle

(In [1221]) fix python string issue. Refs #173.

comment:3 Changed 3 years ago by Freddie Akeroyd

(In [1236]) Add missing nxigetrawinfo export refs#173

comment:4 Changed 16 months ago by Mark Koennecke

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.