Lseek () function

Source: Internet
Author: User

Lseek () has a special purpose for determining whether a file is a regular file or a device.
<pre lang= "C" escaped= "true" >
off_t Currpos;
Ourrpos = Lseek (FD, 0, seek_cur);
if (Ourrpos = =-1)
{
printf ("This was drive file");
}
</pre>
This method is used to determine whether the file or device can set the offset, the regular file can set the offset, and the device is generally not to set the offset, if the device does not support Lseek (), then Lseek returns 1, and the errno device is espipe.


<pre lang= "C" escaped= "true" >
#include <sys/types.h>
#include <unistd.h>

off_t lseek (int fd, off_t offset, int whence);

DESCRIPTION
The Lseek () function repositions The offset of the open file associated with the file descriptor fd to the argument offset According to the directive whence as
follows:

Seek_set
The offset is set to offset bytes.

Seek_cur
The offset is a set to their current location plus offset bytes.

Seek_end
The offset is set to the size of the file plus offset bytes.

</pre>

Lseek () function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.