March 04, 2021, 01:01:37 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
File Utilities
»
[bmx] Long Filesize by N [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bmx] Long Filesize by N [ 1+ years ago ] (Read 484 times)
BlitzBot
Jr. Member
Posts: 1
[bmx] Long Filesize by N [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:40 AM »
Title :
Long Filesize
Author :
N
Posted :
1+ years ago
Description :
Basically, this is the same as FileSize, but uses a Long instead of an Int. Win32 and Linux are the only platforms supported by this function currently.
If you find a way to do this on OS X, I encourage you to post it to save others time. In the mean time, I'll be looking for a solution.
Code :
Code: BlitzMax
?Win32
Const
FILE_READ_ATTRIBUTES% = $00000080
Const
FILE_SHARE_READ% = $00000001
Const
OPEN_EXISTING% =
3
Extern
"OS"
Function
GetFileSizeEx:
Int
(
handle%, size:
Long
Ptr
)
Function
CreateFileW:
Int
(
filename$W, daccess%, sharem%, seca@
Ptr
, cDisp%, flags%, template%
)
Function
CloseHandle:
Int
(
handle%
)
End
Extern
?Linux
Private
Global
statbank:TBank = TBank.Create
(
256
)
' Maximum possible size
Public
Extern
"OS"
Function
stat64:
Int
(
path$z, buf@
Ptr
)
End
Extern
?MacOS
?
Function
GetFileSize:
Long
(
file$
)
Local
out:
Long
=-
1
?Win32
Local
handle% = CreateFileW
(
file, FILE_READ_ATTRIBUTES, FILE_SHARE_READ,
Null
, OPEN_EXISTING,
0
,
0
)
ASsert
handle<>-
1
,
"File does not exist"
GetFileSizeEx
(
handle,
Varptr
out
)
CloseHandle
(
handle
)
?Linux
If
stat64
(
file, statbank.Buf
(
)
)
<>
0
Then
Assert
"Unable to get file stats"
out = statBank.PeekLong
(
44
)
?MacOS
Assert
"GetFileSize not implemented for this platform"
?
Return
out
End
Function
Comments :
N(Posted 1+ years ago)
Added an untested implementation for Linux. Anyone got the balls to test it?
N(Posted 1+ years ago)
New version for Linux. Tested and works from what I can see.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
File Utilities
»
[bmx] Long Filesize by N [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal