Fix a memory leak in Deserializer
[platform/framework/native/appfw.git] / src / io / FIoRegistry.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FIoRegistry.cpp
19  * @brief       This is the implementation file for %Registry class.
20  */
21
22 #include <new>
23 #include <limits.h>
24 #include <unique_ptr.h>
25
26 #include <FBaseInteger.h>
27 #include <FBaseDouble.h>
28 #include <FBaseFloat.h>
29 #include <FBaseUuId.h>
30 #include <FBaseString.h>
31 #include <FBaseByteBuffer.h>
32 #include <FBaseUtilStringTokenizer.h>
33 #include <FBaseResult.h>
34 #include <FBaseSysLog.h>
35 #include <FIoRegistry.h>
36
37 #include <FBase_StringConverter.h>
38 #include <FApp_AppInfo.h>
39 #include "FIo_RegistryImpl.h"
40
41 using namespace std;
42 using namespace Tizen::Base;
43 using namespace Tizen::Base::Utility;
44 using namespace Tizen::Base::Collection;
45
46 namespace Tizen { namespace Io
47 {
48
49 Registry::Registry(void)
50         : __pRegistryImpl(null)
51 {
52 }
53
54 Registry::~Registry(void)
55 {
56         delete __pRegistryImpl;
57         __pRegistryImpl = null;
58 }
59
60 // This method will be removed in a future release.
61 result
62 Registry::Construct(const String& regPath, bool createIfNotExist)
63 {
64         SysAssertf(__pRegistryImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
65
66         long openMode = REG_OPEN_READ_WRITE;
67         if (createIfNotExist)
68         {
69                 openMode |= REG_OPEN_CREATE;
70         }
71
72         return Construct(regPath, openMode, null);
73 }
74
75 // This method will be removed in a future release.
76 result
77 Registry::Construct(const String& regPath, long openMode, long option)
78 {
79         SysAssertf(__pRegistryImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
80         SysTryReturnResult(NID_IO, regPath.GetLength() > 0 && regPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
81                         "The length of the specified regPath is zero or exceeds system limitations.");
82
83         unique_ptr<_RegistryImpl> pRegistryImpl(new (std::nothrow) _RegistryImpl());
84         SysTryReturnResult(NID_IO, pRegistryImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
85
86         result r = pRegistryImpl->Construct(regPath, openMode, null);
87         if (IsFailed(r))
88         {
89                 if (r == E_SYSTEM && Tizen::App::_AppInfo::IsOspCompat() == true)
90                 {
91                         r = E_IO;
92                 }
93                 SysPropagate(NID_IO, r);
94                 return r;
95         }
96         __pRegistryImpl = pRegistryImpl.release();
97
98         return E_SUCCESS;
99 }
100
101 result
102 Registry::Construct(const String& regPath, const char* pOpenMode)
103 {
104         SysAssertf(__pRegistryImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
105         SysTryReturnResult(NID_IO, regPath.GetLength() > 0 && regPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
106                         "The length of the specified regPath is zero or exceeds system limitations.");
107
108         unique_ptr<_RegistryImpl> pRegistryImpl(new (std::nothrow) _RegistryImpl());
109         SysTryReturnResult(NID_IO, pRegistryImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
110
111         result r = pRegistryImpl->Construct(regPath, pOpenMode, null);
112         SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
113
114         __pRegistryImpl = pRegistryImpl.release();
115
116         return E_SUCCESS;
117 }
118
119 result
120 Registry::Construct(const String& regPath, const char* pOpenMode, const ByteBuffer& key)
121 {
122         SysAssertf(__pRegistryImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
123         SysTryReturnResult(NID_IO, regPath.GetLength() > 0 && regPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
124                         "The length of the specified regPath is zero or exceeds system limitations.");
125
126         unique_ptr<_RegistryImpl> pRegistryImpl(new (std::nothrow) _RegistryImpl());
127         SysTryReturnResult(NID_IO, pRegistryImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
128
129         result r = pRegistryImpl->Construct(regPath, pOpenMode, &key);
130         SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
131
132         __pRegistryImpl = pRegistryImpl.release();
133
134         return E_SUCCESS;
135 }
136
137 result
138 Registry::Flush(void)
139 {
140         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
141         result r = E_SUCCESS;
142
143         r = __pRegistryImpl->Flush();
144         SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Flush failed.", GetErrorMessage(r));
145
146         return r;
147 }
148
149 result
150 Registry::AddSection(const String& sectionName)
151 {
152         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
153         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
154
155         return __pRegistryImpl->AddSection(sectionName);
156 }
157
158 result
159 Registry::RemoveSection(const String& sectionName)
160 {
161         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
162         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
163
164         return __pRegistryImpl->RemoveSection(sectionName);
165 }
166
167 IList*
168 Registry::GetAllSectionNamesN(void) const
169 {
170         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
171         result r = E_SUCCESS;
172         IList* pList = null;
173
174         r = __pRegistryImpl->GetSectionListN(&pList);
175         SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propagating to caller...", GetErrorMessage(r));
176
177         SetLastResult(E_SUCCESS);
178         return pList;
179 }
180
181 IList*
182 Registry::GetAllEntryNamesN(const String& sectionName) const
183 {
184         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
185         return __pRegistryImpl->GetAllEntryNamesN(sectionName);
186 }
187
188 result
189 Registry::AddValue(const String& sectionName, const String& entryName, int entryValue)
190 {
191         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
192         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
193         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
194
195         return __pRegistryImpl->AddValue(sectionName, entryName, Integer::ToString(entryValue));
196 }
197
198 result
199 Registry::AddValue(const String& sectionName, const String& entryName, double entryValue)
200 {
201         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
202         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
203         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
204
205         return __pRegistryImpl->AddValue(sectionName, entryName, entryValue);
206 }
207
208 result
209 Registry::AddValue(const String& sectionName, const String& entryName, float entryValue)
210 {
211         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
212         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
213         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
214
215         return __pRegistryImpl->AddValue(sectionName, entryName, entryValue);
216 }
217
218 result
219 Registry::AddValue(const String& sectionName, const String& entryName, const String& entryValue)
220 {
221         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
222         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
223         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
224
225         return __pRegistryImpl->AddValue(sectionName, entryName, entryValue);
226 }
227
228 result
229 Registry::AddValue(const String& sectionName, const String& entryName, const UuId& entryValue)
230 {
231         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
232         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
233         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
234
235         return __pRegistryImpl->AddValue(sectionName, entryName, entryValue.ToString());
236 }
237
238 result
239 Registry::AddValue(const String& sectionName, const String& entryName, const ByteBuffer& entryValue)
240 {
241         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
242         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
243         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
244
245         int size = entryValue.GetLimit();
246         SysTryReturnResult(NID_IO, size > 0, E_INVALID_ARG, "invalid buffer length");
247
248         String strValEncoded;
249         String strVal;
250         result r = E_SUCCESS;
251         byte* pValue = const_cast< byte* >(entryValue.GetPointer());
252         SysAssert(pValue);
253
254         for (int i = 0; i < size; i++)
255         {
256                 r = strValEncoded.Format(3, L"%02x", (static_cast< unsigned char* >(pValue)[i]));
257                 if (IsFailed(r))
258                 {
259                         SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
260                         return r;
261                 }
262                 r = strVal.Append(strValEncoded);
263                 if (IsFailed(r))
264                 {
265                         SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
266                         return r;
267                 }
268         }
269
270         return __pRegistryImpl->AddValue(sectionName, entryName, strVal);
271 }
272
273 result
274 Registry::GetValue(const String& sectionName, const String& entryName, int& retVal) const
275 {
276         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
277         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
278         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
279
280         result r = E_SUCCESS;
281         String valStr;
282
283         r = __pRegistryImpl->GetValue(sectionName, entryName, valStr);
284         if (!IsFailed(r))
285         {
286                 r = Integer::Parse(valStr, retVal);
287                 if (IsFailed(r))
288                 {
289                         r = E_PARSING_FAILED;
290                 }
291         }
292
293         return r;
294 }
295
296 result
297 Registry::GetValue(const String& sectionName, const String& entryName, double& retVal) const
298 {
299         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
300         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
301         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
302
303         return __pRegistryImpl->GetValue(sectionName, entryName, retVal);
304 }
305
306 result
307 Registry::GetValue(const String& sectionName, const String& entryName, float& retVal) const
308 {
309         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
310         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
311         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
312
313         return __pRegistryImpl->GetValue(sectionName, entryName, retVal);
314 }
315
316 result
317 Registry::GetValue(const String& sectionName, const String& entryName, String& retVal) const
318 {
319         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
320         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
321         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
322
323         return __pRegistryImpl->GetValue(sectionName, entryName, retVal);
324 }
325
326 result
327 Registry::GetValue(const String& sectionName, const String& entryName, UuId& retVal) const
328 {
329         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
330         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
331         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
332
333         result r = E_SUCCESS;
334         String valStr;
335
336         r = __pRegistryImpl->GetValue(sectionName, entryName, valStr);
337         if (!IsFailed(r))
338         {
339                 r = UuId::Parse(valStr, retVal);
340                 if (IsFailed(r))
341                 {
342                         r = E_PARSING_FAILED;
343                 }
344         }
345
346         return r;
347 }
348
349 result
350 Registry::GetValue(const String& sectionName, const String& entryName, ByteBuffer& retVal) const
351 {
352         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
353         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
354         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
355
356         int size = retVal.GetLimit();
357         SysTryReturnResult(NID_IO, size > 0, E_INVALID_ARG, "Invalid buffer length");
358
359         result r = E_SUCCESS;
360         String valStr;
361
362         r = __pRegistryImpl->GetValue(sectionName, entryName, valStr);
363         if (!IsFailed(r))
364         {
365                 int length = valStr.GetLength();
366                 int length2 = (size * 2);
367                 int parseSize = (length2 <= length) ? length2 : length;
368                 byte* pRetVal = const_cast< byte* >(retVal.GetPointer());
369                 SysAssert(pRetVal);
370                 for (int i = 0, j = 0; i < parseSize; i++)
371                 {
372                         unsigned long ul = 0;
373                         wchar_t ch = valStr[i];
374                         wchar_t tmp[3];
375
376                         if ((ch >= L'0' && ch <= L'9') || (ch >= L'a' && ch <= L'f') || (ch >= L'A' && ch <= L'F'))
377                         {
378                                 tmp[i % 2] = ch;
379                                 if (i % 2)
380                                 {
381                                         tmp[2] = L'\0';
382                                         ul = wcstoul(tmp, null, 16);
383                                         (static_cast< unsigned char* >(pRetVal))[j++] = static_cast< unsigned char >(ul);
384                                 }
385                         }
386                         else
387                         {
388                                 return E_PARSING_FAILED;
389                         }
390
391                 }
392
393                 parseSize = parseSize/2;
394                 SysAssertf(parseSize <= size, "The specified ByteBuffer is not enough to get the entry value from registry file.");
395                 if (parseSize < size)
396                 {
397                         // resize buffer limit
398                         r = retVal.SetLimit(parseSize);
399                         SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
400                 }
401         }
402         return r;
403 }
404
405 result
406 Registry::SetValue(const String& sectionName, const String& entryName, int newValue)
407 {
408         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
409         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
410         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
411
412         return __pRegistryImpl->SetValue(sectionName, entryName, Integer::ToString(newValue));
413 }
414
415 result
416 Registry::SetValue(const String& sectionName, const String& entryName, double newValue)
417 {
418         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
419         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
420         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
421
422         return __pRegistryImpl->SetValue(sectionName, entryName, newValue);
423 }
424
425 result
426 Registry::SetValue(const String& sectionName, const String& entryName, float newValue)
427 {
428         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
429         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
430         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
431
432         return __pRegistryImpl->SetValue(sectionName, entryName, newValue);
433 }
434
435 result
436 Registry::SetValue(const String& sectionName, const String& entryName, const String& newValue)
437 {
438         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
439         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName is empty");
440         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName is empty");
441         //SysTryReturnResult(NID_IO, newValue.GetLength() > 0, E_INVALID_ARG, "newValue is empty");
442
443         return __pRegistryImpl->SetValue(sectionName, entryName, newValue);
444 }
445
446 result
447 Registry::SetValue(const String& sectionName, const String& entryName, const UuId& newValue)
448 {
449         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
450         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
451         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
452
453         return __pRegistryImpl->SetValue(sectionName, entryName, newValue.ToString());
454 }
455
456 result
457 Registry::SetValue(const String& sectionName, const String& entryName, const ByteBuffer& newValue)
458 {
459         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
460         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
461         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
462
463         int size = newValue.GetLimit();
464         SysTryReturnResult(NID_IO, size > 0, E_INVALID_ARG, "invalid buffer length");
465
466         String strValEncoded;
467         String strVal;
468         result r = E_SUCCESS;
469         byte* pNewValue = const_cast< byte* >(newValue.GetPointer());
470         SysAssert(pNewValue);
471
472         for (int i = 0; i < size; i++)
473         {
474                 r = strValEncoded.Format(3, L"%02x", (static_cast< unsigned char* >(pNewValue)[i]));
475                 if (IsFailed(r))
476                 {
477                         SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
478                         return r;
479                 }
480                 r = strVal.Append(strValEncoded);
481                 if (IsFailed(r))
482                 {
483                         SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
484                         return r;
485                 }
486         }
487
488         return __pRegistryImpl->SetValue(sectionName, entryName, strVal);
489 }
490
491 result
492 Registry::RemoveValue(const String& sectionName, const String& entryName)
493 {
494         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
495         SysTryReturnResult(NID_IO, sectionName.GetLength() > 0, E_INVALID_ARG, "sectionName.GetLength() <= 0");
496         SysTryReturnResult(NID_IO, entryName.GetLength() > 0, E_INVALID_ARG, "entryName.GetLength() <= 0");
497
498         return __pRegistryImpl->RemoveValue(sectionName, entryName);
499 }
500
501 result
502 Registry::Remove(const String& regPath)
503 {
504         SysTryReturnResult(NID_IO, regPath.GetLength() > 0 && regPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
505                                          "regPath.GetLength <= 0 or long name was given.");
506
507         return _RegistryImpl::Remove(regPath);
508 }
509
510 result
511 Registry::ConvertToSecureRegistry(const String& plainRegPath, const String& secureRegPath, const ByteBuffer& key)
512 {
513         SysTryReturnResult(NID_IO, plainRegPath.GetLength() > 0 && plainRegPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
514                                          "plainRegPath.GetLength <= 0 or long name was given.");
515         SysTryReturnResult(NID_IO, secureRegPath.GetLength() > 0 && secureRegPath.GetLength() <= PATH_MAX, E_INVALID_ARG,
516                                          "secureRegPath.GetLength <= 0 or long name was given.");
517         SysTryReturnResult(NID_IO, key.GetLimit() > 0, E_INVALID_ARG, "key.GetLimit <= 0.");
518
519         return _RegistryImpl::ConvertToSecureRegistry(plainRegPath, secureRegPath, &key);
520 }
521
522 FileLock*
523 Registry::LockN(FileLockType lockType)
524 {
525         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
526         return __pRegistryImpl->LockN(lockType);
527 }
528
529 FileLock*
530 Registry::TryToLockN(FileLockType lockType)
531 {
532         SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
533         return __pRegistryImpl->TryToLockN(lockType);
534 }
535
536 }} // Tizen::Io
537