CheckSpaceFree: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== Description == | == Description == | ||
I wrote this example for forum user cooladn. In the end it wasn't needed but someone may find it useful. It's yet another demonstration of the usefulness of the System plugin that Brainsucker wrote for NSIS. This example checks to see if a given disk has the desired amount of free space: | I wrote this example for forum user cooladn. In the end it wasn't needed but someone may find it useful. It's yet another demonstration of the usefulness of the System plugin that Brainsucker wrote for NSIS. This example checks to see if a given disk has the desired amount of free space: | ||
Line 35: | Line 39: | ||
okay: | okay: | ||
sectionend</highlight-nsis> | sectionend</highlight-nsis> | ||
Revision as of 23:14, 29 April 2005
Author: sunjammer (talk, contrib) |
Description
I wrote this example for forum user cooladn. In the end it wasn't needed but someone may find it useful. It's yet another demonstration of the usefulness of the System plugin that Brainsucker wrote for NSIS. This example checks to see if a given disk has the desired amount of free space:
The Script
OutFile "FreeSpace.exe" !define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i' ; $0 - space required in kb ; $1 - path to check ; $2 - 0 = ignore quotas, 1 = obey quotas ; trashes $2 function CheckSpaceFunc IntCmp $2 0 ignorequota ; obey quota System::Call '${sysGetDiskFreeSpaceEx}(r1,.r2,,.)' goto converttokb ; ignore quota ignorequota: System::Call '${sysGetDiskFreeSpaceEx}(r1,.,,.r2)' converttokb: ; convert the large integer byte values into managable kb System::Int64Op $2 / 1024 Pop $2 ; check space System::Int64Op $2 > $0 Pop $2 functionend section - StrCpy $0 12345; kb u need StrCpy $1 'c:' ; check drive c: for space Call CheckSpaceFunc IntCmp $2 1 okay MessageBox MB_OK "Error: Not enough disk space" okay: sectionend