VirtualBox

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

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

GuestCtrl: Request (IPC) changes, bugfixes, fixed handle leaks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: GuestDirEntryImpl.cpp 39843 2012-01-23 18:38:18Z vboxsync $ */
2/** @file
3 * VirtualBox Main - interface for guest directory entries, VBoxC.
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
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include "GuestDirEntryImpl.h"
23#include "GuestCtrlImplPrivate.h"
24#include "Global.h"
25
26#include "AutoCaller.h"
27#include "Logging.h"
28
29
30// constructor / destructor
31/////////////////////////////////////////////////////////////////////////////
32
33DEFINE_EMPTY_CTOR_DTOR(GuestDirEntry)
34
35HRESULT GuestDirEntry::FinalConstruct()
36{
37 LogFlowThisFunc(("\n"));
38 return BaseFinalConstruct();
39}
40
41void GuestDirEntry::FinalRelease()
42{
43 LogFlowThisFuncEnter();
44 uninit();
45 BaseFinalRelease();
46 LogFlowThisFuncLeave();
47}
48
49// public initializer/uninitializer for internal purposes only
50/////////////////////////////////////////////////////////////////////////////
51
52HRESULT GuestDirEntry::init(Guest *aParent, GuestProcessStreamBlock &streamBlock)
53{
54 LogFlowThisFunc(("aParent=%p\n", aParent));
55
56 /* Enclose the state transition NotReady->InInit->Ready. */
57 AutoInitSpan autoInitSpan(this);
58 AssertReturn(autoInitSpan.isOk(), E_FAIL);
59
60 mData.mNodeId = streamBlock.GetInt64("node_id");
61 const char *pszName = streamBlock.GetString("name");
62 if (pszName)
63 {
64 mData.mName = BstrFmt("%s", pszName);
65 mData.mType = GuestDirEntry::fileTypeToEntryType(streamBlock.GetString("ftype"));
66
67 /* Confirm a successful initialization when it's the case. */
68 autoInitSpan.setSucceeded();
69
70 return S_OK;
71 }
72
73 return E_FAIL; /** @todo Find a better rc! */
74}
75
76/**
77 * Uninitializes the instance.
78 * Called from FinalRelease().
79 */
80void GuestDirEntry::uninit()
81{
82 LogFlowThisFunc(("\n"));
83
84 /* Enclose the state transition Ready->InUninit->NotReady. */
85 AutoUninitSpan autoUninitSpan(this);
86 if (autoUninitSpan.uninitDone())
87 return;
88}
89
90STDMETHODIMP GuestDirEntry::COMGETTER(NodeId)(LONG64 *aNodeId)
91{
92 LogFlowThisFuncEnter();
93
94 CheckComArgOutPointerValid(aNodeId);
95
96 AutoCaller autoCaller(this);
97 if (FAILED(autoCaller.rc())) return autoCaller.rc();
98
99 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
100
101 *aNodeId = mData.mNodeId;
102
103 return S_OK;
104}
105
106STDMETHODIMP GuestDirEntry::COMGETTER(Name)(BSTR *aName)
107{
108 LogFlowThisFuncEnter();
109
110 CheckComArgOutPointerValid(aName);
111
112 AutoCaller autoCaller(this);
113 if (FAILED(autoCaller.rc())) return autoCaller.rc();
114
115 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
116
117 mData.mName.cloneTo(aName);
118
119 return S_OK;
120}
121
122STDMETHODIMP GuestDirEntry::COMGETTER(Type)(GuestDirEntryType_T *aType)
123{
124 LogFlowThisFuncEnter();
125
126 CheckComArgOutPointerValid(aType);
127
128 AutoCaller autoCaller(this);
129 if (FAILED(autoCaller.rc())) return autoCaller.rc();
130
131 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
132
133 *aType = mData.mType;
134
135 return S_OK;
136}
137
138GuestDirEntryType_T GuestDirEntry::fileTypeToEntryType(const char *pszFileType)
139{
140 GuestDirEntryType_T retType = GuestDirEntryType_Unknown;
141
142 if (!pszFileType)
143 return retType;
144
145 if (!RTStrICmp(pszFileType, "-"))
146 retType = GuestDirEntryType_File;
147 else if (!RTStrICmp(pszFileType, "d"))
148 retType = GuestDirEntryType_Directory;
149 else if (!RTStrICmp(pszFileType, "l"))
150 retType = GuestDirEntryType_Symlink;
151 /** @todo Add more types here. */
152
153 return retType;
154}
155
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