11use std:: ffi:: { c_char, c_void, CStr } ;
22
3- use windows_sys:: Win32 :: Foundation :: { CloseHandle , HANDLE , INVALID_HANDLE_VALUE } ;
3+ use windows_sys:: Win32 :: Foundation :: { HANDLE , INVALID_HANDLE_VALUE } ;
44use windows_sys:: Win32 :: Storage :: FileSystem :: {
55 FindClose , FindFirstFileA , FindNextFileA , GetFileAttributesA , FILE_ATTRIBUTE_DIRECTORY ,
66 INVALID_FILE_ATTRIBUTES , WIN32_FIND_DATAA ,
77} ;
88
99use super :: log:: log_info;
1010
11- const GENERIC_WRITE : u32 = 0x40000000 ;
12- const CREATE_NEW : u32 = 1 ;
13- const FILE_ATTRIBUTE_NORMAL : u32 = 0x80 ;
14-
1511extern "system" {
16- fn CreateFileA (
17- name : * const u8 ,
18- access : u32 ,
19- share : u32 ,
20- security : * const c_void ,
21- disposition : u32 ,
22- flags : u32 ,
23- template : * mut c_void ,
24- ) -> HANDLE ;
25- fn WriteFile (
26- file : HANDLE ,
27- buf : * const u8 ,
28- len : u32 ,
29- written : * mut u32 ,
30- overlapped : * mut c_void ,
31- ) -> i32 ;
3212 fn CreateDirectoryA ( path : * const u8 , security : * const c_void ) -> i32 ;
3313 fn GetPrivateProfileStringA (
3414 app : * const u8 ,
@@ -51,32 +31,6 @@ pub fn ensure_mods_layout(base_dir: &str) -> (String, String) {
5131 log_info ( & format ! ( "created mods dir: {}" , mods_dir) ) ;
5232 }
5333
54- let ini_path_c = format ! ( "{}\0 " , ini_path) ;
55- if GetFileAttributesA ( ini_path_c. as_ptr ( ) ) == INVALID_FILE_ATTRIBUTES {
56- let hf = CreateFileA (
57- ini_path_c. as_ptr ( ) ,
58- GENERIC_WRITE ,
59- 0 ,
60- std:: ptr:: null ( ) ,
61- CREATE_NEW ,
62- FILE_ATTRIBUTE_NORMAL ,
63- std:: ptr:: null_mut ( ) ,
64- ) ;
65- if hf != INVALID_HANDLE_VALUE {
66- let default_ini = b"[mods]\r \n ; mod_name.dll=0\r \n " ;
67- let mut written = 0u32 ;
68- WriteFile (
69- hf,
70- default_ini. as_ptr ( ) ,
71- default_ini. len ( ) as u32 ,
72- & mut written,
73- std:: ptr:: null_mut ( ) ,
74- ) ;
75- CloseHandle ( hf) ;
76- log_info ( "created default mods.ini" ) ;
77- }
78- }
79-
8034 ( mods_dir, ini_path)
8135 }
8236}
@@ -144,7 +98,6 @@ pub fn scan_mod_files(mods_dir: &str, ini_path: &str) -> Vec<(String, String)> {
14498pub fn scan_manifest_files ( base_dir : & str ) -> Vec < String > {
14599 unsafe {
146100 let manifest_dir = format ! ( "{}\\ mods\\ manifest" , base_dir) ;
147- CreateDirectoryA ( format ! ( "{}\0 " , manifest_dir) . as_ptr ( ) , std:: ptr:: null ( ) ) ;
148101
149102 let pattern = format ! ( "{}\\ *.toml\0 " , manifest_dir) ;
150103 let mut find_data: WIN32_FIND_DATAA = std:: mem:: zeroed ( ) ;
0 commit comments