VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestFileImpl.h@ 72436

Last change on this file since 72436 was 71782, checked in by vboxsync, 7 years ago

Guest Control: Implemented GuestFile::queryInfo() and GuestFile::querySize() APIs, added file opening translation cruft to GuestFile::i_openFile(), where it actually belongs. Some more parameter checking in i_onFileNotify().

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: GuestFileImpl.h 71782 2018-04-09 15:49:19Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_GUESTFILEIMPL
19#define ____H_GUESTFILEIMPL
20
21#include "VirtualBoxBase.h"
22#include "EventImpl.h"
23
24#include "GuestCtrlImplPrivate.h"
25#include "GuestFileWrap.h"
26
27class Console;
28class GuestSession;
29class GuestProcess;
30
31class ATL_NO_VTABLE GuestFile :
32 public GuestFileWrap,
33 public GuestObject
34{
35public:
36 /** @name COM and internal init/term/mapping cruft.
37 * @{ */
38 DECLARE_EMPTY_CTOR_DTOR(GuestFile)
39
40 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
41 void uninit(void);
42
43 HRESULT FinalConstruct(void);
44 void FinalRelease(void);
45 /** @} */
46
47public:
48 /** @name Public internal methods.
49 * @{ */
50 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
51 int i_closeFile(int *pGuestRc);
52 EventSource *i_getEventSource(void) { return mEventSource; }
53 static Utf8Str i_guestErrorToString(int guestRc);
54 int i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
55 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
56 int i_onRemove(void);
57 int i_openFile(uint32_t uTimeoutMS, int *pGuestRc);
58 int i_queryInfo(GuestFsObjData &objData, int *prcGuest);
59 int i_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
60 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
61 void* pvData, size_t cbData, size_t* pcbRead);
62 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
63 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
64 int i_setFileStatus(FileStatus_T fileStatus, int fileRc);
65 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
66 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
67 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
68 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
69 int i_writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
70 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
71 /** @} */
72
73private:
74
75 /** @name Wrapped IGuestFile properties.
76 * @{ */
77 HRESULT getCreationMode(ULONG *aCreationMode);
78 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
79 HRESULT getId(ULONG *aId);
80 HRESULT getInitialSize(LONG64 *aInitialSize);
81 HRESULT getOffset(LONG64 *aOffset);
82 HRESULT getStatus(FileStatus_T *aStatus);
83 HRESULT getFileName(com::Utf8Str &aFileName);
84 HRESULT getAccessMode(FileAccessMode_T *aAccessMode);
85 HRESULT getOpenAction(FileOpenAction_T *aOpenAction);
86 /** @} */
87
88 /** @name Wrapped IGuestFile methods.
89 * @{ */
90 HRESULT close();
91 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
92 HRESULT querySize(LONG64 *aSize);
93 HRESULT read(ULONG aToRead,
94 ULONG aTimeoutMS,
95 std::vector<BYTE> &aData);
96 HRESULT readAt(LONG64 aOffset,
97 ULONG aToRead,
98 ULONG aTimeoutMS,
99 std::vector<BYTE> &aData);
100 HRESULT seek(LONG64 aOffset,
101 FileSeekOrigin_T aWhence,
102 LONG64 *aNewOffset);
103 HRESULT setACL(const com::Utf8Str &aAcl,
104 ULONG aMode);
105 HRESULT setSize(LONG64 aSize);
106 HRESULT write(const std::vector<BYTE> &aData,
107 ULONG aTimeoutMS,
108 ULONG *aWritten);
109 HRESULT writeAt(LONG64 aOffset,
110 const std::vector<BYTE> &aData,
111 ULONG aTimeoutMS,
112 ULONG *aWritten);
113 /** @} */
114
115 /** This can safely be used without holding any locks.
116 * An AutoCaller suffices to prevent it being destroy while in use and
117 * internally there is a lock providing the necessary serialization. */
118 const ComObjPtr<EventSource> mEventSource;
119
120 struct Data
121 {
122 /** The file's open info. */
123 GuestFileOpenInfo mOpenInfo;
124 /** The file's initial size on open. */
125 uint64_t mInitialSize;
126 /** The current file status. */
127 FileStatus_T mStatus;
128 /** The last returned process status
129 * returned from the guest side. */
130 int mLastError;
131 /** The file's current offset. */
132 uint64_t mOffCurrent;
133 } mData;
134};
135
136#endif /* !____H_GUESTFILEIMPL */
137
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette