160 lines
7.7 KiB
HTML
160 lines
7.7 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Examples: HFS" />
|
|
<meta name="abstract" content="Use these hierarchical file system examples to help you program your optical file system." />
|
|
<meta name="description" content="Use these hierarchical file system examples to help you program your optical file system." />
|
|
<meta name="DC.Relation" scheme="URI" content="hfs.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2000, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2000, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="hfsexamples" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- 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. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Examples: HFS</title>
|
|
</head>
|
|
<body id="hfsexamples"><a name="hfsexamples"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Examples: HFS</h1>
|
|
<div><p>Use these hierarchical file system examples to help you program
|
|
your optical file system.</p>
|
|
<div class="section"><p>This topic demonstrates how the HFS API can be used with the ILE
|
|
RPG programming language.</p>
|
|
<div class="p">The programming examples demonstrate the following
|
|
functions: <ul><li>Retrieving a path name from an array</li>
|
|
<li>Calling the HFS API to open a stream file</li>
|
|
<li>Calling the HFS API to write a 256-byte buffer passed to the program as
|
|
a parameter</li>
|
|
<li>Calling the HFS API to close the stream file</li>
|
|
</ul>
|
|
</div>
|
|
<p>For more information about APIs, see <a href="../apiref/api.htm">Application
|
|
device programming (APIs)</a>.</p>
|
|
<div class="note"><span class="notetitle">Note:</span> By using the following code examples,
|
|
you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
|
|
</div>
|
|
<div class="example"><h4 class="sectiontitle">Getting a path and calling subroutines</h4>This sample
|
|
gets a path and calls subroutines.<pre><samp class="codeph">E AR 1 5 36
|
|
C *ENTRY PLIST
|
|
* 2 PARAMETERS - A DATA BUFFER ID AND AN INDEX TO THE ARRAY
|
|
C PARM DATAIN 256
|
|
C PARM IDX 10
|
|
* MOVE THE ARRAY ELEMENT TO A FIELD CALLED "PATH"
|
|
C MOVE AR,IDX PATH
|
|
* EXECUTE SUBROUTINES TO OPEN, WRITE AND CLOSE A FILE
|
|
C EXSR OPNSF
|
|
C RTCD IFEQ 0
|
|
C EXSR WRTSF
|
|
C EXSR CLOSF
|
|
C END
|
|
C SETON LR
|
|
* TABLE/ARRAY . . . . . . . : AR
|
|
** /QOPT/MYVOL1/DIRA/FILE
|
|
/QOPT/MYVOL1/DIRA/SUBDIRB/FILE
|
|
/QOPT/MYVOL1/DIRA/SUBDIRB/C/FILE
|
|
/QOPT/MYVOL1/DIRA/SUBDIRB/C/D/FILE
|
|
/QOPT/MYVOL1/DIRA/SUBDIRB/C/D/E/FILE</samp></pre>
|
|
</div>
|
|
<div class="example"><h4 class="sectiontitle">Defining data structures for opening files</h4>This sample
|
|
defines data structures in the HFS.<pre><samp class="codeph">* PATH LENGTH PARAMETER
|
|
IPATHLN DS
|
|
I B 1 40PATHL
|
|
* OPEN INFORMATION PARAMETER
|
|
IOPNINF DS
|
|
I 1 1 EXISTS
|
|
I 2 2 NOTTHR
|
|
I 3 3 SYNASY
|
|
I 4 4 RSV1
|
|
I 5 5 SHAREM
|
|
I 6 6 ACCESS
|
|
I 7 7 OTYPE
|
|
I 8 10 RSV3
|
|
* ATTRIBUTE LENGTH PARAMETER
|
|
IATTRLN DS
|
|
I B 1 40ATTRL
|
|
* RETURN CODE PARAMETER
|
|
IRETCD DS
|
|
I B 1 40RCLEN
|
|
I B 5 80RTCD
|
|
I 9 15 CONDTN
|
|
I 16 16 RSV
|
|
I 17 272 MSG
|
|
* BYTES TO READ/WRITE PARAMETER
|
|
IBYTRDW DS B 1 40BYT2RW
|
|
* BYTES ACTUALLY READ/WRITTEN PARAMETER
|
|
IBYTACT DS B 1 40BYTARW</samp></pre>
|
|
</div>
|
|
<div class="example"><h4 class="sectiontitle">Opening an optical file</h4>This sample opens an optical
|
|
file.<pre><samp class="codeph">* PARAMETER LIST FOR QHFOPNSF CALL
|
|
C POPNSF PLIST
|
|
C PARM FHDLE 16
|
|
C PARM PATH 36
|
|
C PARM PATHL
|
|
C PARM OPNINF
|
|
C PARM ATRTBL 1
|
|
C PARM ATTRLN
|
|
C PARM ACTION 1
|
|
C PARM RETCD
|
|
C* OPEN FILE SUBROUTINE
|
|
C OPNSF BEGSR
|
|
C* FILL IN THE PATH AND ATTRIBUTE LENGTHS
|
|
C Z-ADD36 PATHL SET PATH LEN=36
|
|
C Z-ADD*ZEROS ATTRL ZERO ATTRIBUTE LENGTH
|
|
C* FILL IN THE OPNINF PARAMETER
|
|
C MOVE '0' EXISTS 1 FAIL IF EXISTS
|
|
C MOVE '1' NOTTHR 1 CREATE IF NOT THERE
|
|
C MOVE '0' SYNASY 1 ASYNCHRONOUS
|
|
C MOVE *BLANKS RSV1 1
|
|
C MOVE '1' SHAREM 1 DENY NONE
|
|
C MOVE '2' ACCESS 1 READ/WRITE
|
|
C MOVE '0' OTYPE 1 NORMAL
|
|
C MOVE *BLANKS RSV3 3
|
|
C* CALL THE API TO OPEN THE STREAM FILE
|
|
C CALL 'QHFOPNSF'POPNSF 50
|
|
C OPNEND ENDSR</samp></pre>
|
|
</div>
|
|
<div class="example"><h4 class="sectiontitle">Writing a file to an optical disk</h4>This sample writes
|
|
a file to an optical disk.<pre><samp class="codeph">* PARAMETER LIST FOR QHFRDSF OR QHFWRTSF CALL
|
|
C PRWSF PLIST
|
|
C PARM FHDLE 16
|
|
C PARM DATAIN
|
|
C PARM BYT2RW
|
|
C PARM BYTARW
|
|
C PARM RETCD
|
|
C* CALL API TO WRITE TO THE FILE
|
|
C WRTSF BEGSR
|
|
C Z-ADD256 BYT2RW SET WRITE LENGTH=256
|
|
C CALL 'QHFWRTSF'PRWSF 50
|
|
C WRTEND ENDSR</samp></pre>
|
|
</div>
|
|
<div class="example"><h4 class="sectiontitle">Closing an optical file</h4>This sample closes an optical
|
|
file.<pre><samp class="codeph">* PARAMETER LIST FOR QHFCLOSF CALL
|
|
C PCLOSF PLIST
|
|
C PARM FHDLE 16
|
|
C PARM RETCD
|
|
C* CALL API TO CLOSE THE FILE
|
|
C CLOSF BEGSR
|
|
C CALL 'QHFCLOSF'PCLOSF 50
|
|
C CLSEND ENDSR
|
|
C* END OF SAMPLE RPG CALL TO THE HFS API</samp></pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="hfs.htm" title="Read this topic collection to learn how to program with the hierarchical file system (HFS).">Hierarchical file system (HFS) programming</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |