0

i am developing a synchronization app, i need to store unique id in the metadata of each files when they are put in to my app, thus i can match the similar files between server and client,(matching the similar files using name is not good ,name can be changed at any time, but if each file has unique id even file is modified or renamed i can identify the similar files)

so i need to know how can i insert my custom attribute(unique id) to a file's metadata in linux and windows?is there any c/c++ libraries to do this?(my app is being developed in c++)

Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92

2 Answers2

0

I'm not sure I fully understand your question, but I believe you can use the setxattr family of system calls to define extended attributes for files.

Jorge Israel Peña
  • 36,800
  • 16
  • 93
  • 123
0

We faced a similar problem for our software, but in our case metadata was lot of, sharing just in case you can use it for your case also...

Our each file now got a metadata section, and its required to not edit that metadata manually by user, its autogenerated by a utility and was something like as mentioned below(at the end of each file)...

#if 0
/** METADATA **/
/**
   <root>
         <element1 attr1="" attr2=""....>
                   <subEleme1 attr1="" attr2="".../>
         </element1>
         <element2 attr1="" attr2=""..../>
   </root>
**/
#endif

It just rough to give you idea, in our case this metadata was too complex, may be you can use something similar?

Saqlain
  • 17,490
  • 4
  • 27
  • 33