Changeset 71135 in vbox
- Timestamp:
- Feb 27, 2018 12:56:00 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlConsole.cpp
r71089 r71135 106 106 case Qt::Key_Right: 107 107 { 108 if (textCursor().positionInBlock() > m_strPrompt.length() )108 if (textCursor().positionInBlock() > m_strPrompt.length()-1) 109 109 QPlainTextEdit::keyPressEvent(pEvent); 110 110 break; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp
r71100 r71135 28 28 # include "CGuestProcess.h" 29 29 # include "CGuestSession.h" 30 31 #include <iprt/getopt.h> 30 # include "CGuestFsObjInfo.h" 31 32 /* Misc. includes: */ 33 # include <iprt/getopt.h> 34 32 35 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 36 … … 44 47 m_strStatus.append(strError); \ 45 48 return false; \ 49 } 50 51 #define RETURN_MESSAGE(strMessage) \ 52 { \ 53 m_strStatus.append(strMessage); \ 54 return true; \ 46 55 } 47 56 … … 108 117 QString m_strExePath; 109 118 QString m_strSessionName; 110 QString m_str DirectoryPath;119 QString m_strPath; 111 120 ULONG m_uSessionId; 112 121 QString m_strDomain; … … 134 143 " [-P|--parents] [<guest directory>\n" 135 144 " [--sessionid <id> | [sessionname <name>]]\n" 145 "stat [common-options]\n" 146 " [--sessionid <id> | [sessionname <name>]]\n" 136 147 ) 137 148 { … … 176 187 if (!pathFound) 177 188 { 178 commandData.m_str DirectoryPath = ValueUnion.psz;189 commandData.m_strPath = ValueUnion.psz; 179 190 pathFound = true; 180 191 } … … 188 199 } 189 200 } 190 if (commandData.m_str DirectoryPath.isEmpty())201 if (commandData.m_strPath.isEmpty()) 191 202 RETURN_ERROR(QString(m_strHelp).append("Syntax error! No path is given\n")); 192 203 … … 203 214 creationFlags.push_back(KDirectoryCreateFlag_Parents); 204 215 205 guestSession.DirectoryCreate(commandData.m_str DirectoryPath, 0 /*ULONG aMode*/, creationFlags);216 guestSession.DirectoryCreate(commandData.m_strPath, 0 /*ULONG aMode*/, creationFlags); 206 217 207 218 //startProcess(commandData, guestSession); 208 219 return true; 220 } 221 222 bool UIGuestControlInterface::handleStat(int argc, char** argv) 223 { 224 225 CommandData commandData; 226 227 static const RTGETOPTDEF s_aOptions[] = 228 { 229 GCTLCMD_COMMON_OPTION_DEFS() 230 { "--sessionname", GCTLCMD_COMMON_OPT_SESSION_NAME, RTGETOPT_REQ_STRING }, 231 { "--sessionid", GCTLCMD_COMMON_OPT_SESSION_ID, RTGETOPT_REQ_UINT32 } 232 }; 233 234 int ch; 235 bool pathFound = false; 236 RTGETOPTUNION ValueUnion; 237 RTGETOPTSTATE GetState; 238 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1 /* ignore 0th element (command) */, 0); 239 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 240 { 241 switch (ch) 242 { 243 HANDLE_COMMON_OPTION_DEFS() 244 case GCTLCMD_COMMON_OPT_SESSION_NAME: 245 commandData.m_bSessionNameGiven = true; 246 commandData.m_strSessionName = ValueUnion.psz; 247 break; 248 case GCTLCMD_COMMON_OPT_SESSION_ID: 249 commandData.m_bSessionIdGiven = true; 250 commandData.m_uSessionId = ValueUnion.i32; 251 break; 252 case 'P': 253 commandData.m_bCreateParentDirectories = true; 254 break; 255 case VINF_GETOPT_NOT_OPTION: 256 if (!pathFound) 257 { 258 commandData.m_strPath = ValueUnion.psz; 259 pathFound = true; 260 } 261 /* Allow only a single NOT_OPTION */ 262 else 263 RETURN_ERROR(generateErrorString(ch, ValueUnion)) 264 265 break; 266 default: 267 RETURN_ERROR(generateErrorString(ch, ValueUnion)) 268 } 269 } 270 if (commandData.m_strPath.isEmpty()) 271 RETURN_ERROR(QString(m_strHelp).append("Syntax error! No path is given\n")); 272 273 CGuestSession guestSession; 274 if (!findOrCreateSession(commandData, guestSession) || !guestSession.isOk()) 275 return false; 276 277 bool isADirectory = 278 guestSession.DirectoryExists(commandData.m_strPath, false /*BOOL aFollowSymlinks*/); 279 280 bool isAFile = false; 281 if (!isADirectory) 282 isAFile = guestSession.FileExists(commandData.m_strPath, false /*BOOL aFollowSymlinks*/); 283 284 if (!isADirectory && !isAFile) 285 RETURN_ERROR("Specified object does not exist") 286 287 CGuestFsObjInfo fsObjectInfo = guestSession.FsObjQueryInfo(commandData.m_strPath, false /*BOOL aFollowSymlinks*/); 288 if (!fsObjectInfo.isOk()) 289 RETURN_ERROR("Cannot get object info"); 290 291 QString strObjectInfo = getFsObjInfoString(fsObjectInfo); 292 293 RETURN_MESSAGE(strObjectInfo); 209 294 } 210 295 … … 376 461 m_subCommandHandlers.insert("help" , &UIGuestControlInterface::handleHelp); 377 462 m_subCommandHandlers.insert("mkdir" , &UIGuestControlInterface::handleMkdir); 463 m_subCommandHandlers.insert("stat" , &UIGuestControlInterface::handleStat); 378 464 } 379 465 … … 483 569 return true; 484 570 } 571 572 QString UIGuestControlInterface::getFsObjInfoString(const CGuestFsObjInfo &fsObjectInfo) const 573 { 574 QString strInfo; 575 if (!fsObjectInfo.isOk()) 576 return strInfo; 577 strInfo.append(QString("Name %1 \n").arg(fsObjectInfo.GetName())); 578 strInfo.append(QString("Size %1 \n").arg(fsObjectInfo.GetObjectSize())); 579 strInfo.append(QString("User %1 \n").arg(fsObjectInfo.GetUserName())); 580 strInfo.append(QString("BirthTime %1 \n").arg(fsObjectInfo.GetBirthTime())); 581 strInfo.append(QString("ChangeTime %1 ").arg(fsObjectInfo.GetChangeTime())); 582 583 return strInfo; 584 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h
r71089 r71135 75 75 /* Handles the 'mkdir' session command to create guest directories */ 76 76 bool handleMkdir(int, char**); 77 bool handleStat(int, char**); 78 79 QString getFsObjInfoString(const CGuestFsObjInfo &fsObjectInfo) const; 77 80 78 81 CGuest m_comGuest;
Note:
See TracChangeset
for help on using the changeset viewer.