154 lines
4.7 KiB
HTML
154 lines
4.7 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>pread64()--Read from Descriptor with Offset (large file enabled)</title>
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- Change History: -->
|
|
<!-- YYMMDD USERID Change description -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- 010307 JTROUS Creation based on pread.htm, V5R2, DCR 98686 -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- This file has undergone html cleanup May 2002 by JET -->
|
|
<!-- End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<!-- Java sync-link -->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<h2 id="HDRPREAD64">pread64()--Read from Descriptor with Offset (large file
|
|
enabled)</h2>
|
|
|
|
<div class="box" style="width: 70%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <unistd.h>
|
|
|
|
ssize_t pread64(int <em>file_descriptor</em>,
|
|
void <em>*buf</em>, size_t <em>nbyte</em>, off64_t <em>offset</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Conditional; see <a href="#USAGE_NOTES">Usage Notes</a>.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>From the file indicated by <em>file_descriptor</em>, the <strong>
|
|
pread64()</strong> function reads <em>nbyte</em> bytes of input into the memory
|
|
area indicated by <em>buf</em>. The <em>offset</em> value defines the starting
|
|
position in the file and the file pointer position is not changed.</p>
|
|
|
|
<p><strong>pread64()</strong> is enabled for large files. It is capable of
|
|
operating on files larger than 2GB minus 1 byte as long as the file has been
|
|
opened by either of the following:</p>
|
|
|
|
<ul>
|
|
<li>Using the <strong>open64()</strong> function (see <a href="open64.htm">
|
|
open64()--Open File (large file enabled)</a>).</li>
|
|
|
|
<li>Using the <strong>open()</strong> function (see <a href="open.htm">
|
|
open()--Open File</a>) with O_LARGEFILE set in the oflag parameter.</li>
|
|
</ul>
|
|
|
|
<p>For additional information about parameters, authorities, and error
|
|
conditions, see <a href="pread.htm">pread()--Read from Descriptor with
|
|
Offset</a>.</p>
|
|
|
|
<br>
|
|
<h3><a name="usage_notes">Usage Notes</a></h3>
|
|
|
|
<ol type="1">
|
|
<li>When you develop in C-based languages, the prototypes for the 64-bit APIs
|
|
are normally hidden. To use the <strong>pread64</strong> API, you must compile
|
|
the source with the _LARGE_FILE_API macro defined.</li>
|
|
|
|
<li>All of the usage notes for <strong>pread()</strong> apply to <strong>
|
|
pread64()</strong>. See <em>Usage Notes</em> in the <strong>pread</strong>
|
|
API.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example opens a file and reads input:</p>
|
|
|
|
<pre>
|
|
#define _LARGE_FILE_API
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
main() {
|
|
int ret, file_descriptor;
|
|
off64_t off=5;
|
|
char buf[]="Test text";
|
|
|
|
if ((file_descriptor = creat64("test.output", S_IWUSR))!= 0)
|
|
perror("creat64() error");
|
|
else {
|
|
if (-1==(rc=write(file_descriptor, buf, sizof(buf)-1)))
|
|
perror("write() error");
|
|
if (close(file_descriptor)!= 0)
|
|
perror("close() error");
|
|
}
|
|
|
|
if ((file_descriptor = open64("test.output", O_RDONLY)) < 0)
|
|
perror("open64() error");
|
|
else {
|
|
ret = pread64(file_descriptor, buf, ((sizeof(buf)-1)-off), off);
|
|
buf[ret] = 0x00;
|
|
printf("block pread64: \n<%s>\n", buf);
|
|
if (close(file_descriptor)!= 0)
|
|
perror("close() error");
|
|
}
|
|
if (unlink("test.output")!= 0)
|
|
perror("unlink() error");
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
block pread64:
|
|
<text>
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V5R2
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|