VirtualBox

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

Last change on this file since 38296 was 38296, checked in by vboxsync, 14 years ago

xpcom build fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: GuestDirEntryImpl.cpp 38296 2011-08-03 11:16:08Z 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.215389.xyz. 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 mData.mName = BstrFmt("%s", streamBlock.GetString("name"));
62 mData.mType = GuestDirEntry::fileTypeToEntryType(streamBlock.GetString("ftype"));
63
64 /* Confirm a successful initialization when it's the case. */
65 autoInitSpan.setSucceeded();
66
67 return S_OK;
68}
69
70/**
71 * Uninitializes the instance.
72 * Called from FinalRelease().
73 */
74void GuestDirEntry::uninit()
75{
76 LogFlowThisFunc(("\n"));
77
78 /* Enclose the state transition Ready->InUninit->NotReady. */
79 AutoUninitSpan autoUninitSpan(this);
80 if (autoUninitSpan.uninitDone())
81 return;
82}
83
84STDMETHODIMP GuestDirEntry::COMGETTER(NodeId)(LONG64 *aNodeId)
85{
86 LogFlowThisFuncEnter();
87
88 CheckComArgOutPointerValid(aNodeId);
89
90 AutoCaller autoCaller(this);
91 if (FAILED(autoCaller.rc())) return autoCaller.rc();
92
93 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
94
95 *aNodeId = mData.mNodeId;
96
97 return S_OK;
98}
99
100STDMETHODIMP GuestDirEntry::COMGETTER(Name)(BSTR *aName)
101{
102 LogFlowThisFuncEnter();
103
104 CheckComArgOutPointerValid(aName);
105
106 AutoCaller autoCaller(this);
107 if (FAILED(autoCaller.rc())) return autoCaller.rc();
108
109 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
110
111 mData.mName.cloneTo(aName);
112
113 return S_OK;
114}
115
116STDMETHODIMP GuestDirEntry::COMGETTER(Type)(GuestDirEntryType_T *aType)
117{
118 LogFlowThisFuncEnter();
119
120 CheckComArgOutPointerValid(aType);
121
122 AutoCaller autoCaller(this);
123 if (FAILED(autoCaller.rc())) return autoCaller.rc();
124
125 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
126
127 *aType = mData.mType;
128
129 return S_OK;
130}
131
132GuestDirEntryType_T GuestDirEntry::fileTypeToEntryType(const char *pszFileType)
133{
134 GuestDirEntryType_T retType = GuestDirEntryType_Unknown;
135
136 if (!pszFileType)
137 return retType;
138
139 if (!RTStrICmp(pszFileType, "-"))
140 retType = GuestDirEntryType_File;
141 else if (!RTStrICmp(pszFileType, "d"))
142 retType = GuestDirEntryType_Directory;
143 else if (!RTStrICmp(pszFileType, "l"))
144 retType = GuestDirEntryType_Symlink;
145 /** @todo Add more types here. */
146
147 return retType;
148}
149
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