Old 13th June 2019, 01:51   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Smile NSIS get file size bigger 2GB

I want to get size (MB) of one file which bigger 2GB.

Example: ${GetSizeBigger2GB} $OUT $PATH

${GetSizeBigger2GB} $OUT "D:\VMWARE\Disk.vhd"

This is possiable ?.
meoit is offline   Reply With Quote
Old 13th June 2019, 10:37   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
FileFunc.nsh

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th June 2019, 14:43   #3
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Post

I tested on Windows 10 x64 v1809

Function .onInit
InitPluginsDir
${GetSize} "D:\VMWare\XP86" "/M=XP86-flat.vmdk /S=0M /G=0" $0 $1 $2
MessageBox MB_OK|MB_USERICON '$0'
FunctionEnd

Result = empty

(In This PC, XP86-flat.vmdk = 2,5GB of size)

With:
${GetSize} "$WINDIR" "/M=Explorer.exe /S=0K /G=0" $0 $1 $2
Result $0 = 4144

Maybe, the .vmdk extension have 4 characters
meoit is offline   Reply With Quote
Old 13th June 2019, 15:34   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
for <= 4GiB files:
Quote:
StrCpy $1 ""
FileOpen $9 "D:\VMWARE\Disk.vhd" r
StrCmp $9 "" +3
FileSeek $9 0 END $1
FileClose $9
IntFmt $1 "%u" $1
DetailPrint $1
64-bit limit:
Quote:
!include LogicLib.nsh
StrCpy $1 -1
FileOpen $9 "D:\VMWARE\Disk.vhd" r
StrCmp $9 "" +3
System::Call 'KERNEL32::GetFileSize(p$9,*i.r2)i.r1'
FileClose $9
${If} $1 = -1
DetailPrint Failed
${Else}
IntFmt $2 "%#x00000000" $2
System::Int64Op $2 | $1
Pop $1
DetailPrint $1
${EndIf}

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 14th June 2019, 10:05   #5
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
I tested on Windows 10 x64 v1809.

for <= 4GiB files:---------result=empty
64-bit limit:-----------------result=-1
meoit is offline   Reply With Quote
Old 14th June 2019, 10:33   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
Does the FileOpen call fail? Is that file perhaps in use/locked?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 14th June 2019, 14:52   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
If you can't open a handle you can ask the directory:

Quote:
!include LogicLib.nsh
System::Call 'KERNEL32::FindFirstFile(t "c:\hiberfil.sys", @r1)p.r0' ; NSIS 3+
${If} $0 P<> -1
System::Call 'KERNEL32::FindClose(pr0)'
System::Call '*$1(i,l,l,l,i.r1,i.r0)'
IntFmt $1 "0x%x" $1
IntFmt $0 "%.8x" $0
StrCpy $1 $1$0
DetailPrint Directory.Size=$1
${EndIf}
This information might not be up to date.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th June 2019, 23:39   #8
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
That's great !!.



I have been searching online for a week.

Thanks again Anders.
meoit is offline   Reply With Quote
Old 16th June 2019, 00:41   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
You can probably just do a pointless 64-bit operation like

Quote:
System::Int64Op $1 + 0
Pop $1
to convert from hex.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump