1 |
|
---|
2 | /* $Id: GuestFileImpl.cpp 42095 2012-07-10 12:58:13Z 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 |
|
---|
25 | #include "Global.h"
|
---|
26 | #include "AutoCaller.h"
|
---|
27 | #include "Logging.h"
|
---|
28 |
|
---|
29 | #include <VBox/com/array.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | // constructor / destructor
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | DEFINE_EMPTY_CTOR_DTOR(GuestFile)
|
---|
36 |
|
---|
37 | HRESULT GuestFile::FinalConstruct()
|
---|
38 | {
|
---|
39 | LogFlowThisFunc(("\n"));
|
---|
40 | return BaseFinalConstruct();
|
---|
41 | }
|
---|
42 |
|
---|
43 | void GuestFile::FinalRelease(void)
|
---|
44 | {
|
---|
45 | LogFlowThisFuncEnter();
|
---|
46 | uninit();
|
---|
47 | BaseFinalRelease();
|
---|
48 | LogFlowThisFuncLeave();
|
---|
49 | }
|
---|
50 |
|
---|
51 | // public initializer/uninitializer for internal purposes only
|
---|
52 | /////////////////////////////////////////////////////////////////////////////
|
---|
53 |
|
---|
54 | HRESULT GuestFile::init(void)
|
---|
55 | {
|
---|
56 | /* Enclose the state transition NotReady->InInit->Ready. */
|
---|
57 | AutoInitSpan autoInitSpan(this);
|
---|
58 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
59 |
|
---|
60 | /* Confirm a successful initialization when it's the case. */
|
---|
61 | autoInitSpan.setSucceeded();
|
---|
62 |
|
---|
63 | return S_OK;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Uninitializes the instance.
|
---|
68 | * Called from FinalRelease().
|
---|
69 | */
|
---|
70 | void GuestFile::uninit(void)
|
---|
71 | {
|
---|
72 | LogFlowThisFunc(("\n"));
|
---|
73 |
|
---|
74 | /* Enclose the state transition Ready->InUninit->NotReady. */
|
---|
75 | AutoUninitSpan autoUninitSpan(this);
|
---|
76 | if (autoUninitSpan.uninitDone())
|
---|
77 | return;
|
---|
78 | }
|
---|
79 |
|
---|
80 | // implementation of public getters/setters for attributes
|
---|
81 | /////////////////////////////////////////////////////////////////////////////
|
---|
82 |
|
---|
83 | STDMETHODIMP GuestFile::COMGETTER(FileName)(BSTR *aFileName)
|
---|
84 | {
|
---|
85 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
86 | ReturnComNotImplemented();
|
---|
87 | #else
|
---|
88 | AutoCaller autoCaller(this);
|
---|
89 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
90 |
|
---|
91 | ReturnComNotImplemented();
|
---|
92 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
93 | }
|
---|
94 |
|
---|
95 | STDMETHODIMP GuestFile::COMGETTER(InitialSize)(LONG64 *aInitialSize)
|
---|
96 | {
|
---|
97 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
98 | ReturnComNotImplemented();
|
---|
99 | #else
|
---|
100 | AutoCaller autoCaller(this);
|
---|
101 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
102 |
|
---|
103 | ReturnComNotImplemented();
|
---|
104 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
105 | }
|
---|
106 |
|
---|
107 | STDMETHODIMP GuestFile::COMGETTER(Offset)(LONG64 *aOffset)
|
---|
108 | {
|
---|
109 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
110 | ReturnComNotImplemented();
|
---|
111 | #else
|
---|
112 | AutoCaller autoCaller(this);
|
---|
113 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
114 |
|
---|
115 | ReturnComNotImplemented();
|
---|
116 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
117 | }
|
---|
118 |
|
---|
119 | STDMETHODIMP GuestFile::COMGETTER(OpenMode)(ULONG *aOpenMode)
|
---|
120 | {
|
---|
121 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
122 | ReturnComNotImplemented();
|
---|
123 | #else
|
---|
124 | AutoCaller autoCaller(this);
|
---|
125 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
126 |
|
---|
127 | ReturnComNotImplemented();
|
---|
128 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
129 | }
|
---|
130 |
|
---|
131 | // implementation of public methods
|
---|
132 | /////////////////////////////////////////////////////////////////////////////
|
---|
133 |
|
---|
134 | STDMETHODIMP GuestFile::Close(void)
|
---|
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 | ReturnComNotImplemented();
|
---|
143 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
144 | }
|
---|
145 |
|
---|
146 | STDMETHODIMP GuestFile::QueryInfo(IGuestFsObjInfo **aInfo)
|
---|
147 | {
|
---|
148 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
149 | ReturnComNotImplemented();
|
---|
150 | #else
|
---|
151 | AutoCaller autoCaller(this);
|
---|
152 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
153 |
|
---|
154 | ReturnComNotImplemented();
|
---|
155 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
156 | }
|
---|
157 |
|
---|
158 | STDMETHODIMP GuestFile::Read(ULONG aToRead, ULONG *aRead, ComSafeArrayOut(BYTE, aData))
|
---|
159 | {
|
---|
160 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
161 | ReturnComNotImplemented();
|
---|
162 | #else
|
---|
163 | AutoCaller autoCaller(this);
|
---|
164 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
165 |
|
---|
166 | ReturnComNotImplemented();
|
---|
167 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
168 | }
|
---|
169 |
|
---|
170 | STDMETHODIMP GuestFile::ReadAt(LONG64 aOffset, ULONG aToRead, ULONG *aRead, ComSafeArrayOut(BYTE, aData))
|
---|
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 | ReturnComNotImplemented();
|
---|
179 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
180 | }
|
---|
181 |
|
---|
182 | STDMETHODIMP GuestFile::Seek(LONG64 aOffset, FileSeekType_T aType)
|
---|
183 | {
|
---|
184 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
185 | ReturnComNotImplemented();
|
---|
186 | #else
|
---|
187 | AutoCaller autoCaller(this);
|
---|
188 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
189 |
|
---|
190 | ReturnComNotImplemented();
|
---|
191 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
192 | }
|
---|
193 |
|
---|
194 | STDMETHODIMP GuestFile::SetACL(IN_BSTR aACL)
|
---|
195 | {
|
---|
196 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
197 | ReturnComNotImplemented();
|
---|
198 | #else
|
---|
199 | AutoCaller autoCaller(this);
|
---|
200 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
201 |
|
---|
202 | ReturnComNotImplemented();
|
---|
203 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
204 | }
|
---|
205 |
|
---|
206 | STDMETHODIMP GuestFile::Write(ComSafeArrayIn(BYTE, aData), ULONG *aWritten)
|
---|
207 | {
|
---|
208 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
209 | ReturnComNotImplemented();
|
---|
210 | #else
|
---|
211 | AutoCaller autoCaller(this);
|
---|
212 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
213 |
|
---|
214 | ReturnComNotImplemented();
|
---|
215 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
216 | }
|
---|
217 |
|
---|
218 | STDMETHODIMP GuestFile::WriteAt(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG *aWritten)
|
---|
219 | {
|
---|
220 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
221 | ReturnComNotImplemented();
|
---|
222 | #else
|
---|
223 | AutoCaller autoCaller(this);
|
---|
224 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
225 |
|
---|
226 | ReturnComNotImplemented();
|
---|
227 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
228 | }
|
---|
229 |
|
---|