|
1 | | -use crate::{CResult, Config, NotifyGuard, SQ, clients, dyn_connect, static_config, Request}; |
| 1 | +use crate::{CResult, Config, NotifyGuard, SQ, clients, dyn_connect, static_config, Request, util::cstr_to_path}; |
2 | 2 |
|
3 | 3 | use object_store::{path::Path, ObjectStore}; |
4 | 4 |
|
@@ -174,13 +174,7 @@ pub extern "C" fn get( |
174 | 174 | ) -> CResult { |
175 | 175 | let response = unsafe { ResponseGuard::new(response, handle) }; |
176 | 176 | let path = unsafe { std::ffi::CStr::from_ptr(path) }; |
177 | | - let path: Path = match Path::parse(path.to_str().expect("invalid utf8")) { |
178 | | - Ok(p) => p, |
179 | | - Err(e) => { |
180 | | - response.into_error(e); |
181 | | - return CResult::Error; |
182 | | - } |
183 | | - }; |
| 177 | + let path = unsafe{ cstr_to_path(path) }; |
184 | 178 | let slice = unsafe { std::slice::from_raw_parts_mut(buffer, size) }; |
185 | 179 | let config = unsafe { & (*config) }; |
186 | 180 | match SQ.get() { |
@@ -216,13 +210,7 @@ pub extern "C" fn put( |
216 | 210 | ) -> CResult { |
217 | 211 | let response = unsafe { ResponseGuard::new(response, handle) }; |
218 | 212 | let path = unsafe { std::ffi::CStr::from_ptr(path) }; |
219 | | - let path: Path = match Path::parse(path.to_str().expect("invalid utf8")) { |
220 | | - Ok(p) => p, |
221 | | - Err(e) => { |
222 | | - response.into_error(e); |
223 | | - return CResult::Error; |
224 | | - } |
225 | | - }; |
| 213 | + let path = unsafe{ cstr_to_path(path) }; |
226 | 214 | let slice = unsafe { std::slice::from_raw_parts(buffer, size) }; |
227 | 215 | let config = unsafe { & (*config) }; |
228 | 216 | match SQ.get() { |
@@ -256,13 +244,7 @@ pub extern "C" fn delete( |
256 | 244 | ) -> CResult { |
257 | 245 | let response = unsafe { ResponseGuard::new(response, handle) }; |
258 | 246 | let path = unsafe { std::ffi::CStr::from_ptr(path) }; |
259 | | - let path: Path = match Path::parse(path.to_str().expect("invalid utf8")) { |
260 | | - Ok(p) => p, |
261 | | - Err(e) => { |
262 | | - response.into_error(e); |
263 | | - return CResult::Error; |
264 | | - } |
265 | | - }; |
| 247 | + let path = unsafe{ cstr_to_path(path) }; |
266 | 248 | let config = unsafe { & (*config) }; |
267 | 249 | match SQ.get() { |
268 | 250 | Some(sq) => { |
|
0 commit comments