Explorar el Código

Add support for overwriting read-only files.

Martijn Laan hace 3 meses
padre
commit
6c670c706b
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      Projects/Src/Compression.SevenZipDLLDecoder.pas

+ 4 - 0
Projects/Src/Compression.SevenZipDLLDecoder.pas

@@ -342,6 +342,10 @@ begin
         if not ValidateAndCombinePath(FExpandedDestDir, Path, FCurrent.ExpandedPath) then
           OleError(E_ACCESSDENIED);
         ForceDirectories(FDisableFsRedir, PathExtractPath(FCurrent.ExpandedPath));
+        const ExistingFileAttr = GetFileAttributesRedir(FDisableFsRedir, FCurrent.ExpandedPath);
+        if (ExistingFileAttr <> INVALID_FILE_ATTRIBUTES) and
+           (ExistingFileAttr and FILE_ATTRIBUTE_READONLY <> 0) then
+          SetFileAttributesRedir(FDisableFsRedir, FCurrent.ExpandedPath, ExistingFileAttr and not FILE_ATTRIBUTE_READONLY);
         { From IArchive.h: can also set outstream to nil to tell 7zip to skip the file }
         outstream := TSequentialOutStream.Create(TFileRedir.Create(FDisableFsRedir, FCurrent.ExpandedPath, fdCreateAlways, faWrite, fsNone));
       end;