addDirEnt_lckd' :: HalfsCapable b t r l m =>
                   Bool
                -> DirHandle r l
                -> DirectoryEntry
                -> HalfsM b r l m ()
addDirEnt_lckd' replaceOK dh de  = do
  -- Precond: (dhLock dh) is currently held (can we assert this? TODO)
  when (not replaceOK) $ do
    mfound <- lookupDE name dh
    maybe (return ()) (const $ throwError $ HE_ObjectExists name) mfound
  insertRM name de (dhContents dh)
  modifyRef (dhState dh) dirStTransAdd
  where
    name = deName de

-- | Remove a directory entry for a file, directory, or symlink; expects
-- that the item exists in the directory.  Thread-safe.
addDirEnt_lckd' :: HalfsCapable b t r l m =>
                   Bool
                -> DirHandle r l
                -> DirectoryEntry
                -> HalfsM b r l m ()
addDirEnt_lckd' replaceOK dh de  = do
  -- Precond: (dhLock dh) is currently held (can we assert this? TODO)
  when (not replaceOK) $ do
    mfound <- lookupDE name dh
    maybe (return ()) (const $ throwError $ HE_ObjectExists name) mfound
  insertRM name de (dhContents dh)
  modifyRef (dhState dh) dirStTransAdd
  where
    name = deName de

-- | Remove a directory entry for a file, directory, or symlink; expects
-- that the item exists in the directory.  Thread-safe.
addDirEnt_lckd' replaceOK dh de  = do
  -- Precond: (dhLock dh) is currently held (can we assert this? TODO)
  when (not replaceOK) $ do
    mfound <- lookupDE name dh
    maybe (return ()) (const $ throwError $ HE_ObjectExists name) mfound
  insertRM name de (dhContents dh)
  modifyRef (dhState dh) dirStTransAdd
  where
    name = deName de

-- | Remove a directory entry for a file, directory, or symlink; expects
-- that the item exists in the directory.  Thread-safe.