summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shell_utils_extended.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/shell/shell_utils_extended.cpp')
-rw-r--r--src/mongo/shell/shell_utils_extended.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp
index e46d69f1d8d..6073994a4e6 100644
--- a/src/mongo/shell/shell_utils_extended.cpp
+++ b/src/mongo/shell/shell_utils_extended.cpp
@@ -202,22 +202,19 @@ namespace mongo {
}
/**
- * @param args - [ name, byte index ]
- * In this initial implementation, all bits in the specified byte are flipped.
+ * @param args - [ source, destination ]
+ * copies file 'source' to 'destination'. Errors if the 'destination' file already exists.
*/
- BSONObj fuzzFile(const BSONObj& args, void* data) {
- uassert( 13619, "fuzzFile takes 2 arguments", args.nFields() == 2 );
- scoped_ptr< File > f( new File() );
- f->open( args.getStringField( "0" ) );
- uassert( 13620, "couldn't open file to fuzz", !f->bad() && f->is_open() );
+ BSONObj copyFile(const BSONObj& args, void* data) {
+ uassert(13619, "copyFile takes 2 arguments", args.nFields() == 2);
- char c;
- f->read( args.getIntField( "1" ), &c, 1 );
- c = ~c;
- f->write( args.getIntField( "1" ), &c, 1 );
+ BSONObjIterator it(args);
+ const std::string source = it.next().str();
+ const std::string destination = it.next().str();
+
+ boost::filesystem::copy_file(source, destination);
return undefinedReturn;
- // f close is implicit
}
BSONObj getHostName(const BSONObj& a, void* data) {
@@ -231,7 +228,7 @@ namespace mongo {
void installShellUtilsExtended( Scope& scope ) {
scope.injectNative( "getHostName" , getHostName );
scope.injectNative( "removeFile" , removeFile );
- scope.injectNative( "fuzzFile" , fuzzFile );
+ scope.injectNative( "copyFile" , copyFile );
scope.injectNative( "listFiles" , listFiles );
scope.injectNative( "ls" , ls );
scope.injectNative( "pwd", pwd );