${PROJECT_SOURCE_DIR}/modules/core/src/exception.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/fast_delegate.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/file_input.cpp
- ${PROJECT_SOURCE_DIR}/modules/core/src/file_lock.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/file_output.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/mutable_task_list.cpp
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/exception.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/fast_delegate.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input.h
- ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_lock.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_output.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/foreach.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/generic_event.h
+++ /dev/null
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file file_lock.h
- * @author Tomasz Iwanek (t.iwanek@samsung.com)
- * @version 1.0
- * @brief This implementation fo file locking
- */
-#ifndef DPL_FILE_LOCK_H
-#define DPL_FILE_LOCK_H
-
-#include <string>
-#include <cstddef>
-
-#include <dpl/exception.h>
-#include <dpl/noncopyable.h>
-
-namespace DPL {
-class FileLock : private Noncopyable
-{
- protected:
- int m_fd;
- std::string m_filename;
- size_t m_mode;
-
- public:
- FileLock(const std::string & filename, bool blocking = true, size_t mode = 0666);
- ~FileLock();
-
- bool lock(bool blocking = true);
- bool unlock();
- bool isHoldingLock() const;
- int getFd() const;
-};
-
-class FileBasedMutex : public FileLock
-{
-public:
- FileBasedMutex(const std::string & id, bool blocking = true);
-};
-
-} // namespace DPL
-
-#endif // DPL_FILE_LOCK_H
+++ /dev/null
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file file_input.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of named input pipe
- */
-
-#include <dpl/file_lock.h>
-
-#include <sys/file.h>
-
-namespace DPL {
-
-FileLock::FileLock(const std::string & filename, bool blocking, size_t mode) : m_filename(filename), m_mode(mode)
-{
- lock(blocking);
-}
-
-FileLock::~FileLock()
-{
- if(isHoldingLock())
- {
- unlock();
- }
-}
-
-bool FileLock::lock(bool blocking)
-{
- if(isHoldingLock()) return true;
-
- int ret = 0;
-
- m_fd = open(m_filename.c_str(), O_RDONLY | O_CREAT, m_mode);
-
- if (m_fd == -1) {
- return false;
- }
-
- if(blocking)
- {
- ret = flock(m_fd, LOCK_EX);
- }
- else
- {
- ret = flock(m_fd, LOCK_EX | LOCK_NB);
- }
-
- if (ret == -1) {
- close(m_fd);
- m_fd = -1;
- return false;
- }
-
- return true;
-}
-
-bool FileLock::unlock()
-{
- if(!isHoldingLock()) return true;
-
- int ret = 0;
- ret = flock(m_fd, LOCK_UN);
- if(ret == -1)
- {
- return false;
- }
- close(m_fd);
- m_fd = -1;
- return true;
-}
-
-bool FileLock::isHoldingLock() const
-{
- return (m_fd > 0);
-}
-
-int FileLock::getFd() const
-{
- return m_fd;
-}
-
-FileBasedMutex::FileBasedMutex(const std::string & id, bool blocking) : FileLock(std::string("/tmp/.dpl_lock.") + id, blocking)
-{
-}
-
-} // namespace DPL
-