| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1289ef8 commit 764d356
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3147,24 +3147,25 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3147 | 3147 | if (!error_code) { | |
| 3148 | 3148 | // Check if src and dest are identical. | |
| 3149 | 3149 | if (std::filesystem::equivalent(src_path, dest_path)) { | |
| 3150 | - std::string message = "src and dest cannot be the same %s"; | ||
| 3151 | - return THROW_ERR_FS_CP_EINVAL(env, message.c_str(), dest_path_str); | ||
| 3150 | + static constexpr const char* message = | ||
| 3151 | + "src and dest cannot be the same %s"; | ||
| 3152 | + return THROW_ERR_FS_CP_EINVAL(env, message, dest_path_str); | ||
| 3152 | 3153 | } | |
| 3153 | 3154 | ||
| 3154 | 3155 | const bool dest_is_dir = | |
| 3155 | 3156 | dest_status.type() == std::filesystem::file_type::directory; | |
| 3156 | 3157 | if (src_is_dir && !dest_is_dir) { | |
| 3157 | - std::string message = | ||
| 3158 | + static constexpr const char* message = | ||
| 3158 | 3159 | "Cannot overwrite non-directory %s with directory %s"; | |
| 3159 | 3160 | return THROW_ERR_FS_CP_DIR_TO_NON_DIR( | |
| 3160 | - env, message.c_str(), dest_path_str, src_path_str); | ||
| 3161 | + env, message, dest_path_str, src_path_str); | ||
| 3161 | 3162 | } | |
| 3162 | 3163 | ||
| 3163 | 3164 | if (!src_is_dir && dest_is_dir) { | |
| 3164 | - std::string message = | ||
| 3165 | + static constexpr const char* message = | ||
| 3165 | 3166 | "Cannot overwrite directory %s with non-directory %s"; | |
| 3166 | 3167 | return THROW_ERR_FS_CP_NON_DIR_TO_DIR( | |
| 3167 | - env, message.c_str(), dest_path_str, src_path_str); | ||
| 3168 | + env, message, dest_path_str, src_path_str); | ||
| 3168 | 3169 | } | |
| 3169 | 3170 | } | |
| 3170 | 3171 | ||
@@ -3173,9 +3174,9 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3173 | 3174 | } | |
| 3174 | 3175 | // Check if dest_path is a subdirectory of src_path. | |
| 3175 | 3176 | if (src_is_dir && dest_path_str.starts_with(src_path_str)) { | |
| 3176 | - std::string message = "Cannot copy %s to a subdirectory of self %s"; | ||
| 3177 | - return THROW_ERR_FS_CP_EINVAL( | ||
| 3178 | - env, message.c_str(), src_path_str, dest_path_str); | ||
| 3177 | + static constexpr const char* message = | ||
| 3178 | + "Cannot copy %s to a subdirectory of self %s"; | ||
| 3179 | + return THROW_ERR_FS_CP_EINVAL(env, message, src_path_str, dest_path_str); | ||
| 3179 | 3180 | } | |
| 3180 | 3181 | ||
| 3181 | 3182 | auto dest_parent = dest_path.parent_path(); | |
@@ -3186,9 +3187,9 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3186 | 3187 | dest_parent.parent_path() != dest_parent) { | |
| 3187 | 3188 | if (std::filesystem::equivalent( | |
| 3188 | 3189 | src_path, dest_path.parent_path(), error_code)) { | |
| 3189 | - std::string message = "Cannot copy %s to a subdirectory of self %s"; | ||
| 3190 | - return THROW_ERR_FS_CP_EINVAL( | ||
| 3191 | - env, message.c_str(), src_path_str, dest_path_str); | ||
| 3190 | + static constexpr const char* message = | ||
| 3191 | + "Cannot copy %s to a subdirectory of self %s"; | ||
| 3192 | + return THROW_ERR_FS_CP_EINVAL(env, message, src_path_str, dest_path_str); | ||
| 3192 | 3193 | } | |
| 3193 | 3194 | ||
| 3194 | 3195 | // If equivalent fails, it's highly likely that dest_parent does not exist | |
@@ -3200,23 +3201,24 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3200 | 3201 | } | |
| 3201 | 3202 | ||
| 3202 | 3203 | if (src_is_dir && !recursive) { | |
| 3203 | - std::string message = | ||
| 3204 | + static constexpr const char* message = | ||
| 3204 | 3205 | "Recursive option not enabled, cannot copy a directory: %s"; | |
| 3205 | - return THROW_ERR_FS_EISDIR(env, message.c_str(), src_path_str); | ||
| 3206 | + return THROW_ERR_FS_EISDIR(env, message, src_path_str); | ||
| 3206 | 3207 | } | |
| 3207 | 3208 | ||
| 3208 | 3209 | switch (src_status.type()) { | |
| 3209 | 3210 | case std::filesystem::file_type::socket: { | |
| 3210 | - std::string message = "Cannot copy a socket file: %s"; | ||
| 3211 | - return THROW_ERR_FS_CP_SOCKET(env, message.c_str(), dest_path_str); | ||
| 3211 | + static constexpr const char* message = "Cannot copy a socket file: %s"; | ||
| 3212 | + return THROW_ERR_FS_CP_SOCKET(env, message, dest_path_str); | ||
| 3212 | 3213 | } | |
| 3213 | 3214 | case std::filesystem::file_type::fifo: { | |
| 3214 | - std::string message = "Cannot copy a FIFO pipe: %s"; | ||
| 3215 | - return THROW_ERR_FS_CP_FIFO_PIPE(env, message.c_str(), dest_path_str); | ||
| 3215 | + static constexpr const char* message = "Cannot copy a FIFO pipe: %s"; | ||
| 3216 | + return THROW_ERR_FS_CP_FIFO_PIPE(env, message, dest_path_str); | ||
| 3216 | 3217 | } | |
| 3217 | 3218 | case std::filesystem::file_type::unknown: { | |
| 3218 | - std::string message = "Cannot copy an unknown file type: %s"; | ||
| 3219 | - return THROW_ERR_FS_CP_UNKNOWN(env, message.c_str(), dest_path_str); | ||
| 3219 | + static constexpr const char* message = | ||
| 3220 | + "Cannot copy an unknown file type: %s"; | ||
| 3221 | + return THROW_ERR_FS_CP_UNKNOWN(env, message, dest_path_str); | ||
| 3220 | 3222 | } | |
| 3221 | 3223 | default: | |
| 3222 | 3224 | break; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments