Set a property value from the content of a file
end2endzone opened this issue · comments
Is your feature request related to a problem? Please describe.
It would be useful to be able to set a property from the content of a file.
Describe the solution you'd like
<property name="content" file="C:\foo\bar\baz.txt" />
Describe alternatives you've considered
There is no alternative for this feature.
Additional context
This feature would allow people to do advanced property manipulation such as
<menu name="Copy file content">
<visibility maxfiles="1" maxfolders="0" />
<actions>
<property name="selection.file.content" file="${selection.path}" />
</actions>
</menu>
or to copy the result of an <exec> element as a property with something such as
<menu name="Capture exec output">
<actions>
<exec path="cmd.exe" arguments="/C dir /b "%USERPROFILE%\Documents"> "${temp}\command_output.txt"" />
<property name="filenames" file="${temp}\command_output.txt" />
</actions>
</menu>
The feature does also require an optional filesize
attribute. The attribute should be used to define how much of a file (in bytes) can be loaded as a property value. This attribute would prevent loading a huge file in memory by mistake. By default the filesize value should be set to 4096
bytes. If you want to load a file that is bigger than the default, then one has to manually specify a filesize value.
For example, to read the first 10 kb of a file :
<property name="selection.file.content" file="${selection.path}" filesize="10240" />
A special value of 0
would tell the application to load the whole file. For example :
<property name="selection.file.content" file="${selection.path}" filesize="0" />