Very large files

Damjan Jovanovic dj015 at yahoo.com
Wed Jun 28 03:50:47 CDT 2006


I tested it (code to copy a file below, file was > 4
GB) and it works.

I'm using Gentoo 2006.0, Linux 2.6.15.1, ReiserFS 3
and wine 0.9.15.

Can you find out whether the broken code is using
KERNEL32, NTDLL, MSVCRT streams or MSVCRT POSIX-style
open()/read() etc.?

#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	HANDLE inputFile = INVALID_HANDLE_VALUE, outputFile =
INVALID_HANDLE_VALUE;
	const int bufferSize = 8*1024;
	char buffer[bufferSize];
	DWORD bytesRead;
	BOOL ok;

	if (argc < 3)
	{
		fprintf(stderr, "Usage: %s source destination\n",
argv[0]);
		return 1;
	}


	inputFile = CreateFile(argv[1], GENERIC_READ,
FILE_SHARE_READ, NULL,
		OPEN_EXISTING, 0, NULL);
	if (inputFile == INVALID_HANDLE_VALUE)
	{
		fprintf(stderr, "Error opening %s\n", argv[1]);
		goto done;
	}

	outputFile = CreateFile(argv[2], GENERIC_WRITE, 0,
NULL,
		CREATE_ALWAYS, 0, NULL);
	if (outputFile == INVALID_HANDLE_VALUE)
	{
		fprintf(stderr, "Error opening %s\n", argv[2]);
		goto done;
	}

	ok = ReadFile(inputFile, buffer, bufferSize,
&bytesRead, NULL);
	if (!ok)
	{
		fprintf(stderr, "Error reading file\n");
		goto done;
	}
	while (bytesRead > 0)
	{
		DWORD bytesWritten = 0, bytesWrittenNow;
		do
		{
			ok = WriteFile(outputFile, buffer, bytesRead,
&bytesWrittenNow,
				NULL);
			if (!ok)
			{
				fprintf(stderr, "Error writing file\n");
				goto done;
			}
			bytesWritten += bytesWrittenNow;
		} while (bytesWritten < bytesRead);

		ok = ReadFile(inputFile, buffer, bufferSize,
&bytesRead, NULL);
		if (!ok)
		{
			fprintf(stderr, "Error reading file\n");
			goto done;
		}
	};

done:
	if (inputFile != INVALID_HANDLE_VALUE)
		CloseHandle(inputFile);
	if (outputFile != INVALID_HANDLE_VALUE)
		CloseHandle(outputFile);
	return 0;
}




--- John Willis <jswillis93105 at verizon.net> wrote:

> Damjan,
> 
> Linux kernel:     2.4.21-20.ELsmp
> Filesystem:        ext3
> 
> Thanks for looking into this for me,
> 
> John
> 
> ----- Original Message ----- 
> From: "Damjan Jovanovic" <dj015 at yahoo.com>
> To: "John Willis" <jswillis93105 at verizon.net>;
> <wine-devel at winehq.org>
> Sent: Sunday, June 25, 2006 11:31 PM
> Subject: Re: Very large files
> 
> 
> > 
> > 
> > --- John Willis <jswillis93105 at verizon.net> wrote:
> > 
> >> Howdy,
> >> 
> >> I have a large VS 6.0 C++ program and I'm running
> it
> >> under WINE under Redhat Linux. 
> >> Everything works fine, but it doesn't handle file
> >> sizes greater than 4gb like it can running 
> >> directly under Windows XP. 
> >> I've tweaked everything that I can find that
> seems
> >> to deal with file sizes. 
> > 
> > How do you access the file? With stdio streams
> > (fopen(), fread(), ...), MSVCRT's open()/read(),
> or
> > with KERNEL32's CreateFile(), ReadFile(), ... ?
> > 
> >> Is there a problem with WINE itself handling very
> >> large file sizes? 
> > 
> > Which version of the Linux kernel and which
> filesystem
> > are you using?
> > 
> > I'll run some tests at home and see whether it
> works
> > for me.
> > 
> >> Thanks in advance,
> >> John> 
> >> 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > http://mail.yahoo.com
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the wine-devel mailing list