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

Option to delete extracted folder after install #18

Open
bquistorff opened this issue Sep 20, 2021 · 2 comments
Open

Option to delete extracted folder after install #18

bquistorff opened this issue Sep 20, 2021 · 2 comments

Comments

@bquistorff
Copy link
Contributor

Using github to install a particular version of a package, e.g. rcall, (on Windows, Stata 15) leaves behind an rcall-X.X.X folder extracted from the zip file. It would be good to have an option to delete this after installation, especially as this folder has the dynamic element of the version (e.g. "stable" -> "3.0.7"). If I'm using github in a script, it would be hard for the script to know the version always and delete the folder programmatically. It might even be good to have this option by default.

@haghish
Copy link
Owner

haghish commented Sep 20, 2021

I totally agree! If "someone" kindly writes a programs that takes a directory name and removes it - for all operating systems - i gladly merge it. It is very annoying to have the unzipped directory remaining... I'm just heavily overwhelmed at the moment to develop and test such a program, no matter how simple it seems to be... please feel free to take the lead

@bquistorff
Copy link
Contributor Author

Some random code I had lying around. Would need to be test.

mata
/*
 *@brief Recursively removes folder with files it in it
 *@param path Directory path to remove
 */
real scalar function rmdir_complete(string scalar path)
{
	if (!regexm(path,"[/\]$")) path = path+"/"
	// display("{hline}{break}Entering folder "+path)
	
	string colvector dirs, files
	
	dirs  = dir(path,"dirs","*",1)
	files = dir(path,"files","*",1)
	
	real scalar i

	for(i=1;i<=length(dirs);i++){
		rmdir_complete(dirs[i])
	}
	
	for(i=1;i<=length(files);i++){
		unlink(files[i])
	}
	rmdir(path)
}
end

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