Changeset 1210
- Timestamp:
- 14/12/2006 23:20:36 (5 years ago)
- Location:
- box/trunk/bin/bbackupquery
- Files:
-
- 3 edited
-
BackupQueries.cpp (modified) (6 diffs)
-
BackupQueries.h (modified) (2 diffs)
-
bbackupquery.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupquery/BackupQueries.cpp
r1209 r1210 103 103 // 104 104 // Function 105 // Name: BackupQueries::DoCommand(const char * )105 // Name: BackupQueries::DoCommand(const char *, bool) 106 106 // Purpose: Perform a command 107 107 // Created: 2003/10/10 108 108 // 109 109 // -------------------------------------------------------------------------- 110 void BackupQueries::DoCommand(const char *Command )110 void BackupQueries::DoCommand(const char *Command, bool isFromCommandLine) 111 111 { 112 112 // is the command a shell command? … … 169 169 } 170 170 171 #ifdef WIN32 172 if (isFromCommandLine) 173 { 174 for (std::vector<std::string>::iterator 175 i = cmdElements.begin(); 176 i != cmdElements.end(); i++) 177 { 178 std::string converted; 179 if (!ConvertEncoding(*i, CP_ACP, converted, 180 GetConsoleCP())) 181 { 182 printf("Failed to convert encoding"); 183 return; 184 } 185 *i = converted; 186 } 187 } 188 #endif 189 171 190 // Check... 172 191 if(cmdElements.size() < 1) … … 395 414 // 396 415 // Function 397 // Name: BackupQueries::List(int64_t, const std::string &, const bool * )416 // Name: BackupQueries::List(int64_t, const std::string &, const bool *, bool) 398 417 // Purpose: Do the actual listing of directories and files 399 418 // Created: 2003/10/10 … … 872 891 // 873 892 // -------------------------------------------------------------------------- 874 void BackupQueries::CommandGet( const std::vector<std::string> &args, const bool *opts)893 void BackupQueries::CommandGet(std::vector<std::string> args, const bool *opts) 875 894 { 876 895 // At least one argument? … … 889 908 // BLOCK 890 909 { 910 #ifdef WIN32 911 for (std::vector<std::string>::iterator 912 i = args.begin(); i != args.end(); i++) 913 { 914 std::string out; 915 if(!ConvertConsoleToUtf8(i->c_str(), out)) 916 { 917 fprintf(stderr, "failed to convert encoding\n"); 918 return; 919 } 920 *i = out; 921 } 922 #endif 923 924 std::string fileName(args[0]); 925 926 if(!opts['i']) 927 { 928 // does this remote filename include a path? 929 std::string::size_type index = fileName.rfind('/'); 930 if(index != std::string::npos) 931 { 932 std::string dirName(fileName.substr(0, index)); 933 fileName = fileName.substr(index + 1); 934 935 dirId = FindDirectoryObjectID(dirName); 936 if(dirId == 0) 937 { 938 printf("Directory '%s' not found\n", 939 dirName.c_str()); 940 return; 941 } 942 } 943 } 944 945 BackupStoreFilenameClear fn(fileName); 946 891 947 // Need to look it up in the current directory 892 948 mrConnection.QueryListDirectory( … … 925 981 // Specified by name, find the object in the directory to get the ID 926 982 BackupStoreDirectory::Iterator i(dir); 927 #ifdef WIN32928 std::string fileName;929 if(!ConvertConsoleToUtf8(args[0].c_str(), fileName))930 return;931 BackupStoreFilenameClear fn(fileName);932 #else933 BackupStoreFilenameClear fn(args[0]);934 #endif935 983 BackupStoreDirectory::Entry *en = i.FindMatchingClearName(fn); 936 984 -
box/trunk/bin/bbackupquery/BackupQueries.h
r217 r1210 37 37 public: 38 38 39 void DoCommand(const char *Command );39 void DoCommand(const char *Command, bool isFromCommandLine); 40 40 41 41 // Ready to stop? … … 51 51 void CommandChangeLocalDir(const std::vector<std::string> &args); 52 52 void CommandGetObject(const std::vector<std::string> &args, const bool *opts); 53 void CommandGet( const std::vector<std::string> &args, const bool *opts);53 void CommandGet(std::vector<std::string> args, const bool *opts); 54 54 void CommandCompare(const std::vector<std::string> &args, const bool *opts); 55 55 void CommandRestore(const std::vector<std::string> &args, const bool *opts); -
box/trunk/bin/bbackupquery/bbackupquery.cpp
r1158 r1210 172 172 173 173 // enable input of Unicode characters 174 if (_setmode(_fileno(stdin), _O_TEXT) == -1) 174 if (_fileno(stdin) != -1 && 175 _setmode(_fileno(stdin), _O_TEXT) == -1) 175 176 { 176 177 perror("Failed to set the console input to " … … 246 247 while(c < argc && !context.Stop()) 247 248 { 248 context.DoCommand(argv[c++] );249 context.DoCommand(argv[c++], true); 249 250 } 250 251 } … … 264 265 break; 265 266 } 266 context.DoCommand(command );267 context.DoCommand(command, false); 267 268 if(last_cmd != 0 && ::strcmp(last_cmd, command) == 0) 268 269 { … … 285 286 #else 286 287 // Version for platforms which don't have readline by default 287 FdGetLine getLine(fileno(stdin)); 288 while(!context.Stop()) 289 { 290 printf("query > "); 291 fflush(stdout); 292 std::string command(getLine.GetLine()); 293 context.DoCommand(command.c_str()); 288 if(fileno(stdin) >= 0) 289 { 290 FdGetLine getLine(fileno(stdin)); 291 while(!context.Stop()) 292 { 293 printf("query > "); 294 fflush(stdout); 295 std::string command(getLine.GetLine()); 296 context.DoCommand(command.c_str(), false); 297 } 294 298 } 295 299 #endif
Note: See TracChangeset
for help on using the changeset viewer.
