From b5beaa09811316a4daaffebf10d87e4860995c33 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 23 Jun 2026 21:25:02 +0200 Subject: [PATCH] add resource lock/unlock methods --- dav-rs/src/dav/resource.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dav-rs/src/dav/resource.rs b/dav-rs/src/dav/resource.rs index e0e6485..c2e556f 100644 --- a/dav-rs/src/dav/resource.rs +++ b/dav-rs/src/dav/resource.rs @@ -236,6 +236,18 @@ impl<'a> ResourceRef<'a> { result == 0 } + + pub fn lock(&self) -> bool { + unsafe { dav_lock(self.ptr) == 0 } + } + + pub fn lock_t(&self, timeout: u64) -> bool { + unsafe { dav_lock_t(self.ptr, timeout as libc::time_t) == 0 } + } + + pub fn unlock(&self) -> bool { + unsafe { dav_unlock(self.ptr) == 0 } + } } @@ -390,4 +402,8 @@ unsafe extern "C" { fn dav_get_content(res: *mut ffi::DavResource, stream: *mut c_void, write_func: DavWriteFunc) -> c_int; fn dav_set_content(res: *mut ffi::DavResource, stream: *mut c_void, read: DavReadFunc, seek: DavSeekFunc); fn dav_set_content_data(res: *mut ffi::DavResource, content: *const c_char, length: size_t); + + fn dav_lock(res: *mut ffi::DavResource) -> c_int; + fn dav_lock_t(res: *mut ffi::DavResource, timeout: libc::time_t) -> c_int; + fn dav_unlock(res: *mut ffi::DavResource) -> c_int; } \ No newline at end of file -- 2.52.0