mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
Keep version of mate (installed) in defaults
This is so that we know when to update the installed version.
This commit is contained in:
@@ -52,6 +52,7 @@ PUBLIC extern NSString* const kUserDefaultsLastBundleUpdateCheckKey;
|
||||
// ============
|
||||
|
||||
PUBLIC extern NSString* const kUserDefaultsMateInstallPathKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsMateInstallVersionKey;
|
||||
|
||||
PUBLIC extern NSString* const kUserDefaultsDisableRMateServerKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsRMateServerListenKey;
|
||||
|
||||
@@ -119,6 +119,7 @@ NSString* const kUserDefaultsLastBundleUpdateCheckKey = @"lastBundleUpdateChec
|
||||
// ============
|
||||
|
||||
NSString* const kUserDefaultsMateInstallPathKey = @"mateInstallPath";
|
||||
NSString* const kUserDefaultsMateInstallVersionKey = @"mateInstallVersion";
|
||||
|
||||
NSString* const kUserDefaultsDisableRMateServerKey = @"rmateServerDisabled";
|
||||
NSString* const kUserDefaultsRMateServerListenKey = @"rmateServerListen"; // localhost (default), remote
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
#import <OakFoundation/OakStringListTransformer.h>
|
||||
#import <io/path.h>
|
||||
#import <io/exec.h>
|
||||
#import <ns/ns.h>
|
||||
#import <regexp/format_string.h>
|
||||
#import <bundles/bundles.h>
|
||||
@@ -218,7 +219,10 @@ static bool uninstall_mate (std::string const& path)
|
||||
if(NSString* path = self.mateInstallPath)
|
||||
{
|
||||
if(access([path fileSystemRepresentation], F_OK) != 0)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kUserDefaultsMateInstallPathKey];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kUserDefaultsMateInstallVersionKey];
|
||||
}
|
||||
}
|
||||
|
||||
installPathPopUp.target = self;
|
||||
@@ -249,7 +253,12 @@ static bool uninstall_mate (std::string const& path)
|
||||
if(NSString* srcPath = [[NSBundle mainBundle] pathForResource:@"mate" ofType:nil])
|
||||
{
|
||||
if(install_mate(to_s(srcPath), to_s(dstPath)))
|
||||
{
|
||||
[self setMateInstallPath:dstPath];
|
||||
std::string res = io::exec(to_s(srcPath), "--version", NULL);
|
||||
if(regexp::match_t const& m = regexp::search("\\Amate ([\\d.]+)", res.data(), res.data() + res.size()))
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:res.data() + m.begin(1) length:m.end(1) - m.begin(1)] forKey:kUserDefaultsMateInstallVersionKey];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user