Thanks Scott.
I'm trying to replace a FTP process with the IFS api's.
I'm getting a "ftp_550-File in use by another process error".
When I attempt to do a put, but I want to know if the file is
"in use" before I attempt to do the put. I have a feeling that we
Have some users opening this text file via notepad.....
How do you check the errno?
Gerald Magnuson
Supervisor, Systemi Administration & Development
The Knapheide Manufacturing Company
Quincy, IL 62301
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Tuesday, July 24, 2007 5:00 PM
To: Midrange Systems Technical Discussion
Subject: Re: QNTC open() api question
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.