1
1
//! Objects related to [`FilesystemStore`] live here.
2
- #[ cfg( target_os = "windows" ) ]
3
- extern crate winapi;
4
-
5
2
use lightning:: util:: persist:: KVStore ;
6
3
7
4
use std:: collections:: HashMap ;
@@ -28,7 +25,7 @@ macro_rules! call {
28
25
}
29
26
30
27
#[ cfg( target_os = "windows" ) ]
31
- fn path_to_windows_str < T : AsRef < OsStr > > ( path : T ) -> Vec < winapi :: shared :: ntdef :: WCHAR > {
28
+ fn path_to_windows_str < T : AsRef < OsStr > > ( path : T ) -> Vec < u16 > {
32
29
path. as_ref ( ) . encode_wide ( ) . chain ( Some ( 0 ) ) . collect ( )
33
30
}
34
31
@@ -116,33 +113,33 @@ impl KVStore for FilesystemStore {
116
113
unsafe {
117
114
libc:: fsync ( dir_file. as_raw_fd ( ) ) ;
118
115
}
116
+ Ok ( ( ) )
119
117
}
120
118
121
119
#[ cfg( target_os = "windows" ) ]
122
120
{
123
121
if dest_file_path. exists ( ) {
124
- unsafe {
125
- winapi :: um :: winbase :: ReplaceFileW (
122
+ call ! ( unsafe {
123
+ windows_sys :: Win32 :: Storage :: FileSystem :: ReplaceFileW (
126
124
path_to_windows_str( dest_file_path) . as_ptr( ) ,
127
125
path_to_windows_str( tmp_file_path) . as_ptr( ) ,
128
126
std:: ptr:: null( ) ,
129
- winapi :: um :: winbase :: REPLACEFILE_IGNORE_MERGE_ERRORS ,
130
- std:: ptr:: null_mut ( ) as * mut winapi :: ctypes :: c_void ,
131
- std:: ptr:: null_mut ( ) as * mut winapi :: ctypes :: c_void ,
127
+ windows_sys :: Win32 :: Storage :: FileSystem :: REPLACEFILE_IGNORE_MERGE_ERRORS ,
128
+ std:: ptr:: null_mut( ) as * const core :: ffi :: c_void,
129
+ std:: ptr:: null_mut( ) as * const core :: ffi :: c_void,
132
130
)
133
- } ;
131
+ } ) ;
134
132
} else {
135
133
call ! ( unsafe {
136
- winapi :: um :: winbase :: MoveFileExW (
134
+ windows_sys :: Win32 :: Storage :: FileSystem :: MoveFileExW (
137
135
path_to_windows_str( tmp_file_path) . as_ptr( ) ,
138
136
path_to_windows_str( dest_file_path) . as_ptr( ) ,
139
- winapi :: um :: winbase :: MOVEFILE_WRITE_THROUGH
140
- | winapi :: um :: winbase :: MOVEFILE_REPLACE_EXISTING ,
137
+ windows_sys :: Win32 :: Storage :: FileSystem :: MOVEFILE_WRITE_THROUGH
138
+ | windows_sys :: Win32 :: Storage :: FileSystem :: MOVEFILE_REPLACE_EXISTING ,
141
139
)
142
140
} ) ;
143
141
}
144
142
}
145
- Ok ( ( ) )
146
143
}
147
144
148
145
fn remove ( & self , namespace : & str , key : & str ) -> std:: io:: Result < ( ) > {
0 commit comments