get_locked_file_path(): new function
Add a function to return the path of the file that is locked by a lock_file object. This reduces the knowledge that callers have to have about the lock_file layout. Suggested-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
316683bd37
commit
ec38b4e482
@ -257,6 +257,15 @@ int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)
|
||||
return fd;
|
||||
}
|
||||
|
||||
char *get_locked_file_path(struct lock_file *lk)
|
||||
{
|
||||
if (!lk->active)
|
||||
die("BUG: get_locked_file_path() called for unlocked object");
|
||||
if (lk->filename.len <= LOCK_SUFFIX_LEN)
|
||||
die("BUG: get_locked_file_path() called for malformed lock object");
|
||||
return xmemdupz(lk->filename.buf, lk->filename.len - LOCK_SUFFIX_LEN);
|
||||
}
|
||||
|
||||
int close_lock_file(struct lock_file *lk)
|
||||
{
|
||||
int fd = lk->fd;
|
||||
|
||||
Reference in New Issue
Block a user