-3

im writing a backup tool with c++. everything works fine. the result text file looks like this:

pathOfTheSourceFile : pathOfTheDestinationFile

pathOfTheSourceFile : pathOfTheDestinationFile ...

Now I need a Exiftool (or If you recommend some other tool) command that can do this -> change the metadata of pathOfTheDestinationFile with the metadata of pathOfTheSourceFile for each line of the txt file.

I searched for a solution in the documentation and tried to do that in c++ code before but I can't find any meaningful solution.

The cmd should work for unix filesystems (LINUX/MACOS) because pathOfTheSourceFile : pathOfTheDestinationFile are the same filetypes I want to have all possible metadata copied

  • 2
    What sort of "metadata" are you after? What platform are you on? What filesystem? Right now your question lacks enough detail to answer. – Lightness Races in Orbit Dec 05 '19 at 17:41
  • should work on Unix systems. MacOs/Linux. metadata that I need are: all I can get!, but of course the important one are the timestamps like made: Date, last changes: Date etc. – Jack Chaker Dec 05 '19 at 17:46
  • Have you looked into any options? – Lightness Races in Orbit Dec 05 '19 at 18:43
  • what do you mean with options? like other ways to change the meta? then yes. I read something about Exiv. but it seems to me like that's not what im searching for. im writing a backup program. that's why I need to save the meta data with stat() and later when writing back the data I need to write the meta data in to the copys. – Jack Chaker Dec 05 '19 at 18:48
  • Exiv is for manipulating image metadata; completely different. Yes, I mean have you researched options to solve your problem. You should go into some more detail in your question about what you've tried and what didn't work with those approaches. – Lightness Races in Orbit Dec 05 '19 at 18:59

1 Answers1

1

You can use std::filesystem::last_write_time for reading and changing last modification time. std::filesystem::permissions to do the same for permissions.

There doesn't appear to be a standard abstraction over changing the user and group that owns the file, so that would be according to the owner of the process that does the copy. Changing that can be done with a platform specific API.

eerorika
  • 232,697
  • 12
  • 197
  • 326
  • thanks for the answer. I don't use in my Code at all. Is there another way ? I found the state() function to read all datas I want. But I never found a way to change the data. – Jack Chaker Dec 05 '19 at 18:43