how to copy large files (bigger than ~2GB)
BlitzMax Forums/BlitzMax Programming/how to copy large files (bigger than ~2GB)
| ||
Is there a way to copy files bigger than Int? I need to be able to display the progress too. Can i use kernel functions for that? or should i change the stdc.c (change all Ints to Doubles? :P) file or what? |
| ||
you can divide it up and use open file and write int to copy the file one 2gb piece at a time. |
| ||
Can you even read the file beyond 2GB, though? I'd kind of expect it to lose track of its location inside of the file once you hit that barrier as well... |
| ||
I have a Windows solution to this problem, using the Windows API to check file sizes, and copy files. If you want me to post it, I can, but it looks like you are looking for a Linux solution?!?! |
| ||
I'd be interested in a Windows solution... |
| ||
To copy a file: Declare the function: Extern "win32" Function CopyFileExW:Int(SrcFile$W, DestFile$W, CallBack:Byte Ptr, Data:Int Ptr, Cancel:Int Ptr, Flags:Int) End Extern Then just call it: CopyFileExW(src, dst, Null, Null, Null, 0) src and dst are just strings containing complete paths to the source abnd detsination of the file. To get a filesize: Declare the functions: Extern "win32" Function CreateFileA:Int (lpFileName$Z, dwDesiredAccess:Int, dwShareMode:Int, lpSecurityAttributes:Byte Ptr, dwCreationDisposition:Int, dwFlagsAndAttributes:Int, hTemplateFile:Int) Function CloseHandle:Int (hObject:Int) Function GetFileSizeEx:Int(handle:Int, size:Long Ptr) End Extern Use this BMax function: Function getFileSize:Long(file:String) Local out:Long = -1 Local handle:Int = CreateFileA(file, 128, 1, Null, 3, 0, 0) If handle <> -1 GetFileSizeEx(handle, Varptr out) End If CloseHandle(handle) Return out End Function |
| ||
Thanks! |
| ||
Can you even read the file beyond 2GB, though? I wrote a filestream that can read and write 2GB+ files.http://www.blitzbasic.com/Community/posts.php?topic=88492#1004898 |
| ||
Thanks for the link, might come in handy some day. |
| ||
i'm too interested in solution for windows. I'll try out the link at some point. Too much to do with other projects at the time. |