2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FIoFileiEventManager.cpp
20 * @brief This is the implementation file for FileEventManager class.
24 #include <unique_ptr.h>
26 #include <FBaseSysLog.h>
27 #include <FIoFileEventManager.h>
28 #include <FIoIFileEventListener.h>
30 #include <FIo_FileEventManagerImpl.h>
32 using namespace Tizen::Base;
34 namespace Tizen { namespace Io
36 FileEventManager::FileEventManager(void)
37 : __pFileEventManagerImpl(null)
41 FileEventManager::~FileEventManager(void)
43 delete __pFileEventManagerImpl;
47 FileEventManager::Construct(IFileEventListener& listener)
49 SysAssertf(__pFileEventManagerImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 std::unique_ptr<_FileEventManagerImpl> pFileEventManagerImpl(new (std::nothrow) _FileEventManagerImpl);
53 SysTryReturnResult(NID_IO, pFileEventManagerImpl, E_OUT_OF_MEMORY, "The memory is insufficient.");
55 r = pFileEventManagerImpl->Construct(listener);
56 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
58 __pFileEventManagerImpl = pFileEventManagerImpl.release();
64 FileEventManager::AddPath(const String& path, unsigned long eventsToMonitor)
67 SysAssertf(__pFileEventManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
68 r = __pFileEventManagerImpl->AddPath(path, eventsToMonitor);
70 if (r == E_FILE_NOT_FOUND)
72 SysLogException(NID_IO, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] An entry for the specified path[%ls] could not be found.", path.GetPointer());
74 else if (r == E_ILLEGAL_ACCESS)
76 SysLogException(NID_IO, E_ILLEGAL_ACCESS, "[E_ILLEGAL_ACCESS] The specified path is not permitted.");
78 else if (r == E_INVALID_ARG)
80 SysLogException(NID_IO, E_INVALID_ARG, "[E_INVALID_ARG] The specified eventsToMonitor contains no valid events.");
84 SysLogException(NID_IO, E_IO, "[E_IO] I/O error is occurred.");
90 FileEventManager::RemovePath(const String& path)
93 SysAssertf(__pFileEventManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
94 r = __pFileEventManagerImpl->RemovePath(path);
98 SysLogException(NID_IO, E_IO, "[E_IO] I/O error is occurred.");