ContentSetValue

From TotalcmdWiki
Revision as of 15:31, 15 April 2017 by Lefteous (talk | contribs) (Initial document version, backlink & category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ContentSetValue is called to set the value of a specific field for a given file, e.g. to change the date field of a file.

Declaration:

int __stdcall ContentSetValue(char* FileName,int FieldIndex,int UnitIndex,int FieldType,

               void* FieldValue,int flags);

Description of parameters:

FileName The name of the file for which the plugin needs to change the field data. This is set to NULL to indicate the end of change attributes (see remarks below).

FieldIndex The index of the field for which the content has to be returned. This is the same index as the FieldIndex value in ContentGetSupportedField. This is set to -1 to signal the end of change attributes (see remarks below).

UnitIndex The index of the unit used. Example: If the plugin returned the following unit string in ContentGetSupportedField: bytes|kbytes|Mbytes Then a UnitIndex of 0 would mean bytes, 1 means kbytes and 2 means MBytes If no unit string was returned, UnitIndex is 0. ft_fulltext is currently unsupported.

FieldType The type of data passed to the plugin in FieldValue. This is the same type as returned by the plugin via ContentGetSupportedField. If the plugin returned a different type via ContentGetValue, the the FieldType _may_ be of that type too.

FieldValue Here the plugin receives the data to be changed. The data format depends on the field type: ft_numeric_32: FieldValue points to a 32-bit signed integer variable. ft_numeric_64: FieldValue points to a 64-bit signed integer variable. ft_numeric_floating: FieldValue points to a 64-bit floating point variable (ISO standard double precision) ft_date: FieldValue points to a structure containing year,month,day as 2 byte values. ft_time: FieldValue points to a structure containing hour,minute,second as 2 byte values. ft_boolean: FieldValue points to a 32-bit number. 0 neans false, anything else means true. ft_string or ft_multiplechoice: FieldValue is a pointer to a 0-terminated string. ft_fulltext: Currently unsupported. ft_datetime: A timestamp of type FILETIME, as returned e.g. by FindFirstFile(). It is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. The time MUST be relative to universal time (Greenwich mean time) as returned by the file system, not local time! ft_delayed, ft_ondemand: You may return a zero-terminated string as in ft_string, which will be shown until the actual value has been extracted. Requires plugin version>=1.4.


flags Currently the following flags are defined: setflags_first_attribute: This is the first attribute to be set for this file via this plugin. May be used for optimization. setflags_last_attribute: This is the last attribute to be set for this file via this plugin. setflags_only_date: For field type ft_datetime only: User has only entered a date, don't change the time

Return value:

ft_setsuccess Change was successful ft_fileerror Error accessing the specified file FileName, or cannot set the given value ft_nosuchfield The given field index was invalid

Remarks:

About caching the data: Total Commander will not call a mix ContentSetValue for different files, it will only call it for the next file when the previous file can be closed. Therefore a single cache per running Total Commander should be sufficient.

About the flags: If the flags setflags_first_attribute and setflags_last_attribute are both set, then this is the only attribute of this plugin which is changed for this file.

FileName is set to NULL and FieldIndex to -1 to signal to the plugin that the change attributes operation has ended. This can be used to flush unsaved data to disk, e.g. when setting comments for multiple files.


Back to Content plugins developer guide