Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

return value for _lread

Posted on 1998-08-10
5
Medium Priority
?
393 Views
Last Modified: 2013-12-03
Hi,

I'd like to know what is the expected behavior for the _lread functions (kerlnel.dll # 82 and kernel32.dll # 596) when uBytes == 0. This is not described in the API spec.

I.e., if we ask to read 0 bytes, what will happen:

an error? which one?

what is returned by the function? 0? -1?

does that depend on wether the EOF has been reached?

does that depend on the windows' version?

Thanks.
0
Comment
Question by:zorzella
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 300 total points
ID: 1413326
There is no problem reading 0 bytes.  It just does nothing and returns 0 (the number of bytes read).
0
 

Author Comment

by:zorzella
ID: 1413327
Is this valid if the file reader has just reached the EOF?

For example, imagine that EOF has already been reached, and one asks for a _lread of 0 bytes.

In the specs, it is said:

"If the number of bytes read is less than uBytes, the function has reached the end of file (EOF) before reading the specified number of bytes. "

So, would it return 0 even though EOF was reached?

Thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 1413328
assuming no error, _lread() returns the number of bytes that were read.  This is the lesser of the number requested or the number remaining after the current file position.  If you specify 0 bytes to be read, then the procedure will read 0 bytes (regardless of the current file position) and will return 0.  Thus when you read 0 bytes it doesn't matter what the current file position is.
0
 

Author Comment

by:zorzella
ID: 1413329
Thanks. BTW, did you find this documented somewhere or you just know it by use?

0
 
LVL 22

Expert Comment

by:nietod
ID: 1413330
both documentation and use---but not of _lread().  'm assuming (and it is a safe assumption) that it works like the 100s of other functions that perform the same task (C and C++ have several that work like this, DOS has a read service that works like this, Win32 has the ReadFile() function.)  Thus there is a sort-of convention to how a read() function is supposed to work and _read() will almost certainly follow it.  If it didn't it would have to have a good reason and would have to make it clear in the documentation because programmers will assume it does.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question