VirtualBox

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

Last change on this file since 50922 was 50874, checked in by vboxsync, 11 years ago

6813 src-all/ProgressImp.cpp + some formatting/line length sorting

  • 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 50874 2014-03-25 18:29:02Z 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.215389.xyz. 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,
65 void* pvData, size_t cbData, size_t* pcbRead);
66 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
67 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
68 int i_setFileStatus(FileStatus_T fileStatus, int fileRc);
69 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
70 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
71 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
72 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
73 int i_writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
74 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
75 /** @} */
76
77private:
78
79 // Wrapped IGuestFile properties.
80 HRESULT getCreationMode(ULONG *aCreationMode);
81 HRESULT getDisposition(com::Utf8Str &aDisposition);
82 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
83 HRESULT getFileName(com::Utf8Str &aFileName);
84 HRESULT getId(ULONG *aId);
85 HRESULT getInitialSize(LONG64 *aInitialSize);
86 HRESULT getOpenMode(com::Utf8Str &aOpenMode);
87 HRESULT getOffset(LONG64 *aOffset);
88 HRESULT getStatus(FileStatus_T *aStatus);
89
90 // Wrapped IGuestFile methods.
91 HRESULT close();
92 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
93 HRESULT read(ULONG aToRead,
94 ULONG aTimeoutMS,
95 std::vector<BYTE> &aData);
96 HRESULT readAt(LONG64 aOffset,
97 ULONG aToRead,
98 ULONG aTimeoutMS,
99 std::vector<BYTE> &aData);
100 HRESULT seek(LONG64 aOffset,
101 FileSeekType_T aWhence);
102 HRESULT setACL(const com::Utf8Str &aAcl);
103 HRESULT write(const std::vector<BYTE> &aData,
104 ULONG aTimeoutMS,
105 ULONG *aWritten);
106 HRESULT writeAt(LONG64 aOffset,
107 const std::vector<BYTE> &aData,
108 ULONG aTimeoutMS,
109 ULONG *aWritten);
110
111 /** This can safely be used without holding any locks.
112 * An AutoCaller suffices to prevent it being destroy while in use and
113 * internally there is a lock providing the necessary serialization. */
114 const ComObjPtr<EventSource> mEventSource;
115
116 struct Data
117 {
118 /** The file's open info. */
119 GuestFileOpenInfo mOpenInfo;
120 /** The file's initial size on open. */
121 uint64_t mInitialSize;
122 /** The file's ID. */
123 uint32_t mID;
124 /** The current file status. */
125 FileStatus_T mStatus;
126 /** The last returned process status
127 * returned from the guest side. */
128 int mLastError;
129 /** The file's current offset. */
130 uint64_t mOffCurrent;
131 } mData;
132};
133
134#endif /* !____H_GUESTFILEIMPL */
135
Note: See TracBrowser for help on using the repository browser.

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