VirtualBox

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

最後變更 在這個檔案從50500是 50500,由 vboxsync 提交於 11 年 前

6813 - client/GuestFsObjInfoImpl.cpp

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.3 KB
 
1
2/* $Id: GuestFileImpl.h 50500 2014-02-18 19:11:17Z 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.alldomusa.eu.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
27class Console;
28class GuestSession;
29class GuestProcess;
30
31/**
32 * TODO
33 */
34class ATL_NO_VTABLE GuestFile :
35 public VirtualBoxBase,
36 public GuestObject,
37 VBOX_SCRIPTABLE_IMPL(IGuestFile)
38{
39public:
40 /** @name COM and internal init/term/mapping cruft.
41 * @{ */
42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestFile, IGuestFile)
43 DECLARE_NOT_AGGREGATABLE(GuestFile)
44 DECLARE_PROTECT_FINAL_CONSTRUCT()
45 BEGIN_COM_MAP(GuestFile)
46 VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestFile)
47 COM_INTERFACE_ENTRY(IFile)
48 END_COM_MAP()
49 DECLARE_EMPTY_CTOR_DTOR(GuestFile)
50
51 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
52 void uninit(void);
53 HRESULT FinalConstruct(void);
54 void FinalRelease(void);
55 /** @} */
56
57 /** @name IFile interface.
58 * @{ */
59 STDMETHOD(COMGETTER(CreationMode))(ULONG *aCreationMode);
60 STDMETHOD(COMGETTER(Disposition))(BSTR *aDisposition);
61 STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
62 STDMETHOD(COMGETTER(FileName))(BSTR *aFileName);
63 STDMETHOD(COMGETTER(Id))(ULONG *aID);
64 STDMETHOD(COMGETTER(InitialSize))(LONG64 *aInitialSize);
65 STDMETHOD(COMGETTER(Offset))(LONG64 *aOffset);
66 STDMETHOD(COMGETTER(OpenMode))(BSTR *aOpenMode);
67 STDMETHOD(COMGETTER(Status))(FileStatus_T *aStatus);
68
69 STDMETHOD(Close)(void);
70 STDMETHOD(QueryInfo)(IFsObjInfo **aInfo);
71 STDMETHOD(Read)(ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
72 STDMETHOD(ReadAt)(LONG64 aOffset, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
73 STDMETHOD(Seek)(LONG64 aOffset, FileSeekType_T aType);
74 STDMETHOD(SetACL)(IN_BSTR aACL);
75 STDMETHOD(Write)(ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
76 STDMETHOD(WriteAt)(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
77 /** @} */
78
79public:
80 /** @name Public internal methods.
81 * @{ */
82 int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
83 int closeFile(int *pGuestRc);
84 EventSource *getEventSource(void) { return mEventSource; }
85 static Utf8Str guestErrorToString(int guestRc);
86 int onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
87 int onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
88 int onRemove(void);
89 int openFile(uint32_t uTimeoutMS, int *pGuestRc);
90 int readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
91 int readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, void* pvData, size_t cbData, size_t* pcbRead);
92 int seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
93 static HRESULT setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
94 int setFileStatus(FileStatus_T fileStatus, int fileRc);
95 int waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
96 int waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
97 int waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
98 int waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
99 int writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
100 int writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
101 /** @} */
102
103private:
104
105 /** This can safely be used without holding any locks.
106 * An AutoCaller suffices to prevent it being destroy while in use and
107 * internally there is a lock providing the necessary serialization. */
108 const ComObjPtr<EventSource> mEventSource;
109
110 struct Data
111 {
112 /** The file's open info. */
113 GuestFileOpenInfo mOpenInfo;
114 /** The file's initial size on open. */
115 uint64_t mInitialSize;
116 /** The file's ID. */
117 uint32_t mID;
118 /** The current file status. */
119 FileStatus_T mStatus;
120 /** The last returned process status
121 * returned from the guest side. */
122 int mLastError;
123 /** The file's current offset. */
124 uint64_t mOffCurrent;
125 } mData;
126};
127
128#endif /* !____H_GUESTFILEIMPL */
129
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette