<i>…using API QHFOPNSF…</i>
You can only use QHFOPNSF in a hierarchical file system (HFS). The two standard HFSs on the system are /QDLS and /QOPT. You could create your own HFS and mount it as “demo”, but I suspect that that’s <i>not</i> what you’re trying to do.
<i>Aren’t the file system and directory are same?</i>
No. They are very different.
A path can indicate <b>at least</b> five different things:
<li>Absolute or relative addressing</li><li>File system</li><li>Directory (and subdirectories)</li><li>Redirection</li><li>The object</li>
A path that begins with a slash (“/”) character is an absolute path. That path is the actual path to the object (as long as symbolic links or redirection doesn’t point somewhere else). If a path does not start with a slash, it’s a relative path. The path is ‘relative’ to whatever the ‘current directory’ is for the job.
The first node of an absolute path indicates the file system. There are two kinds of file systems as far as this point is concerned — the /root file system and all other file systems. A file system must be registered with the system. If the node doesn’t match the name of a registered file system, then it’s in the /root file system. (“/demo” is almost certainly not registered, so it’s merely a directory within the /root file system.) Example file systems are /QNTC, /QSYS.LIB, /QOPT and /root. A file system determines things like the valid methods for accessing objects within it.
Redirection happens when a node is either “/.” or “/..” instead of a name. When “/.” is found as a node in a path, it indicates that the rest of the path is relative to the current position in the path. (If the path simply begins with “.”, then the current position is the job’s current directory.) When “/..” is in the path, then the path is redirected to the previous node. E.g., “/home/MyDir/..” is equivalent to “/home”.
And the final node is whatever streamfile or other object is at that point in the path.
<i>when I used the path as ‘/demo/file1’ to open the stream file using API QHFOPNSF I’m getting the error
“File system name demo not found.”</i>
If someone else created “demo” as a user-defined file system (UDFS) and you’re trying to use it, then you’ll need to mount it over an existing directory first. Use the MOUNT command with the TYPE(*UDFS) parameter. Assuming that “demo” really is a valid UDFS, then you might be able to use QHFOPNSF.
Otherwise, you need to use the normal IFS APIs to process your streamfile.