@@ -182,8 +182,13 @@ private:
182
182
alias int OSStatus;
183
183
alias uint OptionBits;
184
184
185
- extern (C ) @nogc @system OSStatus _dummy_FSPathMakeRefWithOptions(const (char )* path, OptionBits, FSRef* , Boolean* ) nothrow {return 0 ;}
186
- extern (C ) @nogc @system OSStatus _dummy_FSMoveObjectToTrashSync(const (FSRef)* , FSRef* , OptionBits) nothrow {return 0 ;}
185
+ version (TrashCanStatic) {
186
+ extern (C ) @nogc @system OSStatus FSPathMakeRefWithOptions(const (char )* path, OptionBits, FSRef* , Boolean* ) nothrow ;
187
+ extern (C ) @nogc @system OSStatus FSMoveObjectToTrashSync(const (FSRef)* , FSRef* , OptionBits) nothrow ;
188
+ } else {
189
+ extern (C ) @nogc @system OSStatus _dummy_FSPathMakeRefWithOptions(const (char )* path, OptionBits, FSRef* , Boolean* ) nothrow {return 0 ;}
190
+ extern (C ) @nogc @system OSStatus _dummy_FSMoveObjectToTrashSync(const (FSRef)* , FSRef* , OptionBits) nothrow {return 0 ;}
191
+ }
187
192
}
188
193
189
194
/**
@@ -222,27 +227,28 @@ private:
222
227
throw new Exception (format(" SHFileOperation failed with error code %d" , r));
223
228
}
224
229
} else version (OSX ) {
225
- void * handle = dlopen(" CoreServices.framework/Versions/A/CoreServices" , RTLD_NOW | RTLD_LOCAL );
226
- if (handle ! is null ) {
230
+ version (TrashCanStatic) {}
231
+ else {
232
+ void * handle = dlopen(" CoreServices.framework/Versions/A/CoreServices" , RTLD_NOW | RTLD_LOCAL );
233
+ if (handle is null )
234
+ throw new Exception (fromStringz(dlerror()).idup);
227
235
scope (exit) dlclose (handle);
228
236
229
- auto ptrFSPathMakeRefWithOptions = cast (typeof (&_dummy_FSPathMakeRefWithOptions))dlsym(handle, " FSPathMakeRefWithOptions" );
230
- if (ptrFSPathMakeRefWithOptions is null ) {
237
+ auto FSPathMakeRefWithOptions = cast (typeof (&_dummy_FSPathMakeRefWithOptions))dlsym(handle, " FSPathMakeRefWithOptions" );
238
+ if (FSPathMakeRefWithOptions is null ) {
231
239
throw new Exception (fromStringz(dlerror()).idup);
232
240
}
233
241
234
- auto ptrFSMoveObjectToTrashSync = cast (typeof (&_dummy_FSMoveObjectToTrashSync))dlsym(handle, " FSMoveObjectToTrashSync" );
235
- if (ptrFSMoveObjectToTrashSync is null ) {
242
+ auto FSMoveObjectToTrashSync = cast (typeof (&_dummy_FSMoveObjectToTrashSync))dlsym(handle, " FSMoveObjectToTrashSync" );
243
+ if (FSMoveObjectToTrashSync is null ) {
236
244
throw new Exception (fromStringz(dlerror()).idup);
237
245
}
238
-
239
- FSRef source;
240
- enforce(ptrFSPathMakeRefWithOptions(toStringz(path), 1 , &source, null ) == 0 , " Could not make FSRef from path" );
241
- FSRef target;
242
- enforce(ptrFSMoveObjectToTrashSync(&source, &target, 0 ) == 0 , " Could not move path to trash" );
243
- } else {
244
- throw new Exception (fromStringz(dlerror()).idup);
245
246
}
247
+
248
+ FSRef source;
249
+ enforce(FSPathMakeRefWithOptions(toStringz(path), 1 , &source, null ) == 0 , " Could not make FSRef from path" );
250
+ FSRef target;
251
+ enforce(FSMoveObjectToTrashSync(&source, &target, 0 ) == 0 , " Could not move path to trash" );
246
252
} else {
247
253
static if (isFreedesktop) {
248
254
string dataPath = xdgDataHome(null , true );
0 commit comments