2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FIoFileiEventManager.cpp
19 * @brief This is the implementation file for FileEventManager class.
23 #include <unique_ptr.h>
25 #include <FBaseSysLog.h>
26 #include <FIoFileEventManager.h>
27 #include <FIoIFileEventListener.h>
29 #include <FIo_FileEventManagerImpl.h>
31 using namespace Tizen::Base;
33 namespace Tizen { namespace Io
35 FileEventManager::FileEventManager(void)
36 : __pFileEventManagerImpl(null)
40 FileEventManager::~FileEventManager(void)
42 delete __pFileEventManagerImpl;
46 FileEventManager::Construct(IFileEventListener& listener)
48 SysAssertf(__pFileEventManagerImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
51 std::unique_ptr<_FileEventManagerImpl> pFileEventManagerImpl(new (std::nothrow) _FileEventManagerImpl);
52 SysTryReturnResult(NID_IO, pFileEventManagerImpl, E_OUT_OF_MEMORY, "The memory is insufficient.");
54 r = pFileEventManagerImpl->Construct(listener);
55 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
57 __pFileEventManagerImpl = pFileEventManagerImpl.release();
63 FileEventManager::AddPath(const String& path, unsigned long eventsToMonitor)
66 SysAssertf(__pFileEventManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
67 r = __pFileEventManagerImpl->AddPath(path, eventsToMonitor);
69 if (r == E_FILE_NOT_FOUND)
71 SysLogException(NID_IO, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] An entry for the specified path[%ls] could not be found.", path.GetPointer());
73 else if (r == E_ILLEGAL_ACCESS)
75 SysLogException(NID_IO, E_ILLEGAL_ACCESS, "[E_ILLEGAL_ACCESS] The specified path is not permitted.");
77 else if (r == E_INVALID_ARG)
79 SysLogException(NID_IO, E_INVALID_ARG, "[E_INVALID_ARG] The specified eventsToMonitor contains no valid events.");
83 SysLogException(NID_IO, E_IO, "[E_IO] I/O error is occurred.");
89 FileEventManager::RemovePath(const String& path)
92 SysAssertf(__pFileEventManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
93 r = __pFileEventManagerImpl->RemovePath(path);
97 SysLogException(NID_IO, E_IO, "[E_IO] I/O error is occurred.");