diff options
| author | Laszlo Boszormenyi (GCS) <gcs@debian.org> | 2015-08-08 18:57:06 +0200 |
|---|---|---|
| committer | Fathi Boudra <fabo@debian.org> | 2015-12-15 11:15:36 +0200 |
| commit | 34eb495f9fee1acb705465102a8ae5f5b78cb149 (patch) | |
| tree | 39f258113dafec114383eee975c2c718d4235227 /src/mongo/shell/shell_utils_extended.cpp | |
| parent | eb56ab9a71cbca16969e19586c9aad2136c24875 (diff) | |
| parent | b19ca2d7025ec90a916906e912f3c97113da38b2 (diff) | |
Imported Debian patch 1:2.4.14-3debian/2.4.14-3
Diffstat (limited to 'src/mongo/shell/shell_utils_extended.cpp')
| -rw-r--r-- | src/mongo/shell/shell_utils_extended.cpp | 23 |
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 2808bab7688..d852893270b 100644 --- a/src/mongo/shell/shell_utils_extended.cpp +++ b/src/mongo/shell/shell_utils_extended.cpp @@ -183,22 +183,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) { @@ -212,7 +209,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 ); |
