VirtualBox

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

Last change on this file since 62485 was 62485, checked in by vboxsync, 8 years ago

(C) 2016

  • 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 62485 2016-07-22 18:36:43Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2016 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_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
59 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
60 void* pvData, size_t cbData, size_t* pcbRead);
61 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
62 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
63 int i_setFileStatus(FileStatus_T fileStatus, int fileRc);
64 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
65 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
66 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
67 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
68 int i_writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
69 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
70 /** @} */
71
72private:
73
74 /** @name Wrapped IGuestFile properties.
75 * @{ */
76 HRESULT getCreationMode(ULONG *aCreationMode);
77 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
78 HRESULT getId(ULONG *aId);
79 HRESULT getInitialSize(LONG64 *aInitialSize);
80 HRESULT getOffset(LONG64 *aOffset);
81 HRESULT getStatus(FileStatus_T *aStatus);
82 HRESULT getFileName(com::Utf8Str &aFileName);
83 HRESULT getAccessMode(FileAccessMode_T *aAccessMode);
84 HRESULT getOpenAction(FileOpenAction_T *aOpenAction);
85 /** @} */
86
87 /** @name Wrapped IGuestFile methods.
88 * @{ */
89 HRESULT close();
90 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
91 HRESULT querySize(LONG64 *aSize);
92 HRESULT read(ULONG aToRead,
93 ULONG aTimeoutMS,
94 std::vector<BYTE> &aData);
95 HRESULT readAt(LONG64 aOffset,
96 ULONG aToRead,
97 ULONG aTimeoutMS,
98 std::vector<BYTE> &aData);
99 HRESULT seek(LONG64 aOffset,
100 FileSeekOrigin_T aWhence,
101 LONG64 *aNewOffset);
102 HRESULT setACL(const com::Utf8Str &aAcl,
103 ULONG aMode);
104 HRESULT setSize(LONG64 aSize);
105 HRESULT write(const std::vector<BYTE> &aData,
106 ULONG aTimeoutMS,
107 ULONG *aWritten);
108 HRESULT writeAt(LONG64 aOffset,
109 const std::vector<BYTE> &aData,
110 ULONG aTimeoutMS,
111 ULONG *aWritten);
112 /** @} */
113
114 /** This can safely be used without holding any locks.
115 * An AutoCaller suffices to prevent it being destroy while in use and
116 * internally there is a lock providing the necessary serialization. */
117 const ComObjPtr<EventSource> mEventSource;
118
119 struct Data
120 {
121 /** The file's open info. */
122 GuestFileOpenInfo mOpenInfo;
123 /** The file's initial size on open. */
124 uint64_t mInitialSize;
125 /** The file's ID. */
126 uint32_t mID;
127 /** The current file status. */
128 FileStatus_T mStatus;
129 /** The last returned process status
130 * returned from the guest side. */
131 int mLastError;
132 /** The file's current offset. */
133 uint64_t mOffCurrent;
134 } mData;
135};
136
137#endif /* !____H_GUESTFILEIMPL */
138
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