Functionality of restoreStatOnFile may be reused. Move it into
FileUtilities.cpp. Create helper class FilePermissionsCarrier
to store and apply permissions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Functionality of restoreStatOnFile may be reused.
Do you have an impending usage? The functionality is to emulate in-place update of GNU strip/objcopy where "copy" in "objcopy" assumes some "cp" like behavior. This somewhat makes replacing GNU strip/objcopy easy.
For many utilities, they probably shouldn't do this.
llvm/include/llvm/Support/FileUtilities.h | ||
---|---|---|
127 | private? |
I would like to use it for the new utility - https://reviews.llvm.org/D86539#inline-1182993 . I think it would be good if the behavior would match with "objcopy". f.e. this utility might be used instead of
`llvm-objcopy` --only-keep-debug in-file out-file.debug `llvm-objcopy` --strip-debug in-file out-file `llvm-objcopy` --add-gnu-debuglink=out-file.debug out-file
Mostly looks fine to me. Just a couple of points/questions.
llvm/include/llvm/Support/FileUtilities.h | ||
---|---|---|
114–115 | ||
117 | I wonder if FilePermssionsApplier might make it clearer why this isn't just a POD type (and more importantly why it isn't just a copy of sys::fs::perms? | |
llvm/lib/Support/FileUtilities.cpp | ||
341 | Why do you need this extra layer here and not just do the check in the other apply function? |
llvm/lib/Support/FileUtilities.cpp | ||
---|---|---|
341 | I thought about adding other variants of interface methods. Like apply(StringRef OutFileName); In this case there would be several interface methods with different arguments and single internal method used to implementation. but finally decided to have single universal interface method. So we can remove extra layer in this version of the patch. |
llvm/include/llvm/Support/FileUtilities.h | ||
---|---|---|
117 | sorry, did not get the second part of question. The FilePermissionsCarrier/FilePermssionsApplier already contains a copy of permissions: sys::fs::file_status InputStatus; What do you suggest to change? |
LGTM, once the name typo has been fixed.
llvm/include/llvm/Support/FileUtilities.h | ||
---|---|---|
117 | Sorry, realised I made a couple of typos in my original comment. FilePermssionsApplier -> FilePermissionsApplier The name change was the only thing I was requesting. The rest of the comment was about why I recommended it:
|
Thank you for the review.
llvm/include/llvm/Support/FileUtilities.h | ||
---|---|---|
117 | Ah, I see. thanks. |