VirtualBox

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

Last change on this file since 55437 was 51321, checked in by vboxsync, 11 years ago

Main: Fixed broken documentation due to wrapper changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: GuestFileImpl.h 51321 2014-05-21 13:02:44Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2014 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 /** Wrapped @name IGuestFile properties.
75 * @{ */
76 HRESULT getCreationMode(ULONG *aCreationMode);
77 HRESULT getDisposition(com::Utf8Str &aDisposition);
78 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
79 HRESULT getFileName(com::Utf8Str &aFileName);
80 HRESULT getId(ULONG *aId);
81 HRESULT getInitialSize(LONG64 *aInitialSize);
82 HRESULT getOpenMode(com::Utf8Str &aOpenMode);
83 HRESULT getOffset(LONG64 *aOffset);
84 HRESULT getStatus(FileStatus_T *aStatus);
85 /** @} */
86
87 /** Wrapped @name IGuestFile methods.
88 * @{ */
89 HRESULT close();
90 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
91 HRESULT read(ULONG aToRead,
92 ULONG aTimeoutMS,
93 std::vector<BYTE> &aData);
94 HRESULT readAt(LONG64 aOffset,
95 ULONG aToRead,
96 ULONG aTimeoutMS,
97 std::vector<BYTE> &aData);
98 HRESULT seek(LONG64 aOffset,
99 FileSeekType_T aWhence);
100 HRESULT setACL(const com::Utf8Str &aAcl);
101 HRESULT write(const std::vector<BYTE> &aData,
102 ULONG aTimeoutMS,
103 ULONG *aWritten);
104 HRESULT writeAt(LONG64 aOffset,
105 const std::vector<BYTE> &aData,
106 ULONG aTimeoutMS,
107 ULONG *aWritten);
108 /** @} */
109
110 /** This can safely be used without holding any locks.
111 * An AutoCaller suffices to prevent it being destroy while in use and
112 * internally there is a lock providing the necessary serialization. */
113 const ComObjPtr<EventSource> mEventSource;
114
115 struct Data
116 {
117 /** The file's open info. */
118 GuestFileOpenInfo mOpenInfo;
119 /** The file's initial size on open. */
120 uint64_t mInitialSize;
121 /** The file's ID. */
122 uint32_t mID;
123 /** The current file status. */
124 FileStatus_T mStatus;
125 /** The last returned process status
126 * returned from the guest side. */
127 int mLastError;
128 /** The file's current offset. */
129 uint64_t mOffCurrent;
130 } mData;
131};
132
133#endif /* !____H_GUESTFILEIMPL */
134
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