   fseek() and files greater than 2go...
  Hi, im trying to figure out how to seek into a big file (larger than 2go), but everything i've tryed failed. Well 1st off, it's not really a file im attempting to open but a drive, but it can be read like a file using this syntax for example:FILE *f = fopen("\\\\.\\h:", "rb"); // h:\ being my cd-rom drive...// now i can read the cd drive like a file... It work just fine, but like with files, if you try to change the file cursor to a position beyond the 2go limit it dosen't work... so i tryed with fstream, same problem because it use an int as argument too, i guess it could work using windows CreateFile and such but since im on xp i dont have access to SetFilePointerEx(), only SetFilePointer()... Hell i even tried with Delphi and c#, but both refuse to open the cd-rom drive like that... What should i do?? Plz help... PS: i can't use the read methods to advance the file pointer because this program is too extract data from a scratched cd-rom, so when it fails i need to reopen the drive again, so i need to use fseek or something to jump back where i was before to avoid getting stuck again there or before the last readen sector.   
  SetFilePointerEx() works on XP. It was introduced with Windows 2000 Professional/Server.   ;  Ok, might be my old vs6 that isn't up to date, so if i compile using c++ express it should work?EDIT: Also, if i use:SetFilePointerEx(hDrive, SECTOR_SIZE * Cpt, NULL, FILE_BEGIN);would the result of the multiplication be a 32 or 64 bits value??;  Nvm i imported the function myself, now it seem to work... thx   ;  Well, whatever you do, you have to use 64-bit pointers, so try _lseeki64.64-bit offsets have the type __int64.But, I don't think it works for fopen.  You'll have to use these functions with it:_open_read_write_telli64Runtime header is <io.h>.For Win 98, Win Me, Win NT, Win 2000, Win XP.   ;Quote:Original post by VortezOk, might be my old vs6 that isn't up to date, so if i compile using c++ express it should work?If you're using VC 6.0, you shouldn't be using XP, or files bigger that 2GB, because you're stuck in the year 1999/2000.Is there any reason you're not using a real compiler instead, like VC2008?   ;Vortez said:// now i can read the cd drive like a file… Sorry, I just must ask this:How can you put a 2gb file onto a CD :P   ;Quote:Original post by Evil SteveIf you're using VC 6.0, you shouldn't be using XP, or files bigger that 2GB, because you're stuck in the year 1999/2000.Is there any reason you're not using a real compiler instead, like VC2008?I know how ppl here dont like vs6 so im not gonna venture in the subject (again).Simply put, i like this compiler better, im a (old school)hobbyist programmer, so i dont care that much about some optimization i wont even notice or smaller exe size as long as it compile and run well... not to mention the compile time wich take around 0.5 sec per .cpp file, compared to 5 sec per file on vs 2010. Still i like to compile my bigger project with 2010, i just don't like it for small projects.And for the missing function, it was no big deal at all, it's located in kernel32.dll, so all i had to do to use it was to load the dll and use a function pointer to access it.BOOL (WINAPI * pSetFilePointerEx)(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod);// Load the kernel32 SetFilePointerEx() function manually HINSTANCE hDll = LoadLibrary("kernel32.dll");pSetFilePointerEx = (BOOL (WINAPI*)(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod))GetProcAddress(hDll, "SetFilePointerEx");FreeLibrary(hDll);[/Source]Quote:Original post by mind in a boxHow can you put a 2gb file onto a CD :PNo! when using fopen like that, you open the DRIVE as like it was a file, so doing this:FILE *f = fopen("\\\\.\\h:", "rb");fread(pBuf, 1, 2048, f); fclose(f);would read the first sector of a drive or cd-rom into a buffer for example.PS: When i said cd i meant cd, dvd ect...Edit: Everytime i edit my post a </source> tag appear from nowhere in my post after the last one, is that a bug or somethin?[Edited by - Vortez on June 1, 2010 4:17:11 PM];Quote:Original post by mind in a boxQuote:// now i can read the cd drive like a file... Sorry, I just must ask this:How can you put a 2gb file onto a CD :PIt could be a sparse file.  Assuming a Rock Ridge or UDF format that's a full 64-bit maximum size.  So at 16 million terabytes per sparse file, and a limit of a few million files, that's somewhere in the octillians, 2^80ish bytes worth of sparse zeros.   