VirtualBox

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

Last change on this file since 50736 was 50618, checked in by vboxsync, 11 years ago

6813 src-client/GuestFileImpl.cpp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1
2/* $Id: GuestFileImpl.h 50618 2014-02-26 19:55:39Z vboxsync $ */
3/** @file
4 * VirtualBox Main - Guest file handling.
5 */
6
7/*
8 * Copyright (C) 2012-2014 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ____H_GUESTFILEIMPL
20#define ____H_GUESTFILEIMPL
21
22#include "VirtualBoxBase.h"
23#include "EventImpl.h"
24
25#include "GuestCtrlImplPrivate.h"
26#include "GuestFileWrap.h"
27
28class Console;
29class GuestSession;
30class GuestProcess;
31
32/**
33 * TODO
34 */
35class ATL_NO_VTABLE GuestFile :
36 public GuestFileWrap,
37 public GuestObject
38{
39public:
40 /** @name COM and internal init/term/mapping cruft.
41 * @{ */
42 DECLARE_EMPTY_CTOR_DTOR(GuestFile)
43
44 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
45 void uninit(void);
46
47 HRESULT FinalConstruct(void);
48 void FinalRelease(void);
49 /** @} */
50
51
52public:
53 /** @name Public internal methods.
54 * @{ */
55 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
56 int i_closeFile(int *pGuestRc);
57 EventSource *i_getEventSource(void) { return mEventSource; }
58 static Utf8Str i_guestErrorToString(int guestRc);
59 int i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
60 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
61 int i_onRemove(void);
62 int i_openFile(uint32_t uTimeoutMS, int *pGuestRc);
63 int i_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
64 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, 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, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
73 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
74 /** @} */
75
76private:
77
78 // Wrapped IGuestFile properties.
79 HRESULT getCreationMode(ULONG *aCreationMode);
80 HRESULT getDisposition(com::Utf8Str &aDisposition);
81 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
82 HRESULT getFileName(com::Utf8Str &aFileName);
83 HRESULT getId(ULONG *aId);
84 HRESULT getInitialSize(LONG64 *aInitialSize);
85 HRESULT getOpenMode(com::Utf8Str &aOpenMode);
86 HRESULT getOffset(LONG64 *aOffset);
87 HRESULT getStatus(FileStatus_T *aStatus);
88
89 // Wrapped IGuestFile methods.
90 HRESULT close();
91 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
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 FileSeekType_T aWhence);
101 HRESULT setACL(const com::Utf8Str &aAcl);
102 HRESULT write(const std::vector<BYTE> &aData,
103 ULONG aTimeoutMS,
104 ULONG *aWritten);
105 HRESULT writeAt(LONG64 aOffset,
106 const std::vector<BYTE> &aData,
107 ULONG aTimeoutMS,
108 ULONG *aWritten);
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