Skip to content

Commit

Permalink
Merge pull request #1875 from ApexAI/iox-1391-move-filesystem-files-t…
Browse files Browse the repository at this point in the history
…o-separate-module

iox-1391 move filesystem files to separate module
  • Loading branch information
FerdinandSpitzschnueffler authored Feb 14, 2023
2 parents f4c81ab + 21b4e32 commit b093d24
Show file tree
Hide file tree
Showing 35 changed files with 168 additions and 132 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy-diff-scans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
./iceoryx_hoofs/buffer/**/*
./iceoryx_hoofs/test/moduletests/test_buffer_*

./iceoryx_hoofs/filesystem/**/*
./iceoryx_hoofs/test/moduletests/test_filesystem_*

# IMPORTANT:
# after the first # everything is considered a comment, add new files and
# directories only at the top of this file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Build & Test](https://github.com/eclipse-iceoryx/iceoryx/workflows/Build%20&%20Test/badge.svg?branch=master)](https://github.com/eclipse-iceoryx/iceoryx/actions)
[![Integrationtests](https://github.com/eclipse-iceoryx/iceoryx/workflows/Iceoryx%20Integrationtests/badge.svg?branch=master)](https://github.com/eclipse-iceoryx/iceoryx/actions)
[![Gitter](https://badges.gitter.im/eclipse-iceoryx/iceoryx.svg)](https://gitter.im/eclipse/iceoryx)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Codecov](https://codecov.io/gh/eclipse-iceoryx/iceoryx/branch/master/graph/badge.svg?branch=master)](https://codecov.io/gh/eclipse-iceoryx/iceoryx?branch=master)
[![Sanitize](https://github.com/eclipse/iceoryx/workflows/Sanitize/badge.svg?branch=master)](https://github.com/eclipse/iceoryx/actions?query=workflow%3ASanitize)

Expand Down
18 changes: 9 additions & 9 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
.memorySizeInBytes(16)
.accessMode(iox::posix::AccessMode::READ_WRITE)
.openMode(iox::posix::OpenMode::PURGE_AND_CREATE)
.permissions(cxx::perms::owner_all)
.permissions(perms::owner_all)
.create();
```

Expand Down Expand Up @@ -193,7 +193,7 @@
auto result = iox::posix::NamedSemaphoreBuilder()
.name("mySemaphoreName")
.openMode(iox::posix::OpenMode::OPEN_OR_CREATE)
.permissions(iox::cxx::perms::owner_all)
.permissions(iox::perms::owner_all)
.initialValue(0U)
.create(semaphore);
```
Expand Down Expand Up @@ -269,7 +269,7 @@
// after
auto fileLock = iox::posix::FileLockBuilder().name("lockFileName")
.path("/Now/I/Can/Add/A/Path")
.permission(iox::cxx::perms::owner_all)
.permission(iox::perms::owner_all)
.create()
.expect("Oh no I couldn't create the lock file");
```
Expand Down Expand Up @@ -375,12 +375,12 @@
iox::cxx::doesEndWithPathSeparator(..);

// after
#include "iceoryx_hoofs/cxx/filesystem.hpp"
iox::cxx::isValidPathEntry(..);
iox::cxx::isValidFileName(..);
iox::cxx::isValidPathToFile(..);
iox::cxx::isValidPathToDirectory(..);
iox::cxx::doesEndWithPathSeparator(..);
#include "iox/filesystem.hpp"
iox::isValidPathEntry(..);
iox::isValidFileName(..);
iox::isValidPathToFile(..);
iox::isValidPathToDirectory(..);
iox::doesEndWithPathSeparator(..);
```

```cpp
Expand Down
7 changes: 4 additions & 3 deletions iceoryx_dust/source/posix_wrapper/named_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "iceoryx_dust/posix_wrapper/named_pipe.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iox/deadline_timer.hpp"
#include "iox/filesystem.hpp"
#include "iox/into.hpp"

#include <thread>
Expand Down Expand Up @@ -60,10 +61,10 @@ NamedPipe::NamedPipe(const IpcChannelName_t& name,
}

// leading slash is allowed even though it is not a valid file name
bool isValidPipeName = cxx::isValidFileName(name)
bool isValidPipeName = isValidFileName(name)
// name is checked for emptiness, so it's ok to get a first member
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|| (!name.empty() && name.c_str()[0] == '/' && cxx::isValidFileName(*name.substr(1)));
|| (!name.empty() && name.c_str()[0] == '/' && isValidFileName(*name.substr(1)));
if (!isValidPipeName)
{
std::cerr << "The named pipe name: \"" << name << "\" is not a valid file path name." << std::endl;
Expand Down Expand Up @@ -96,7 +97,7 @@ NamedPipe::NamedPipe(const IpcChannelName_t& name,
.memorySizeInBytes(sizeof(NamedPipeData) + alignof(NamedPipeData))
.accessMode(AccessMode::READ_WRITE)
.openMode((channelSide == IpcChannelSide::SERVER) ? OpenMode::OPEN_OR_CREATE : OpenMode::OPEN_EXISTING)
.permissions(cxx::perms::owner_all | cxx::perms::group_all)
.permissions(perms::owner_all | perms::group_all)
.create()
.and_then([this](auto& value) { m_sharedMemory.emplace(std::move(value)); }))
{
Expand Down
6 changes: 4 additions & 2 deletions iceoryx_hoofs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
# Copyright (c) 2022 - 2023 by Apex.AI Inc. 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.
Expand Down Expand Up @@ -31,19 +31,21 @@ cc_library(
name = "iceoryx_hoofs",
srcs = glob([
"design/source/*.cpp",
"filesystem/source/*.cpp",
"memory/source/*.cpp",
"posix/time/source/*.cpp",
"source/**/*.cpp",
"time/source/*.cpp",
"vocabulary/source/**/*.cpp",
]),
hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["time/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["posix/**"]) + glob(["design/**"]) + glob(["buffer/**"]) + [
hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["time/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["posix/**"]) + glob(["design/**"]) + glob(["buffer/**"]) + glob(["filesystem/**"]) + [
":iceoryx_hoofs_deployment_hpp",
],
includes = [
"buffer/include/",
"container/include/",
"design/include",
"filesystem/include",
"include/",
"legacy/include/",
"memory/include/",
Expand Down
6 changes: 4 additions & 2 deletions iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2019 - 2021 by Robert Bosch GmbH. All rights reserved.
# Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
# Copyright (c) 2020 - 2023 by Apex.AI Inc. 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.
Expand Down Expand Up @@ -57,6 +57,7 @@ iox_add_library(
${PROJECT_SOURCE_DIR}/time/include
${PROJECT_SOURCE_DIR}/posix/time/include
${PROJECT_SOURCE_DIR}/buffer/include
${PROJECT_SOURCE_DIR}/filesystem/include
${CMAKE_BINARY_DIR}/generated/iceoryx_hoofs/include
INSTALL_INTERFACE include/${PREFIX}
EXPORT_INCLUDE_DIRS include/
Expand All @@ -70,14 +71,15 @@ iox_add_library(
time/include/
posix/time/include/
buffer/include/
filesystem/include/
FILES
design/source/functional_interface.cpp
filesystem/source/filesystem.cpp
memory/source/bump_allocator.cpp
memory/source/memory.cpp
posix/time/source/adaptive_wait.cpp
posix/time/source/deadline_timer.cpp
source/concurrent/loffli.cpp
source/cxx/filesystem.cpp
source/cxx/requires.cpp
source/cxx/type_traits.cpp
source/cxx/unique_id.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_CXX_FILESYSTEM_INL
#define IOX_HOOFS_CXX_FILESYSTEM_INL
#ifndef IOX_HOOFS_FILESYSTEM_FILESYSTEM_INL
#define IOX_HOOFS_FILESYSTEM_FILESYSTEM_INL

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iox/filesystem.hpp"

namespace iox
{
namespace cxx
{
template <uint64_t StringCapacity>
inline bool isValidPathEntry(const iox::string<StringCapacity>& name,
const RelativePathComponents relativePathComponents) noexcept
Expand Down Expand Up @@ -220,7 +218,6 @@ constexpr perms operator^=(const perms lhs, const perms rhs) noexcept
{
return operator^(lhs, rhs);
}
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_CXX_FILESYSTEM_HPP
#define IOX_HOOFS_CXX_FILESYSTEM_HPP
#ifndef IOX_HOOFS_FILESYSTEM_FILESYSTEM_HPP
#define IOX_HOOFS_FILESYSTEM_FILESYSTEM_HPP

#include "iox/string.hpp"

Expand All @@ -23,8 +23,6 @@

namespace iox
{
namespace cxx
{
namespace internal
{
// AXIVION DISABLE STYLE AutosarC++19_03-A3.9.1: Not used as an integer but as actual character.
Expand Down Expand Up @@ -197,9 +195,8 @@ constexpr perms operator^=(const perms lhs, const perms rhs) noexcept;
/// @return the reference to the stream
template <typename StreamType>
StreamType& operator<<(StreamType& stream, const perms value) noexcept;
} // namespace cxx
} // namespace iox

#include "iceoryx_hoofs/internal/cxx/filesystem.inl"
#include "iox/detail/filesystem.inl"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iox/filesystem.hpp"
#include "iceoryx_hoofs/log/logstream.hpp"
#include <iostream>

namespace iox
{
namespace cxx
{
template <typename StreamType>
static void outputToStream(StreamType& stream, const char* text, bool& hasPrecedingEntry)
{
Expand Down Expand Up @@ -167,5 +165,4 @@ StreamType& operator<<(StreamType& stream, const perms value) noexcept

template std::ostream& operator<<(std::ostream&, const perms) noexcept;
template log::LogStream& operator<<(log::LogStream&, const perms) noexcept;
} // namespace cxx
} // namespace iox
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#ifndef IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_HPP
#define IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_HPP

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp"
#include "iceoryx_platform/stat.hpp"
#include "iox/builder.hpp"
#include "iox/bump_allocator.hpp"
#include "iox/filesystem.hpp"
#include "iox/optional.hpp"

#include <cstdint>
Expand Down Expand Up @@ -138,7 +138,7 @@ class SharedMemoryObjectBuilder
IOX_BUILDER_PARAMETER(optional<const void*>, baseAddressHint, nullopt)

/// @brief Defines the access permissions of the shared memory
IOX_BUILDER_PARAMETER(cxx::perms, permissions, cxx::perms::none)
IOX_BUILDER_PARAMETER(perms, permissions, perms::none)

public:
expected<SharedMemoryObject, SharedMemoryObjectError> create() noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_SHARED_MEMORY_HPP
#define IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_SHARED_MEMORY_HPP

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iceoryx_hoofs/posix_wrapper/types.hpp"
#include "iox/builder.hpp"
#include "iox/expected.hpp"
#include "iox/filesystem.hpp"
#include "iox/optional.hpp"
#include "iox/string.hpp"

Expand Down Expand Up @@ -116,7 +116,7 @@ class SharedMemoryBuilder
IOX_BUILDER_PARAMETER(OpenMode, openMode, OpenMode::OPEN_EXISTING)

/// @brief Defines the access permissions of the shared memory
IOX_BUILDER_PARAMETER(cxx::perms, filePermissions, cxx::perms::none)
IOX_BUILDER_PARAMETER(perms, filePermissions, perms::none)

/// @brief Defines the size of the shared memory
IOX_BUILDER_PARAMETER(uint64_t, size, 0U)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#ifndef IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP
#define IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iceoryx_platform/file.hpp"
#include "iox/builder.hpp"
#include "iox/expected.hpp"
#include "iox/filesystem.hpp"
#include "iox/string.hpp"

namespace iox
Expand Down Expand Up @@ -121,7 +121,7 @@ class FileLockBuilder

/// @brief Defines the access permissions of the file lock. If they are not
/// explicitly set they will be none
IOX_BUILDER_PARAMETER(cxx::perms, permission, cxx::perms::none)
IOX_BUILDER_PARAMETER(perms, permission, perms::none)

public:
/// @brief Creates a file lock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#ifndef IOX_HOOFS_POSIX_WRAPPER_NAMED_SEMAPHORE_HPP
#define IOX_HOOFS_POSIX_WRAPPER_NAMED_SEMAPHORE_HPP

#include "iceoryx_hoofs/cxx/filesystem.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp"
#include "iceoryx_hoofs/posix_wrapper/types.hpp"
#include "iceoryx_platform/platform_settings.hpp"
#include "iox/builder.hpp"
#include "iox/expected.hpp"
#include "iox/filesystem.hpp"
#include "iox/optional.hpp"
#include "iox/string.hpp"

Expand Down Expand Up @@ -64,7 +64,7 @@ class NamedSemaphoreBuilder
IOX_BUILDER_PARAMETER(OpenMode, openMode, OpenMode::OPEN_EXISTING)

/// @brief Defines the access permissions of the semaphore
IOX_BUILDER_PARAMETER(cxx::perms, permissions, cxx::perms::owner_all)
IOX_BUILDER_PARAMETER(perms, permissions, perms::owner_all)

/// @brief Set the initial value of the unnamed posix semaphore. This value is only used when a new semaphore is
/// created.
Expand Down
32 changes: 32 additions & 0 deletions iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/filesystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2023 by Apex.AI Inc. 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.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_CXX_FILESYSTEM_HPP
#define IOX_HOOFS_CXX_FILESYSTEM_HPP

#include "iox/filesystem.hpp"

namespace iox
{
/// @todo iox-#1593 Deprecate include
/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/filesystem.hpp' instead")]]
namespace cxx
{
/// @deprecated use `iox::perms` instead of `iox::cxx::perms`
using iox::perms;
} // namespace cxx
} // namespace iox

#endif
6 changes: 3 additions & 3 deletions iceoryx_hoofs/source/posix_wrapper/file_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ constexpr const char FileLock::LOCK_FILE_SUFFIX[];

expected<FileLock, FileLockError> FileLockBuilder::create() noexcept
{
if (!cxx::isValidFileName(m_name))
if (!isValidFileName(m_name))
{
IOX_LOG(ERROR) << "Unable to create FileLock since the name \"" << m_name << "\" is not a valid file name.";
return error<FileLockError>(FileLockError::INVALID_FILE_NAME);
}

if (!cxx::isValidPathToDirectory(m_path))
if (!isValidPathToDirectory(m_path))
{
IOX_LOG(ERROR) << "Unable to create FileLock since the path \"" << m_path << "\" is not a valid path.";
return error<FileLockError>(FileLockError::INVALID_PATH);
}

FileLock::FilePath_t fileLockPath = m_path;

if (!cxx::doesEndWithPathSeparator(fileLockPath))
if (!doesEndWithPathSeparator(fileLockPath))
{
fileLockPath.unsafe_append(iox::platform::IOX_PATH_SEPARATORS[0]);
}
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/source/posix_wrapper/named_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ tryOpenExistingSemaphore(optional<NamedSemaphore>& uninitializedSemaphore, const
static expected<SemaphoreError> createSemaphore(optional<NamedSemaphore>& uninitializedSemaphore,
const NamedSemaphore::Name_t& name,
const OpenMode openMode,
const cxx::perms permissions,
const perms permissions,
const uint32_t initialValue) noexcept
{
auto result = posixCall(iox_sem_open_ext)(createNameWithSlash(name).c_str(),
Expand Down Expand Up @@ -157,7 +157,7 @@ expected<SemaphoreError>
// NOLINTNEXTLINE(readability-function-size,readability-function-cognitive-complexity)
NamedSemaphoreBuilder::create(optional<NamedSemaphore>& uninitializedSemaphore) const noexcept
{
if (!cxx::isValidFileName(m_name))
if (!isValidFileName(m_name))
{
IOX_LOG(ERROR) << "The name \"" << m_name << "\" is not a valid semaphore name.";
return error<SemaphoreError>(SemaphoreError::INVALID_NAME);
Expand Down
Loading

0 comments on commit b093d24

Please sign in to comment.