Skip to content

Option to delete extracted folder after install #18

Open

Description

@bquistorff

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.

Activity

  1. haghish commented on Sep 20, 2021

    @haghish
    Owner

    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

  2. bquistorff commented on Sep 21, 2021

    @bquistorff
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions