lockFile()  mkNewFile()

Chapter 5: General Objects and Methods

lockSeg()

Description

Enables advisory locking of part of an I/O file object’s associated file, blocking if necessary. Blocking is not available on Windows.

NoteUse pos() before locking a file segment to determine the current location of the file position indicator. Reading or writing to a file causes the file position indicator to move. Because unlockSeg() always unlocks a file from the indicator’s current location, before calling unlockSeg(), reposition the file position indicator to the position it was at when you called lockSeg() so that you unlock exactly the segment you locked.

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

Syntax

lockSeg(log size);

Parameter

Description

size

Number of bytes to examine for a lock.

Return value

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

Usage

Pointer to object

Object

long num;num = 45783piof->lockSeg(num);

long num;num = 45783;my_iofobj.lockSeg(num);





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

View this book as PDF