On Wed, May 26, 2010 at 04:52:27PM +0100, Balazs Lecz wrote:
> 
> Signed-off-by: Balazs Lecz <[email protected]>
> ---
>  lib/utils.py |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/utils.py b/lib/utils.py
> index 2b3e785..7b93870 100644
> --- a/lib/utils.py
> +++ b/lib/utils.py
> @@ -645,6 +645,24 @@ def RemoveFile(filename):
>        raise
>  
>  
> +def RemoveDir(dirname):
> +  """Remove an empty directory.
> +
> +  Remove a directory, ignoring non-existing ones.
> +  Other errors are passed. This includes the case,
> +  where the directory is not empty, so it can't be removed.
> +
> +  @type dirname: str
> +  @param dirname: the empty directory to be removed
> +
> +  """
> +  try:
> +    os.rmdir(dirname)
> +  except OSError, err:
> +    if err.errno != errno.ENOENT:
> +      raise

This doesn't do any security checks. The dirname must lie somewhere
below a static path.

iustin

Reply via email to