| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 399b340 commit a6c2213
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,13 +23,26 @@ concept StringConvertible = requires(T a) { | |||
| 23 | 23 | a.ToString() | |
| 24 | 24 | } -> std::convertible_to<std::string>; | |
| 25 | 25 | }; | |
| 26 | + // For std::filesystem::path and similar types | ||
| 27 | + template <typename T> | ||
| 28 | + concept StringConvertibleFSPathLike = requires(T a) { | ||
| 29 | + { | ||
| 30 | + a.string() | ||
| 31 | + } -> std::convertible_to<std::string>; | ||
| 32 | + }; | ||
| 26 | 33 | ||
| 27 | 34 | struct ToStringHelper { | |
| 28 | 35 | template <typename T> | |
| 29 | 36 | requires(StringConvertible<T>) && (!StringViewConvertible<T>) | |
| 30 | 37 | static std::string Convert(const T& value) { | |
| 31 | 38 | return value.ToString(); | |
| 32 | 39 | } | |
| 40 | + template <typename T> | ||
| 41 | + requires(StringConvertibleFSPathLike<T>) && (!StringViewConvertible<T>) && | ||
| 42 | + (!StringConvertible<T>) | ||
| 43 | + static std::string Convert(const T& value) { | ||
| 44 | + return value.string(); | ||
| 45 | + } | ||
| 33 | 46 | template <typename T> | |
| 34 | 47 | requires StringViewConvertible<T> | |
| 35 | 48 | static std::string_view Convert(const T& value) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3526,12 +3526,10 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) { | |||
| 3526 | 3526 | if (!dereference && | |
| 3527 | 3527 | std::filesystem::is_directory(symlink_target) && | |
| 3528 | 3528 | isInsideDir(symlink_target, current_dest_symlink_target)) { | |
| 3529 | - std::string message = | ||
| 3529 | + static constexpr const char* message = | ||
| 3530 | 3530 | "Cannot copy %s to a subdirectory of self %s"; | |
| 3531 | - THROW_ERR_FS_CP_EINVAL(env, | ||
| 3532 | - message.c_str(), | ||
| 3533 | - symlink_target.c_str(), | ||
| 3534 | - current_dest_symlink_target.c_str()); | ||
| 3531 | + THROW_ERR_FS_CP_EINVAL( | ||
| 3532 | + env, message, symlink_target, current_dest_symlink_target); | ||
| 3535 | 3533 | return false; | |
| 3536 | 3534 | } | |
| 3537 | 3535 | ||
@@ -3540,12 +3538,10 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) { | |||
| 3540 | 3538 | // and therefore a broken symlink would be created. | |
| 3541 | 3539 | if (std::filesystem::is_directory(dest_file_path) && | |
| 3542 | 3540 | isInsideDir(current_dest_symlink_target, symlink_target)) { | |
| 3543 | - std::string message = "cannot overwrite %s with %s"; | ||
| 3541 | + static constexpr const char* message = | ||
| 3542 | + "cannot overwrite %s with %s"; | ||
| 3544 | 3543 | THROW_ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY( | |
| 3545 | - env, | ||
| 3546 | - message.c_str(), | ||
| 3547 | - current_dest_symlink_target.c_str(), | ||
| 3548 | - symlink_target.c_str()); | ||
| 3544 | + env, message, current_dest_symlink_target, symlink_target); | ||
| 3549 | 3545 | return false; | |
| 3550 | 3546 | } | |
| 3551 | 3547 | ||
@@ -3597,7 +3593,7 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) { | |||
| 3597 | 3593 | THROW_ERR_FS_CP_EEXIST(isolate, | |
| 3598 | 3594 | "[ERR_FS_CP_EEXIST]: Target already exists: " | |
| 3599 | 3595 | "cp returned EEXIST (%s already exists)", | |
| 3600 | - dest_file_path.c_str()); | ||
| 3596 | + dest_file_path); | ||
| 3601 | 3597 | return false; | |
| 3602 | 3598 | } | |
| 3603 | 3599 | env->ThrowStdErrException(error, "cp", dest_str.c_str()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments