lockEnforceOn()  lockSeg()

Chapter 5: General Objects and Methods

lockFile()

Description

Places an advisory lock on an I/O file object’s associated file, blocking if necessary. Blocking is not available on Windows.

NoteAn advisory lock does not prevent other users from reading and writing to the file. Call lockEnforceOn() before calling lockFile() to place enforcement locking on the file and prevent other users from reading and writing to the file. Enforcement locking is available only on UNIX, and the file must not have “group” execute permissions.

Syntax

lockFile();

Return value

Integer. Returns 1 for success, and 0 for failure.

Usage

To successfully lock a file using lockFile(), you must have opened the file using the open() method, and the file’s I/O object must have the “write only” or the “read and write” I/O option set. You should always call unlockFile() once you are finished with the file. When calling lockFile() from a program running on a UNIX platform, if another user has locked the file, then your program blocks this lockFile() call until the other user unlocks the file. When calling lockFile() method from a program running on Windows, if another user has locked the file, then your program makes multiple attempts to establish the lock, but it will not perform blocking.

Pointer to object

Object

piof->lockFile();

my_iobobj.lockFile();





Copyright © 2005. Sybase Inc. All rights reserved. lockSeg()

View this book as PDF