- NSIS Discussion
- space required
Archive: space required
orecchionebruno
6th August 2010 12:26 UTC
space required
Hello everyone,
any one can suggest me how get space required by installer?
The standard installer directory page of NSIS shows the Space required and the Space avaible. I would recreate that infos in a custom page.
For the avaible space I've used the function "UpdateFreeSpace" included in Starting from "NSIS\Examples\nsDialogs\welcome.nsi", but the for the Space required i din't found a solution. So can I retrieve this info or I should calculate it?
Thankss
Bruno
jpderuiter
6th August 2010 13:06 UTC
Get the size of every selected section using:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.13.8
orecchionebruno
6th August 2010 13:22 UTC
sorry but I've not understood
SectionGetSize can retrieve the amount size (in byte or Mb) of files and folder that NSIS will compress on the exe of the installer?
orecchionebruno
6th August 2010 13:55 UTC
Thanksss I've followed your suggestion and I'v solved my question:
SectionGetSize ${MySectionFileToExtract} $0
IntOp $0 $0 + 100
SectionSetSize ${MySectionFileToExtract} $0
Thanksss
Animaether
6th August 2010 13:56 UTC
Originally posted by orecchionebruno
SectionGetSize can retrieve the amount size (in byte or Mb) of files and folder that NSIS will compress on the exe of the installer?
It retrieves the size in kilobytes of a given section when -uncompressed-. Note that this does not take into account things like filesystem overhead or NTFS compression, etc. But if drive space available is tight enough for such things to matter, the drive is definitely too full ;)
As MSG would say... search the forum;
http://forums.winamp.com/showthread....space+required
orecchionebruno
6th August 2010 14:26 UTC
Ok thankss and thanks for the thread that you post me
orecchionebruno
6th August 2010 16:50 UTC
Originally posted by Animaether
It retrieves the size in kilobytes of a given section when -uncompressed-. Note that this does not take into account things like filesystem overhead or NTFS compression, etc. But if drive space available is tight enough for such things to matter, the drive is definitely too full ;)
Thanksss I'm not sure to had understood. If SectionGetSize retrieves uncompressed size, I should not have any problems on any filesystem compresions or not?
Originally posted by Animaether
As MSG would say... search the forum;
http://forums.winamp.com/showthread....space+required
I read your suggestion about "${DriveSpace} "$0\" "/D=F /S=G" $spaceAvailable ; G = GiB"
What the difference beetween ${DriveSpace} and GetDiskFreeSpaceEx?
This what I've used:
StrCpy $1 " byte"
System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
${If} $0 > 1024
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "kb"
${If} $0 > 1024
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "mb"
${If} $0 > 1024
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "gb"
${EndIf}
${EndIf}
${EndIf}
SendMessage $FREESPACE ${WM_SETTEXT} 0 "STR:Space available: $0 $1"
Ciao
Bruno
Animaether
6th August 2010 20:05 UTC
Originally posted by orecchionebruno
Thanksss I'm not sure to had understood. If SectionGetSize retrieves uncompressed size, I should not have any problems on any filesystem compresions or not?
Well, filesystem compression compresses the file when it's written away or as it's written away (depending on the FS). Let's say your application needs 13MB of space when not compressed, and the system only shows 12MB free. Your installer would then claim it can't be installed; but if you were to attempt install anyway, the filesystem might compress the files down to 8MB and it does fit.
Again, though, in any such situation I'd err on the side of caution and just tell the user that you don't care if they use compression, it's time for them to delete some stuff if they want your app installed :)
Originally posted by orecchionebruno
I read your suggestion about "${DriveSpace} "$0\" "/D=F /S=G" $spaceAvailable ; G = GiB"
What the difference beetween ${DriveSpace} and GetDiskFreeSpaceEx?
No real difference. DriveSpace uses the same API (GetDiskFreeSpaceEx) to get the free space. It just does some of the math bits for you and has some flags for getting total space/used space/free space.
MSG
7th August 2010 06:11 UTC
Originally posted by orecchionebruno
If SectionGetSize retrieves uncompressed size, I should not have any problems on any filesystem compresions or not?
Animaether, I think he meant to say: "I should not have any problems on any filesystem, regardless of the installer's compression." orecchionebruno, the answer to that question would be: Yes. SectionSetSize gets the harddrive space required for *installing* the section. It doesn't have anything to do with the size of the installer.
orecchionebruno
7th August 2010 09:43 UTC
thanks Animaether and MSS
I'll consider any Animaether suggestions but for this specific situatation I'll consider only uncopress size because my data are only some mbytes and it's very hard that user has not some mb free. If not user will delete something.
thankss again
orecchionebruno
10th August 2010 10:51 UTC
Originally posted by Animaether
No real difference. DriveSpace uses the same API (GetDiskFreeSpaceEx) to get the free space. It just does some of the math bits for you and has some flags for getting total space/used space/free space.
Hi Animaether and hi to everyone,
I've followed Animaether suggestions because when I use the API as follow I'm not able to retrieve correct values:
System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
If I try to get free space on C:\ everything is correct, but if try in other drive the values are not correct. I'm sure that happens because I don't know wich parameter I should change so I had started using ${DriveSpace} but it happens something that I don't understand.
Using ${DriveSpace} I can get any value of any drives.
The problem happens when I try to compare some values. If I compare free space of C:\ or D:\ or H:\ (this is a USB pen) everything works but when I compare with my E:\ (it's a recovery partition) the conditions commands give me wrong value.
For example:
${GetRoot} $MYPATH1 $1
${DriveSpace} "$1\" "/D=F /S=B" $1
${GetRoot} $MYPATH2 $2
${DriveSpace} $MYPATH2
${If} "$MYPATH1 " U>= "$MYPATH2"
MessageBox MB_OK "PATH1 >= PATH2"
${Else}
MessageBox MB_OK "PATH1 < PATH2"
${EndIf}
If MYPATH1 and MYPATH2 is C:\, F:\ D:\, I obtain correct results but when is E:\ (the partition recovery) the value is apparently correct but the condition script doesn't work.
The problem should be on the variable format so I tried to see what happens if I do this but I get a negative value:
System::Int64Op $MYPATH1 * 1
Pop $MYPATH1
Any one have a suggestion to solve this problem?
Animaether
10th August 2010 20:18 UTC
Looks like you had posted this to a separate thread as well - see there :)
http://forums.winamp.com/showthread.php?t=321543 - "${DriveSpace} and some strange values "
orecchionebruno
11th August 2010 10:19 UTC
Hi Animaether, I'm sorry upper I made a mistake translating my variables. I correct the script, but the problem that I wrote is that happens.
${GetRoot} $MYPATH1 $1
${DriveSpace} "$1\" "/D=F /S=B" $FreeSpace1
${GetRoot} $MYPATH2 $2
${DriveSpace} "$2\" "/D=F /S=B" $FreeSpace2
${If} "$FreeSpace1" U>= "$FreeSpace2"
MessageBox MB_OK "PATH1 >= PATH2"
${Else}
MessageBox MB_OK "PATH1 < PATH2"
${EndIf}
_____
As Animaether wrote, this discussion continue here:
http://forums.winamp.com/showthread.php?t=321543
Thanksss
MSG
11th August 2010 10:21 UTC
orecchionebruno, please stop posting in two threads at once. Use the other thread, not this one.
(And please don't reply to this post, either.)