VirtualBox

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

Last change on this file was 104001, checked in by vboxsync, 7 weeks ago

Guest Control/Main: Renaming (removed "File" from some internal GuestFile APIs; unnecessary).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: GuestFileImpl.h 104001 2024-03-22 16:03:33Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_GuestFileImpl_h
29#define MAIN_INCLUDED_GuestFileImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "VirtualBoxBase.h"
35#include "EventImpl.h"
36
37#include "GuestCtrlImplPrivate.h"
38#include "GuestFileWrap.h"
39
40class Console;
41class GuestSession;
42class GuestProcess;
43
44class ATL_NO_VTABLE GuestFile :
45 public GuestFileWrap,
46 public GuestObject
47{
48public:
49 /** @name COM and internal init/term/mapping cruft.
50 * @{ */
51 DECLARE_COMMON_CLASS_METHODS(GuestFile)
52
53 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
54 void uninit(void);
55
56 HRESULT FinalConstruct(void);
57 void FinalRelease(void);
58 /** @} */
59
60public:
61 /** @name Implemented virtual methods from GuestObject.
62 * @{ */
63 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
64 int i_onUnregister(void);
65 int i_onSessionStatusChange(GuestSessionStatus_T enmSessionStatus);
66 /** @} */
67
68public:
69 /** @name Public internal methods.
70 * @{ */
71 int i_close(int *pGuestRc);
72 EventSource *i_getEventSource(void) { return mEventSource; }
73 int i_onNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
74 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
75 int i_open(uint32_t uTimeoutMS, int *pGuestRc);
76 int i_queryInfo(GuestFsObjData &objData, int *prcGuest);
77 int i_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
78 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
79 void* pvData, size_t cbData, size_t* pcbRead);
80 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
81 int i_setFileStatus(FileStatus_T fileStatus, int vrcFile);
82 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
83 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
84 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
85 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
86 int i_writeData(uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten);
87 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten);
88 /** @} */
89
90 /** @name Static helper methods.
91 * @{ */
92 static Utf8Str i_guestErrorToString(int guestRc, const char *pcszWhat);
93 /** @} */
94
95public:
96
97 /** @name Wrapped IGuestFile properties.
98 * @{ */
99 HRESULT getCreationMode(ULONG *aCreationMode);
100 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
101 HRESULT getId(ULONG *aId);
102 HRESULT getInitialSize(LONG64 *aInitialSize);
103 HRESULT getOffset(LONG64 *aOffset);
104 HRESULT getStatus(FileStatus_T *aStatus);
105 HRESULT getFilename(com::Utf8Str &aFilename);
106 HRESULT getAccessMode(FileAccessMode_T *aAccessMode);
107 HRESULT getOpenAction(FileOpenAction_T *aOpenAction);
108 /** @} */
109
110 /** @name Wrapped IGuestFile methods.
111 * @{ */
112 HRESULT close();
113 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
114 HRESULT querySize(LONG64 *aSize);
115 HRESULT read(ULONG aToRead,
116 ULONG aTimeoutMS,
117 std::vector<BYTE> &aData);
118 HRESULT readAt(LONG64 aOffset,
119 ULONG aToRead,
120 ULONG aTimeoutMS,
121 std::vector<BYTE> &aData);
122 HRESULT seek(LONG64 aOffset,
123 FileSeekOrigin_T aWhence,
124 LONG64 *aNewOffset);
125 HRESULT setACL(const com::Utf8Str &aAcl,
126 ULONG aMode);
127 HRESULT setSize(LONG64 aSize);
128 HRESULT write(const std::vector<BYTE> &aData,
129 ULONG aTimeoutMS,
130 ULONG *aWritten);
131 HRESULT writeAt(LONG64 aOffset,
132 const std::vector<BYTE> &aData,
133 ULONG aTimeoutMS,
134 ULONG *aWritten);
135 /** @} */
136
137private:
138
139 /** This can safely be used without holding any locks.
140 * An AutoCaller suffices to prevent it being destroy while in use and
141 * internally there is a lock providing the necessary serialization. */
142 const ComObjPtr<EventSource> mEventSource;
143
144 struct Data
145 {
146 /** The file's open info. */
147 GuestFileOpenInfo mOpenInfo;
148 /** The file's initial size on open. */
149 uint64_t mInitialSize;
150 /** The current file status. */
151 FileStatus_T mStatus;
152 /** The last returned process status
153 * returned from the guest side. */
154 int mLastError;
155 /** The file's current offset. */
156 uint64_t mOffCurrent;
157 } mData;
158};
159
160#endif /* !MAIN_INCLUDED_GuestFileImpl_h */
161
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use