Function: file-locked-p
file-locked-p is a function defined in filelock.c.
Signature
(file-locked-p FILENAME)
Documentation
Return a value indicating whether FILENAME is locked.
The value is nil if the FILENAME is not locked, t if it is locked by you, else a string saying which user has locked it.
Other relevant functions are documented in the file group.
Probably introduced at or before Emacs version 18.
Shortdoc
;; file
(file-locked-p "/tmp/foo")
e.g. => nil
Source Code
// Defined in /usr/src/emacs/src/filelock.c
{
#ifdef MSDOS
return Qnil;
#else
Lisp_Object ret;
int owner;
lock_info_type locker;
/* If the file name has special constructs in it,
call the corresponding file name handler. */
Lisp_Object handler;
handler = Ffind_file_name_handler (filename, Qfile_locked_p);
if (!NILP (handler))
{
return calln (handler, Qfile_locked_p, filename);
}
Lisp_Object lfname = make_lock_file_name (filename);
if (NILP (lfname))
return Qnil;
owner = current_lock_owner (&locker, lfname);
switch (owner)
{
case I_OWN_IT: ret = Qt; break;
case ANOTHER_OWNS_IT:
ret = make_string (locker.user, locker.at - locker.user);
break;
case 0: ret = Qnil; break;
default: report_file_errno ("Testing file lock", filename, owner);
}
return ret;
#endif
}