forked from eclipse-iceoryx/iceoryx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iox-eclipse-iceoryx#1942 Implement and test FilePath
Signed-off-by: Christian Eltzschig <[email protected]>
- Loading branch information
Showing
4 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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 | ||
|
||
#include "iox/file_path.hpp" | ||
#include "iox/filesystem.hpp" | ||
|
||
namespace iox | ||
{ | ||
namespace details | ||
{ | ||
bool file_path_does_contain_invalid_characters(const string<platform::IOX_MAX_PATH_LENGTH>& value) noexcept | ||
{ | ||
const auto valueSize = value.size(); | ||
|
||
for (uint64_t i{0}; i < valueSize; ++i) | ||
{ | ||
// AXIVION Next Construct AutosarC++19_03-A3.9.1: Not used as an integer but as actual character | ||
const char c{value[i]}; | ||
|
||
const bool isSmallLetter{'a' <= c && c <= 'z'}; | ||
const bool isCapitalLetter{'A' <= c && c <= 'Z'}; | ||
const bool isNumber{'0' <= c && c <= '9'}; | ||
const bool isSpecialCharacter{c == '-' || c == '.' || c == ':' || c == '_'}; | ||
const bool isPathSeparator{[&] { | ||
for (const auto separator : platform::IOX_PATH_SEPARATORS) | ||
{ | ||
if (c == separator) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
}()}; | ||
|
||
if ((!isSmallLetter && !isCapitalLetter) && (!isNumber && !isSpecialCharacter) && !isPathSeparator) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool file_path_does_contain_invalid_content(const string<platform::IOX_MAX_PATH_LENGTH>& value) noexcept | ||
{ | ||
return !isValidPathToFile(value); | ||
} | ||
} // namespace details | ||
} // namespace iox | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters