fledge-iot / fledge

An open source platform for the Industrial Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems.
https://www.lfedge.org/projects/fledge/
Apache License 2.0
124 stars 46 forks source link

FOGL-8538A: New file and directory utilities #1415

Closed RVerhoeff closed 4 months ago

RVerhoeff commented 4 months ago

New file and directory routines are added in new files:

ashish-jabble commented 4 months ago

fyi, We have almost same utility which exists at https://github.com/fledge-iot/fledge/blob/develop/C/plugins/utils/cmdutil.cpp and to run the supported commands for fledge as root using setuid. As of now, only consumer is python. So not sure if we can merge into one utility or keep individual utilities for different works.

Is this required for any specific plugin?

RVerhoeff commented 4 months ago

@ashish-jabble , thanks for your feedback. I looked at the code for cmdutil and tried a few things. I have some comments:

For C++ programs, I think we would benefit from utilities created with the C run-time library so that creating command lines and spawning processes is not necessary. This Pull Request came out of my work on updating the S2OPCUA South plugin. Creating directories and copying files happens many times during startup but not while the plugin is actively processing data.

By the way, one of the error messages has a typo: insallation -> installation.

ashish-jabble commented 4 months ago

Thanks for the detailed info.

Environment variable FLEDGE_ROOT must be defined.

yeah this utility is only meant and worked inside FLEDGE_ROOT; as per initially requirements.

I just only want to share the existing stuff and this may only fit/worked with the specific scenarios moreover inside FLEDGE_ROOT.

If that does not meet your requirement, you can go ahead with the merge.