diff options
author | Teddy Wing | 2018-10-26 16:06:18 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-26 16:06:18 +0200 |
commit | 388c40cd41e2bbbc3fe3e3336e32a4dc64fa84a4 (patch) | |
tree | 4559d7b8aa61d62a31a8cf339b308f616d95205f | |
parent | 4c41d323ae14c4c676dde4310cb948143e175ca5 (diff) | |
download | DomeKey-388c40cd41e2bbbc3fe3e3336e32a4dc64fa84a4.tar.bz2 |
LicenseHandler(addLicense:): Delete license file instead of trashing it
The trash/recycle method wasn't working because it was asynchronous. As
a result, the file never got moved.
Using `removeItemAtURL:error:` does work, and is available starting in
OS 10.6. But I still don't like the idea of forcibly deleting files.
What if the user licenses the program and deletes their license file,
then somehow gets their only local copy deleted?
Need to work out a different way of doing this.
-rw-r--r-- | DomeKey/LicenseHandler.m | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/DomeKey/LicenseHandler.m b/DomeKey/LicenseHandler.m index c6e0e9c..0421e2e 100644 --- a/DomeKey/LicenseHandler.m +++ b/DomeKey/LicenseHandler.m @@ -51,13 +51,13 @@ static NSString * const LICENSE_FILE_NAME = @"license.plist"; else { [self printInvalidLicenseMessage]; - [[NSWorkspace sharedWorkspace] - recycleURLs:[NSArray arrayWithObject:[self licensePath]] - completionHandler:^(NSDictionary<NSURL *,NSURL *> *newURLs, NSError *error) { - if (error) { - eprintf("%s\n", [[error localizedDescription] UTF8String]); - } - }]; + BOOL removed = [[NSFileManager defaultManager] + removeItemAtURL:[self licensePath] + error:&error]; + + if (!removed) { + eprintf("%s\n", [[error localizedDescription] UTF8String]); + } } // Copy license file into path |