VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/GuestFileImpl.cpp@ 42699

Last change on this file since 42699 was 42611, checked in by vboxsync, 12 years ago

Guest Control 2.0: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1
2/* $Id: GuestFileImpl.cpp 42611 2012-08-06 08:42:23Z vboxsync $ */
3/** @file
4 * VirtualBox Main - XXX.
5 */
6
7/*
8 * Copyright (C) 2012 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
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#include "GuestFileImpl.h"
24#include "GuestSessionImpl.h"
25#include "GuestCtrlImplPrivate.h"
26
27#include "Global.h"
28#include "AutoCaller.h"
29
30#include <VBox/com/array.h>
31
32
33// constructor / destructor
34/////////////////////////////////////////////////////////////////////////////
35
36DEFINE_EMPTY_CTOR_DTOR(GuestFile)
37
38HRESULT GuestFile::FinalConstruct()
39{
40 LogFlowThisFunc(("\n"));
41 return BaseFinalConstruct();
42}
43
44void GuestFile::FinalRelease(void)
45{
46 LogFlowThisFuncEnter();
47 uninit();
48 BaseFinalRelease();
49 LogFlowThisFuncLeave();
50}
51
52// public initializer/uninitializer for internal purposes only
53/////////////////////////////////////////////////////////////////////////////
54
55int GuestFile::init(GuestSession *pSession, const Utf8Str &strPath,
56 const Utf8Str &strOpenMode, const Utf8Str &strDisposition, uint32_t uCreationMode,
57 int64_t iOffset)
58{
59 /* Enclose the state transition NotReady->InInit->Ready. */
60 AutoInitSpan autoInitSpan(this);
61 AssertReturn(autoInitSpan.isOk(), E_FAIL);
62
63 mData.mSession = pSession;
64 mData.mCreationMode = uCreationMode;
65 mData.mDisposition = getDispositionFromString(strDisposition);
66 mData.mFileName = strPath;
67 mData.mInitialSize = 0;
68 mData.mOpenMode = getOpenModeFromString(strOpenMode);
69 mData.mOffset = iOffset;
70
71 /** @todo Validate parameters! */
72
73 /* Confirm a successful initialization when it's the case. */
74 autoInitSpan.setSucceeded();
75
76 return VINF_SUCCESS;
77}
78
79/**
80 * Uninitializes the instance.
81 * Called from FinalRelease().
82 */
83void GuestFile::uninit(void)
84{
85 LogFlowThisFunc(("\n"));
86
87 /* Enclose the state transition Ready->InUninit->NotReady. */
88 AutoUninitSpan autoUninitSpan(this);
89 if (autoUninitSpan.uninitDone())
90 return;
91
92 mData.mSession->fileClose(this);
93}
94
95// implementation of public getters/setters for attributes
96/////////////////////////////////////////////////////////////////////////////
97
98STDMETHODIMP GuestFile::COMGETTER(CreationMode)(ULONG *aCreationMode)
99{
100#ifndef VBOX_WITH_GUEST_CONTROL
101 ReturnComNotImplemented();
102#else
103 AutoCaller autoCaller(this);
104 if (FAILED(autoCaller.rc())) return autoCaller.rc();
105
106 CheckComArgOutPointerValid(aCreationMode);
107
108 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
109
110 *aCreationMode = mData.mCreationMode;
111
112 return S_OK;
113#endif /* VBOX_WITH_GUEST_CONTROL */
114}
115
116STDMETHODIMP GuestFile::COMGETTER(Disposition)(ULONG *aDisposition)
117{
118#ifndef VBOX_WITH_GUEST_CONTROL
119 ReturnComNotImplemented();
120#else
121 AutoCaller autoCaller(this);
122 if (FAILED(autoCaller.rc())) return autoCaller.rc();
123
124 CheckComArgOutPointerValid(aDisposition);
125
126 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
127
128 *aDisposition = mData.mDisposition;
129
130 return S_OK;
131#endif /* VBOX_WITH_GUEST_CONTROL */
132}
133
134STDMETHODIMP GuestFile::COMGETTER(FileName)(BSTR *aFileName)
135{
136#ifndef VBOX_WITH_GUEST_CONTROL
137 ReturnComNotImplemented();
138#else
139 AutoCaller autoCaller(this);
140 if (FAILED(autoCaller.rc())) return autoCaller.rc();
141
142 CheckComArgOutPointerValid(aFileName);
143
144 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
145
146 mData.mFileName.cloneTo(aFileName);
147
148 return S_OK;
149#endif /* VBOX_WITH_GUEST_CONTROL */
150}
151
152STDMETHODIMP GuestFile::COMGETTER(InitialSize)(LONG64 *aInitialSize)
153{
154#ifndef VBOX_WITH_GUEST_CONTROL
155 ReturnComNotImplemented();
156#else
157 AutoCaller autoCaller(this);
158 if (FAILED(autoCaller.rc())) return autoCaller.rc();
159
160 CheckComArgOutPointerValid(aInitialSize);
161
162 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
163
164 *aInitialSize = mData.mInitialSize;
165
166 return S_OK;
167#endif /* VBOX_WITH_GUEST_CONTROL */
168}
169
170STDMETHODIMP GuestFile::COMGETTER(Offset)(LONG64 *aOffset)
171{
172#ifndef VBOX_WITH_GUEST_CONTROL
173 ReturnComNotImplemented();
174#else
175 AutoCaller autoCaller(this);
176 if (FAILED(autoCaller.rc())) return autoCaller.rc();
177
178 CheckComArgOutPointerValid(aOffset);
179
180 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
181
182 *aOffset = mData.mOffset;
183
184 return S_OK;
185#endif /* VBOX_WITH_GUEST_CONTROL */
186}
187
188STDMETHODIMP GuestFile::COMGETTER(OpenMode)(ULONG *aOpenMode)
189{
190#ifndef VBOX_WITH_GUEST_CONTROL
191 ReturnComNotImplemented();
192#else
193 AutoCaller autoCaller(this);
194 if (FAILED(autoCaller.rc())) return autoCaller.rc();
195
196 CheckComArgOutPointerValid(aOpenMode);
197
198 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
199
200 *aOpenMode = mData.mOpenMode;
201
202 return S_OK;
203#endif /* VBOX_WITH_GUEST_CONTROL */
204}
205
206// private methods
207/////////////////////////////////////////////////////////////////////////////
208
209/* static */
210uint32_t GuestFile::getDispositionFromString(const Utf8Str &strDisposition)
211{
212 return 0; /** @todo Implement me! */
213}
214
215/* static */
216uint32_t GuestFile::getOpenModeFromString(const Utf8Str &strOpenMode)
217{
218 return 0; /** @todo Implement me! */
219}
220
221// implementation of public methods
222/////////////////////////////////////////////////////////////////////////////
223
224STDMETHODIMP GuestFile::Close(void)
225{
226#ifndef VBOX_WITH_GUEST_CONTROL
227 ReturnComNotImplemented();
228#else
229 AutoCaller autoCaller(this);
230 if (FAILED(autoCaller.rc())) return autoCaller.rc();
231
232 ReturnComNotImplemented();
233#endif /* VBOX_WITH_GUEST_CONTROL */
234}
235
236STDMETHODIMP GuestFile::QueryInfo(IFsObjInfo **aInfo)
237{
238#ifndef VBOX_WITH_GUEST_CONTROL
239 ReturnComNotImplemented();
240#else
241 AutoCaller autoCaller(this);
242 if (FAILED(autoCaller.rc())) return autoCaller.rc();
243
244 ReturnComNotImplemented();
245#endif /* VBOX_WITH_GUEST_CONTROL */
246}
247
248STDMETHODIMP GuestFile::Read(ULONG aToRead, ULONG *aRead, ComSafeArrayOut(BYTE, aData))
249{
250#ifndef VBOX_WITH_GUEST_CONTROL
251 ReturnComNotImplemented();
252#else
253 AutoCaller autoCaller(this);
254 if (FAILED(autoCaller.rc())) return autoCaller.rc();
255
256 ReturnComNotImplemented();
257#endif /* VBOX_WITH_GUEST_CONTROL */
258}
259
260STDMETHODIMP GuestFile::ReadAt(LONG64 aOffset, ULONG aToRead, ULONG *aRead, ComSafeArrayOut(BYTE, aData))
261{
262#ifndef VBOX_WITH_GUEST_CONTROL
263 ReturnComNotImplemented();
264#else
265 AutoCaller autoCaller(this);
266 if (FAILED(autoCaller.rc())) return autoCaller.rc();
267
268 ReturnComNotImplemented();
269#endif /* VBOX_WITH_GUEST_CONTROL */
270}
271
272STDMETHODIMP GuestFile::Seek(LONG64 aOffset, FileSeekType_T aType)
273{
274#ifndef VBOX_WITH_GUEST_CONTROL
275 ReturnComNotImplemented();
276#else
277 AutoCaller autoCaller(this);
278 if (FAILED(autoCaller.rc())) return autoCaller.rc();
279
280 ReturnComNotImplemented();
281#endif /* VBOX_WITH_GUEST_CONTROL */
282}
283
284STDMETHODIMP GuestFile::SetACL(IN_BSTR aACL)
285{
286#ifndef VBOX_WITH_GUEST_CONTROL
287 ReturnComNotImplemented();
288#else
289 AutoCaller autoCaller(this);
290 if (FAILED(autoCaller.rc())) return autoCaller.rc();
291
292 ReturnComNotImplemented();
293#endif /* VBOX_WITH_GUEST_CONTROL */
294}
295
296STDMETHODIMP GuestFile::Write(ComSafeArrayIn(BYTE, aData), ULONG *aWritten)
297{
298#ifndef VBOX_WITH_GUEST_CONTROL
299 ReturnComNotImplemented();
300#else
301 AutoCaller autoCaller(this);
302 if (FAILED(autoCaller.rc())) return autoCaller.rc();
303
304 ReturnComNotImplemented();
305#endif /* VBOX_WITH_GUEST_CONTROL */
306}
307
308STDMETHODIMP GuestFile::WriteAt(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG *aWritten)
309{
310#ifndef VBOX_WITH_GUEST_CONTROL
311 ReturnComNotImplemented();
312#else
313 AutoCaller autoCaller(this);
314 if (FAILED(autoCaller.rc())) return autoCaller.rc();
315
316 ReturnComNotImplemented();
317#endif /* VBOX_WITH_GUEST_CONTROL */
318}
319
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