×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Hi Gerald,
What is the standard way to code and test the open() api to see if the
file (in QNTC) is already open by another user?
Hmmm... I have no idea if QNTC handles object locking or not? In most
IFS filesystems, you'd do something like this:
in C: rc = open(filename, O_RDONLY|O_SHARE_NONE);
in RPG: rc = open(%trimr(filename): O_RDONlY+O_SHARE_NONE);
The O_SHARE_NONE flag says "I don't want to share this file with anyone"
so if someone else already has it open, rc will be -1, and errno will be
set to EBUSY.
But, I have no idea how well this works with /QNTC , since in that case
it would be the Windows computer (rather than i5/OS) that keeps track of
who is using the file and whether sharing is allowed.
Plus, it's important to understand that many/most PC programs don't keep
the file open. They load the whole file into memory then close it -- a
very different approach than is used with the databases that System i
professionals are accustomed to. For example, Microsoft Excel will
probably load it's entire XLS file into memory, then close the file. It
doesn't keep it open, so you can't use O_SHARE_NONE to check for it. It
does, however, create a "flag file" (a copy of the file under a special
filename) that other instances of Excel will check for to determine if
the file is in use. That may sound weird, but you have to understand
that Windows is an evolution of MS-DOS, and MS-DOS didn't have any
concept of locking, so it was left to the programmers to come up with
their own method.
As an Amazon Associate we earn from qualifying purchases.