Archive: Recursively setting dir/file permissions


Recursively setting dir/file permissions
Hi people,

My distribution zipfile which sits inside ".\setup_files" (built into the setup.exe on NSIS compile), has a few read-only directories and files. I have tried using

SetFileAttributes $INSTDIR FILE_ATTRIBUTE_NORMAL

SetFileAttributes $INSTDIR\* FILE_ATTRIBUTE_NORMAL

its obvious it doesnt support wildcards however. $R0 returns success, although its not actually setting them to non read only.

AccessControl::GrantOnFile $INSTDIR\* "Administrator" "GenericRead + GenericWrite"

I've tried with the AccessControl plugin also, but I'm probably missing the mark somehow, I could extract them into a temp dir and manually set each files permission, but it pains me thinking about it, if I can just:

a) ask the zipfile creator nicely if he'll set the permissions properly (they are set for a reason, not just set)

b) set the perms on the $INSTDIR after uncompression from the zipfile, and they have been placed in the $INSTDIR.

I've googled for a bit, and searched here, but all I can find is similar to the two methods above, or merely a 'get' and not 'set' method.

anyones help I am very grateful for.

Thanks NSIS community.


I guess a recursive SetFileAttributes would be nice, not that there is one. it seems to return success for the tests I do, although I'd have to do it for every file and dir in the subtree. ack!


The Wiki has something that will help you:

http://nsis.sourceforge.net/Attrib

It doesn't recurse through folders but will get all the files in a folder.


Name "Output"
OutFile "Output.exe"

!include "FileFunc.nsh"
!insertmacro Locate

Section
${Locate} "$INSTDIR" "/L=FD /M=*.*" "LocateCallback"

IfErrors 0 +2
MessageBox MB_OK "Error"
SectionEnd

Function LocateCallback
SetFileAttributes $R9 FILE_ATTRIBUTE_NORMAL

Push $0
FunctionEnd

That is a very elegant and compact method.

Thanks! I'll give it a go


Works a treat, thanks eternally.