Skip to content

Commit

Permalink
Rvue xtd::io::path_too_long_exception exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Nov 1, 2024
1 parent cf3156d commit 54b0add
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/xtd.core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1111,16 +1111,17 @@ add_sources(
src/xtd/io/binary_writer.cpp
src/xtd/io/directory.cpp
src/xtd/io/directory_info.cpp
src/xtd/io/directory_not_found_exception.cpp
src/xtd/io/file.cpp
src/xtd/io/file_info.cpp
src/xtd/io/file_not_found_exception.cpp
src/xtd/io/file_system_info.cpp
src/xtd/io/directory_not_found_exception.cpp
src/xtd/io/drive_info.cpp
src/xtd/io/drive_not_found_exception.cpp
src/xtd/io/end_of_stream_exception.cpp
src/xtd/io/io_exception.cpp
src/xtd/io/path.cpp
src/xtd/io/path_too_long_exception.cpp
src/xtd/io/stream_reader.cpp
src/xtd/io/stream_writer.cpp
src/xtd/io/string_reader.cpp
Expand Down
67 changes: 44 additions & 23 deletions src/xtd.core/include/xtd/io/path_too_long_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,66 +32,87 @@ namespace xtd {
/// @name Public Constructors

/// @{
/// @brief Create a new instance of class path_too_long_exception
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @remarks Message is set with the default message associate to the exception.
explicit path_too_long_exception(const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(default_message(), stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
explicit path_too_long_exception(const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
explicit path_too_long_exception(const xtd::optional<xtd::string>& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
template<typename exception_t>
path_too_long_exception(const xtd::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, stack_frame) {error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));}

/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, error, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, help_link, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param help_link Help link string associate to the exception.
explicit path_too_long_exception(const xtd::string& message, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, error, help_link, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @remarks Message is set with the default message associate to the exception.
explicit path_too_long_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(default_message(), inner_exception, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param error Error code associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, error, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, help_link, stack_frame) {}
/// @brief Create a new instance of class path_too_long_exception
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::path_too_long_exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param error Error code associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, error, help_link, stack_frame) {}
/// @deprecated Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::path_too_long_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.")]]
explicit path_too_long_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame&stack_frame = null);
/// @}
/// @cond
path_too_long_exception(const path_too_long_exception&) = default;
path_too_long_exception& operator =(const path_too_long_exception&) = default;
/// @endcond

private:
const char* default_message() const noexcept {return "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."_t;}
};
}
}
49 changes: 49 additions & 0 deletions src/xtd.core/src/xtd/io/path_too_long_exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "../../../include/xtd/io/path_too_long_exception.h"

using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::io;

path_too_long_exception::path_too_long_exception(const stack_frame& stack_frame) : io_exception(stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
}

path_too_long_exception::path_too_long_exception(const optional<string>& message, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
}

path_too_long_exception::path_too_long_exception(const string& message, const std::error_code& error, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
}

path_too_long_exception::path_too_long_exception(const string& message, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
this->help_link(help_link);
}

path_too_long_exception::path_too_long_exception(const string& message, const std::error_code& error, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
this->help_link(help_link);
}

path_too_long_exception::path_too_long_exception(const std::exception& inner_exception, const stack_frame& stack_frame) : io_exception(stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
}

path_too_long_exception::path_too_long_exception(const string& message, const std::exception& inner_exception, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
}

path_too_long_exception::path_too_long_exception(const string& message, const std::exception& inner_exception, const std::error_code& error, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
}

path_too_long_exception::path_too_long_exception(const string& message, const std::exception& inner_exception, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_PATHTOOLONG));
this->help_link(help_link);
}

path_too_long_exception::path_too_long_exception(const string& message, const std::exception& inner_exception, const std::error_code& error, const string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
this->help_link(help_link);
}
Loading

0 comments on commit 54b0add

Please sign in to comment.