Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
513 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// NfsScanner.h | ||
// Vagrant Manager | ||
// | ||
// Copyright (c) 2014 Lanayo. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NFSScanner : NSObject | ||
|
||
- (NSArray*)getNFSInstancePaths; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// NfsScanner.m | ||
// Vagrant Manager | ||
// | ||
// Copyright (c) 2014 Lanayo. All rights reserved. | ||
// | ||
|
||
#import "NFSScanner.h" | ||
|
||
@implementation NFSScanner | ||
|
||
//find vagrant instances in the NFS exports file | ||
- (NSArray*)getNFSInstancePaths { | ||
NSMutableArray *paths = [[NSMutableArray alloc] init]; | ||
|
||
//get contents of /etc/exports | ||
NSError *err; | ||
NSString *fileContents = [NSString stringWithContentsOfFile:@"/etc/exports" encoding:NSUTF8StringEncoding error:&err]; | ||
|
||
if(fileContents) { | ||
//search for vagrant NFS paths | ||
NSMutableArray *lines = [[fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] mutableCopy]; | ||
[lines removeObject:@""]; | ||
|
||
for(NSString *line in lines) { | ||
|
||
if([line rangeOfString:@"# VAGRANT-"].location != NSNotFound) { | ||
continue; | ||
} | ||
|
||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?<!\\\\)\"((?:\\\\\"|[^\"])*+)\"" options:0 error:nil]; | ||
NSArray *pathArr = [regex matchesInString:line options:0 range:NSMakeRange(0, [line length])]; | ||
for (NSTextCheckingResult *pathResult in pathArr) { | ||
if (pathResult.range.length > 1) { | ||
NSString *path = [line substringWithRange:[pathResult rangeAtIndex:1]]; | ||
BOOL vagrantFileExists = [[NSFileManager defaultManager] fileExistsAtPath:[NSString pathWithComponents:@[path, @"Vagrantfile"]]]; | ||
|
||
if(vagrantFileExists) { | ||
[paths addObject:path]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return [NSArray arrayWithArray:paths]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.