removeFile - fixes repltest

This commit is contained in:
Eliot Horowitz
2010-02-01 22:07:05 -05:00
parent cb26bb4428
commit c7a9785fb4
2 changed files with 21 additions and 0 deletions

View File

@@ -129,6 +129,24 @@ namespace mongo {
ret.appendArray( "", lst.done() );
return ret.obj();
}
BSONObj removeFile(const BSONObj& args){
uassert( 12597 , "need to specify 1 argument to listFiles" , args.nFields() == 1 );
bool found = false;
path root( args.firstElement().valuestrsafe() );
if ( boost::filesystem::exists( root ) ){
found = true;
boost::filesystem::remove_all( root );
}
BSONObjBuilder b;
b.appendBool( "removed" , found );
return b.obj();
}
BSONObj Quit(const BSONObj& args) {
// If not arguments are given first element will be EOO, which
@@ -577,6 +595,7 @@ namespace mongo {
void installShellUtils( Scope& scope ){
scope.injectNative( "listFiles" , listFiles );
scope.injectNative( "removeFile" , removeFile );
scope.injectNative( "sleep" , JSSleep );
scope.injectNative( "quit", Quit );
scope.injectNative( "getMemInfo" , JSGetMemInfo );