VirtualBox

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

Last change on this file since 77387 was 77387, checked in by vboxsync, 6 years ago

GuestControl/Main: Const'ed data to write in i_writeData[At].

  • 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 77387 2019-02-20 14:20:19Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2019 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 MAIN_INCLUDED_GuestFileImpl_h
19#define MAIN_INCLUDED_GuestFileImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "VirtualBoxBase.h"
25#include "EventImpl.h"
26
27#include "GuestCtrlImplPrivate.h"
28#include "GuestFileWrap.h"
29
30class Console;
31class GuestSession;
32class GuestProcess;
33
34class ATL_NO_VTABLE GuestFile :
35 public GuestFileWrap,
36 public GuestObject
37{
38public:
39 /** @name COM and internal init/term/mapping cruft.
40 * @{ */
41 DECLARE_EMPTY_CTOR_DTOR(GuestFile)
42
43 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
44 void uninit(void);
45
46 HRESULT FinalConstruct(void);
47 void FinalRelease(void);
48 /** @} */
49
50public:
51 /** @name Public internal methods.
52 * @{ */
53 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
54 int i_closeFile(int *pGuestRc);
55 EventSource *i_getEventSource(void) { return mEventSource; }
56 static Utf8Str i_guestErrorToString(int guestRc);
57 int i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
58 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
59 int i_onRemove(void);
60 int i_openFile(uint32_t uTimeoutMS, int *pGuestRc);
61 int i_queryInfo(GuestFsObjData &objData, int *prcGuest);
62 int i_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
63 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
64 void* pvData, size_t cbData, size_t* pcbRead);
65 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
66 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
67 int i_setFileStatus(FileStatus_T fileStatus, int fileRc);
68 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
69 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
70 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
71 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
72 int i_writeData(uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten);
73 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten);
74 /** @} */
75
76private:
77
78 /** @name Wrapped IGuestFile properties.
79 * @{ */
80 HRESULT getCreationMode(ULONG *aCreationMode);
81 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
82 HRESULT getId(ULONG *aId);
83 HRESULT getInitialSize(LONG64 *aInitialSize);
84 HRESULT getOffset(LONG64 *aOffset);
85 HRESULT getStatus(FileStatus_T *aStatus);
86 HRESULT getFilename(com::Utf8Str &aFilename);
87 HRESULT getAccessMode(FileAccessMode_T *aAccessMode);
88 HRESULT getOpenAction(FileOpenAction_T *aOpenAction);
89 /** @} */
90
91 /** @name Wrapped IGuestFile methods.
92 * @{ */
93 HRESULT close();
94 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
95 HRESULT querySize(LONG64 *aSize);
96 HRESULT read(ULONG aToRead,
97 ULONG aTimeoutMS,
98 std::vector<BYTE> &aData);
99 HRESULT readAt(LONG64 aOffset,
100 ULONG aToRead,
101 ULONG aTimeoutMS,
102 std::vector<BYTE> &aData);
103 HRESULT seek(LONG64 aOffset,
104 FileSeekOrigin_T aWhence,
105 LONG64 *aNewOffset);
106 HRESULT setACL(const com::Utf8Str &aAcl,
107 ULONG aMode);
108 HRESULT setSize(LONG64 aSize);
109 HRESULT write(const std::vector<BYTE> &aData,
110 ULONG aTimeoutMS,
111 ULONG *aWritten);
112 HRESULT writeAt(LONG64 aOffset,
113 const std::vector<BYTE> &aData,
114 ULONG aTimeoutMS,
115 ULONG *aWritten);
116 /** @} */
117
118 /** This can safely be used without holding any locks.
119 * An AutoCaller suffices to prevent it being destroy while in use and
120 * internally there is a lock providing the necessary serialization. */
121 const ComObjPtr<EventSource> mEventSource;
122
123 struct Data
124 {
125 /** The file's open info. */
126 GuestFileOpenInfo mOpenInfo;
127 /** The file's initial size on open. */
128 uint64_t mInitialSize;
129 /** The current file status. */
130 FileStatus_T mStatus;
131 /** The last returned process status
132 * returned from the guest side. */
133 int mLastError;
134 /** The file's current offset. */
135 uint64_t mOffCurrent;
136 } mData;
137};
138
139#endif /* !MAIN_INCLUDED_GuestFileImpl_h */
140
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