News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HELP for file operation

Started by bomz, August 22, 2010, 11:41:02 AM

Previous topic - Next topic

bomz

Thank's I read it. But it's not very quickly

donkey

Quote from: bomz on August 23, 2010, 03:52:41 AM
Thank's I read it. But it's not very quickly

Yeah, its a bit hard to read, but in my opinion you're better off using FILE_FLAG_WRITE_THROUGH if you don't want the data cached during a write operation, not sure why you picked FILE_FLAG_NO_BUFFERING, I assume you needed it for your applications purposes.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

bomz

if the sector size is 512 bytes, an application can request reads and writes of 512, 1,024, 1,536, or 2,048 bytes, but not of 335, 981, or 7,171 bytes...........33554432=32 mb


in other case there is not only any writing but reading too

FILE_FLAG_WRITE_THROUGH cause the same result as NO_BUFFERING

VirtualAlloc and Heap - the same result in all flag combination

donkey

Quote from: bomz on August 23, 2010, 04:01:06 AM
if the sector size is 512 bytes, an application can request reads and writes of 512, 1,024, 1,536, or 2,048 bytes, but not of 335, 981, or 7,171 bytes...........33554432=32 mb


in other case there is not only any writing but reading too

FILE_FLAG_WRITE_THROUGH cause the same result as NO_BUFFERING

No, the 32MB buffer size you are using may be correct however the write request on the only write (if the file is under 32MB) is for a portion of that and will cause the write to fail, the read succeeds because the buffer size is the complete 32MB. For example if ReadFile reads 1057 bytes that is what your write request is, the actual size of the buffer is not important, your request is not aligned because you are telling WriteFile the size of the buffer is 1057 bytes. The way your program is written it will always fail unless the actual file size is a multiple of the sector size, which would be common in many executable files but in others would not be.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

bomz

but how it cause copying AVI files and not copy HLP files?

donkey

Quote from: bomz on August 23, 2010, 04:09:20 AM
but how it cause copying AVI files and not copy HLP files?

Again check the file size. Is the AVI a multiple of sector size ? Is the HLP file ? When you subtract 3MB is the remainder a multiple of sector size ? The flag you selected is a specialty flag that requires you only use buffers and write sizes within very strict parameters.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

bomz

yes you right the reason is in the size

bomz


donkey

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable