[#BloombergLP-bdls-FilesystemUtil-lock] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/FilesystemUtil.adoc[FilesystemUtil]::lock :relfileprefix: ../../../ :mrdocs: Acquire a lock for the file with the specified `descriptor`. If `lockWriteFlag` is true, acquire an exclusive write lock; otherwise acquire a (possibly) shared read lock. The calling thread will block until the lock is acquired. Return 0 on success, and a non‐zero value otherwise. Note that this operation locks the indicated file for use by the current _process_, but the behavior is unspecified (and platform‐dependent) when either attempting to lock `descriptor` multiple times, or attempting to lock another descriptor referring to the same file, within a single process. == Synopsis Declared in `<bdls_filesystemutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int lock( xref:BloombergLP/bdls/FilesystemUtil/FileDescriptor.adoc[FileDescriptor] descriptor, bool lockWriteFlag); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#