Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

How to read a large file ??? Find similar branches


Art   (2001-12-14 13:09) [0]

I need to read a large file completely !!!



softland   (2001-12-14 13:15) [1]

What, the file is significantly more RAM?



Vitaly   (2001-12-14 13:19) [2]

So what?



Art   (2001-12-14 13:20) [3]

Yes, no more 255 bytes, and in the normal current line so much fits !!!



MBo   (2001-12-14 13:37) [4]

Concretize the question. What kind of file?
In Delphi string = ansistring to 4 Meg (if not {$ H-})



Art   (2001-12-14 14:06) [5]

Well, there is a file size can reach 100kb I need to read it all !!



gek   (2001-12-14 14:08) [6]

>> Art
I did not understand something where to read something?
100 kb is nonsense



NickBat   (2001-12-14 14:10) [7]

Where to take, then? And how do you read?



Dimka Maslov   (2001-12-14 14:11) [8]

You allocate a buffer in memory and read information into it. There are no problems.



MBo   (2001-12-14 14:11) [9]

yet another Concretize the question
if you have a text file that needs to be read in one line, then so do, for example, FileStream
Or does Stringlist.loadfromfile work?



Polevi   (2001-12-14 16:02) [10]

procedure ReadAnyFile (FileName: string);
was
fHandle, fmHandle: THANDLE;
fBuffer: Pointer;
FileSize, FileSizeHigh: Cardinal;
begin
fHandle: = CreateFile (PChar (FileName), GENERIC_READ or GENERIC_WRITE,
0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if fHandle <> INVALID_HANDLE_VALUE then
begin
FileSize: = GetFileSize (fHandle, @ FileSizeHigh);
if FileSizeHigh = 0 then
begin
fmHandle: = CreateFileMapping (fHandle, nil, PAGE_READWRITE, 0,0, nil);
if (fmHandle <> 0) and (GetLastError <> ERROR_ALREADY_EXISTS) then
begin
fBuffer: = MapViewOfFile (fmHandle, FILE_MAP_WRITE, 0,0,0);
if fBuffer <> nil then
begin
// works here with the file as with the memory area at the address fBuffer
end;
CloseHandle (fmHandle);
end;
end;
CloseHandle (fHandle);
end;
end;



DK   (2001-12-15 03:58) [11]

If the file is a text file, you can do it very simply:
1. create TStringList
2. then its loadfromfile
3. thinks everything :)



Anatoly Podgoretsky   (2001-12-15 12:11) [12]

MBo © (14.12.01 13: 37)
Length (S) = INTEGER

DK © (15.12.01 03: 58)
Let's wait when the question is asked normally, so that it can be understood, well, if not by the rain, then it is not necessary.



Art   (2001-12-15 17:34) [13]

I ask the question normally: Task: Read the file into a variable (completely, the whole file), the file is an ordinary text file, the file size may be larger than 4 megs. (Now it’s ok ???)



Anatoly Podgoretsky   (2001-12-15 18:18) [14]

BlockRead (F, S, N) is one of many methods.



DK   (2001-12-16 02:11) [15]

So I say: DK © (15.12.01 03: 58)
He personally uploaded 16 megs (and this is not the limit).
Quickly loads and then easily work with strings.



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.85 MB
Time: 0.035 c
14-22339
Chinese How Zo Vut
2001-11-01 10:12
2002.01.08
Programmer, what's your name?


7-22445
Kirill
2001-09-21 19:03
2002.01.08
Record to dll


1-22100
Avol
2001-12-15 18:29
2002.01.08
How in Delphi to make a table of records for the game?


14-22327
fliz
2001-11-05 15:39
2002.01.08
and they say the day after tomorrow is a holiday?


14-22382
Panov
2001-11-08 18:54
2002.01.08
continuation http://delphi.mastak.ru/cgi-bin/forum.pl?look=1&id=1005233643&n=3





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish