VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/GuestDirEntryImpl.cpp@ 38290

Last change on this file since 38290 was 38290, checked in by vboxsync, 13 years ago

GuestCtrl: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "GuestDirEntryImpl.h"
19#include "GuestCtrlImplPrivate.h"
20#include "Global.h"
21
22#include "AutoCaller.h"
23#include "Logging.h"
24
25// constructor / destructor
26/////////////////////////////////////////////////////////////////////////////
27
28DEFINE_EMPTY_CTOR_DTOR(GuestDirEntry)
29
30HRESULT GuestDirEntry::FinalConstruct()
31{
32 LogFlowThisFunc(("\n"));
33 return BaseFinalConstruct();
34}
35
36void GuestDirEntry::FinalRelease()
37{
38 LogFlowThisFuncEnter();
39 uninit();
40 BaseFinalRelease();
41 LogFlowThisFuncLeave();
42}
43
44// public initializer/uninitializer for internal purposes only
45/////////////////////////////////////////////////////////////////////////////
46
47HRESULT GuestDirEntry::init(Guest *aParent, GuestProcessStreamBlock &streamBlock)
48{
49 LogFlowThisFunc(("aParent=%p\n", aParent));
50
51 /* Enclose the state transition NotReady->InInit->Ready. */
52 AutoInitSpan autoInitSpan(this);
53 AssertReturn(autoInitSpan.isOk(), E_FAIL);
54
55 mData.mNodeId = streamBlock.GetInt64("node_id");
56 mData.mName = BstrFmt("%s", streamBlock.GetString("name"));
57 mData.mType = GuestDirEntry::fileTypeToEntryType(streamBlock.GetString("ftype"));
58
59 /* Confirm a successful initialization when it's the case. */
60 autoInitSpan.setSucceeded();
61
62 return S_OK;
63}
64
65/**
66 * Uninitializes the instance.
67 * Called from FinalRelease().
68 */
69void GuestDirEntry::uninit()
70{
71 LogFlowThisFunc(("\n"));
72
73 /* Enclose the state transition Ready->InUninit->NotReady. */
74 AutoUninitSpan autoUninitSpan(this);
75 if (autoUninitSpan.uninitDone())
76 return;
77}
78
79STDMETHODIMP GuestDirEntry::COMGETTER(NodeId)(LONG64 *aNodeId)
80{
81 LogFlowThisFuncEnter();
82
83 CheckComArgOutPointerValid(aNodeId);
84
85 AutoCaller autoCaller(this);
86 if (FAILED(autoCaller.rc())) return autoCaller.rc();
87
88 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
89
90 *aNodeId = mData.mNodeId;
91
92 return S_OK;
93}
94
95STDMETHODIMP GuestDirEntry::COMGETTER(Name)(BSTR *aName)
96{
97 LogFlowThisFuncEnter();
98
99 CheckComArgOutPointerValid(aName);
100
101 AutoCaller autoCaller(this);
102 if (FAILED(autoCaller.rc())) return autoCaller.rc();
103
104 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
105
106 mData.mName.cloneTo(aName);
107
108 return S_OK;
109}
110
111STDMETHODIMP GuestDirEntry::COMGETTER(Type)(GuestDirEntryType_T *aType)
112{
113 LogFlowThisFuncEnter();
114
115 CheckComArgOutPointerValid(aType);
116
117 AutoCaller autoCaller(this);
118 if (FAILED(autoCaller.rc())) return autoCaller.rc();
119
120 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
121
122 *aType = mData.mType;
123
124 return S_OK;
125}
126
127GuestDirEntryType_T GuestDirEntry::fileTypeToEntryType(const char *pszFileType)
128{
129 GuestDirEntryType_T retType = GuestDirEntryType_Unknown;
130
131 if (!pszFileType)
132 return retType;
133
134 if (!RTStrICmp(pszFileType, "-"))
135 retType = GuestDirEntryType_File;
136 else if (!RTStrICmp(pszFileType, "d"))
137 retType = GuestDirEntryType_Directory;
138 else if (!RTStrICmp(pszFileType, "l"))
139 retType = GuestDirEntryType_Symlink;
140 /** @todo Add more types here. */
141
142 return retType;
143}
144
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