Reputation: 29
I would like get stat parameters from one file and later apply it as is, to a copy of the same file (Including type, path, permissions, size, etc.).
The original file will be long gone from this directory and the copy will take his place, and should get the same exact properties.
How could this be done using C in Linux?
Upvotes: 0
Views: 159
Reputation: 263147
If I understand your question correctly, you don't need to write your own program to do that.
If your files reside on the same machine, you can preserve and restore times and permissions in tar
archives. The p
option handles permissions, and times are persisted by default (except atime
, but --atime-preserve
can work around that).
Alternatively, if you want to restore files from a remote server, you can use rsync
with the -a
option.
Upvotes: 1