Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Added Windows remove_dir_all implementation from #31944 #17

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ appveyor = { repository = "rust-lang-libs/tempdir" }

[dependencies]
rand = "0.3"
remove_dir_all = "0.2"

6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@
//! ```

extern crate rand;
extern crate remove_dir_all;

use std::env;
use std::io::{self, Error, ErrorKind};
use std::fmt;
use std::fs;
use std::path::{self, PathBuf, Path};
use rand::{thread_rng, Rng};
use remove_dir_all::remove_dir_all;

/// A directory in the filesystem that is automatically deleted when
/// it goes out of scope.
Expand Down Expand Up @@ -321,7 +323,7 @@ impl TempDir {
/// # }
/// ```
pub fn close(mut self) -> io::Result<()> {
let result = fs::remove_dir_all(self.path());
let result = remove_dir_all(self.path());

// Prevent the Drop impl from removing the dir a second time.
self.path = None;
Expand All @@ -348,7 +350,7 @@ impl Drop for TempDir {
fn drop(&mut self) {
// Path is `None` if `close()` or `into_path()` has been called.
if let Some(ref p) = self.path {
let _ = fs::remove_dir_all(p);
let _ = remove_dir_all(p);
}
}
}
Expand Down