Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contribution? #107

Open
justin-souter opened this issue Feb 16, 2021 · 4 comments
Open

Contribution? #107

justin-souter opened this issue Feb 16, 2021 · 4 comments

Comments

@justin-souter
Copy link

I have added these functions to the File interface and I'm willing to contribute them. How is that done?

  • (NSString*) resourceDirectory;
  • (NSString*) homeDirectory;
  • (BOOL) createDirectory:(NSString*)path;
  • (void) delete:(NSString*)path;
@jeff-h
Copy link
Member

jeff-h commented Feb 16, 2021

Sounds great! Just open a Pull Request, I'll review your code and if all is well I'll commit it.

If you're new to Github PRs the whole process will involve a bit of a learning curve, but if that's the case you should be able to find some good tutorials out there.

@justin-souter
Copy link
Author

justin-souter commented Feb 16, 2021

Unfortunately I have my hands full with learning curves at the moment. It's just a small amount of code so I'll just post here and hopefully someone else can bake it in for the common good.

- (NSString*) resourceDirectory {

	NSBundle* myBundle = [NSBundle mainBundle];
	return [myBundle resourcePath];
}

- (NSString*) homeDirectory {
	return NSHomeDirectory();
}

- (BOOL) createDirectory:(NSString*)path {
	
	NSFileManager *fileManager= [NSFileManager defaultManager];
	NSError *error = nil;
	
	if(![fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]) {
		 
		NSLog(@"Failed to create directory \"%@\". Error: %@", path, error);
		return false;
	}
	return true;
}

- (void) delete:(NSString*)path {
	NSFileManager *fileManager= [NSFileManager defaultManager];
	[fileManager removeItemAtPath:path error:nil];
}

@jeff-h
Copy link
Member

jeff-h commented Feb 16, 2021

Thanks for this!

@justin-souter
Copy link
Author

Well, turns out that a couple of things I added (home and resources directories) are already covered as properties of the MagGap object, which I hadn't found before. My createDirectory and delete are still useful though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants