{"id":2100,"date":"2025-03-24T08:48:18","date_gmt":"2025-03-23T23:48:18","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2100"},"modified":"2025-03-24T08:48:45","modified_gmt":"2025-03-23T23:48:45","slug":"c-filesystem%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a-%e5%8a%b9%e7%8e%87%e7%9a%84%e3%81%aa%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e6%93%8d","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2100","title":{"rendered":"C++ filesystem\u30e9\u30a4\u30d6\u30e9\u30ea\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a \u52b9\u7387\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3092\u5b9f\u73fe\u3059\u308b7\u3064\u306e\u5b9f\u88c5\u4f8b"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <span><\/span>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-0\">filesystem\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e3b\u8981\u6a5f\u80fd\u3068\u5b9f\u88c5\u4f8b<\/a>      <\/li>      <li>        <a href=\"#i-4\">\u5b9f\u8df5\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u30c6\u30af\u30cb\u30c3\u30af\u6d3b\u7528<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u958b\u767a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-9\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3068\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-11\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-13\">\u4eca\u5f8c\u306e\u5c55\u958b\u3068\u6280\u8853\u95a2\u9023<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-15\">include<\/a>  <\/li>  <li>    <a href=\"#i-16\">include<\/a>  <\/li>  <li>    <a href=\"#i-17\">include<\/a>  <\/li>  <li>    <a href=\"#i-18\">include<\/a>  <\/li>  <li class=\"last\">    <a href=\"#i-19\">include<\/a>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">filesystem\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e3b\u8981\u6a5f\u80fd\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<p>C++17\u3067\u5c0e\u5165\u3055\u308c\u305f<code>std::filesystem<\/code>\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b89\u5168\u304b\u3064\u52b9\u7387\u7684\u306b\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306e\u5305\u62ec\u7684\u306a\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u672c\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u4e3b\u8981\u306a\u6a5f\u80fd\u3068\u305d\u306e\u5b9f\u88c5\u4f8b\u3092\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u30d1\u30b9\u306e\u64cd\u4f5c\u3068\u6b63\u898f\u5316\u3067\u5b9f\u73fe\u3059\u308b\u78ba\u5b9f\u306a\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30d1\u30b9\u64cd\u4f5c\u306f<code>std::filesystem<\/code>\u306e\u57fa\u790e\u3068\u306a\u308b\u6a5f\u80fd\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u30d1\u30b9\u64cd\u4f5c\u306e\u4e3b\u8981\u6a5f\u80fd\u3068\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\nnamespace fs = std::filesystem;\n\nvoid path_operations_example() {\n    \/\/ \u30d1\u30b9\u306e\u69cb\u7bc9\u3068\u9023\u7d50\n    fs::path base_path = \"\/home\/user\";\n    fs::path file_path = base_path \/ \"documents\" \/ \"report.txt\";\n\n    \/\/ \u30d1\u30b9\u306e\u5404\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3078\u306e\u30a2\u30af\u30bb\u30b9\n    std::cout &lt;&lt; \"Root name: \" &lt;&lt; file_path.root_name() &lt;&lt; '\\n'\n              &lt;&lt; \"Root directory: \" &lt;&lt; file_path.root_directory() &lt;&lt; '\\n'\n              &lt;&lt; \"Root path: \" &lt;&lt; file_path.root_path() &lt;&lt; '\\n'\n              &lt;&lt; \"Relative path: \" &lt;&lt; file_path.relative_path() &lt;&lt; '\\n'\n              &lt;&lt; \"Parent path: \" &lt;&lt; file_path.parent_path() &lt;&lt; '\\n'\n              &lt;&lt; \"Filename: \" &lt;&lt; file_path.filename() &lt;&lt; '\\n'\n              &lt;&lt; \"Stem: \" &lt;&lt; file_path.stem() &lt;&lt; '\\n'\n              &lt;&lt; \"Extension: \" &lt;&lt; file_path.extension() &lt;&lt; '\\n';\n\n    \/\/ \u30d1\u30b9\u306e\u6b63\u898f\u5316\uff08\u91cd\u8907\u3084\u76f8\u5bfe\u30d1\u30b9\u306e\u89e3\u6c7a\uff09\n    fs::path redundant_path = \"home\/.\/user\/..\/user\/docs\/..\/documents\/.\/report.txt\";\n    fs::path normalized_path = redundant_path.lexically_normal();\n    std::cout &lt;&lt; \"Normalized path: \" &lt;&lt; normalized_path &lt;&lt; '\\n';\n\n    \/\/ \u30d1\u30b9\u306e\u6bd4\u8f03\u3068\u691c\u8a3c\n    if (fs::equivalent(file_path, normalized_path)) {\n        std::cout &lt;&lt; \"Paths refer to the same location\\n\";\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u4f8b\u3067\u306f\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u6a5f\u80fd\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30b9\u306e\u69cb\u7bc9\u3068\u9023\u7d50<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30aa\u30da\u30ec\u30fc\u30bf<code>\/<\/code>\u3092\u4f7f\u7528\u3057\u305f\u76f4\u611f\u7684\u306a\u30d1\u30b9\u9023\u7d50<\/li>\n\n\n\n<li>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u72ec\u7acb\u306e\u30d1\u30b9\u533a\u5207\u308a\u6587\u5b57\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30b9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3078\u306e\u30a2\u30af\u30bb\u30b9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30eb\u30fc\u30c8\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306a\u3069\u306e\u500b\u5225\u53d6\u5f97<\/li>\n\n\n\n<li>\u30d1\u30b9\u8981\u7d20\u306e\u8a73\u7d30\u306a\u89e3\u6790\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30b9\u306e\u6b63\u898f\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5197\u9577\u306a\u30d1\u30b9\u8868\u73fe\u306e\u7c21\u7565\u5316<\/li>\n\n\n\n<li>\u76f8\u5bfe\u30d1\u30b9\u53c2\u7167\u306e\u89e3\u6c7a<\/li>\n\n\n\n<li>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u9593\u306e\u4e92\u63db\u6027\u78ba\u4fdd<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8d70\u67fb\u3067\u5b9f\u73fe\u3059\u308b\u52b9\u7387\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u51e6\u7406<\/h3>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\n\/\/ \u7279\u5b9a\u306e\u62e1\u5f35\u5b50\u3092\u6301\u3064\u30d5\u30a1\u30a4\u30eb\u306e\u691c\u7d22\nstd::vector&lt;fs::path&gt; find_files_by_extension(\n    const fs::path&amp; dir_path,\n    const std::string&amp; extension\n) {\n    std::vector&lt;fs::path&gt; matching_files;\n\n    \/\/ \u4f8b\u5916\u51e6\u7406\u3092\u542b\u3080\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8d70\u67fb\n    try {\n        for (const auto&amp; entry : fs::directory_iterator(dir_path)) {\n            if (entry.is_regular_file() &amp;&amp; entry.path().extension() == extension) {\n                matching_files.push_back(entry.path());\n\n                \/\/ \u30d5\u30a1\u30a4\u30eb\u60c5\u5831\u306e\u53d6\u5f97\u4f8b\n                auto file_size = entry.file_size();\n                auto last_write_time = entry.last_write_time();\n\n                std::cout &lt;&lt; \"Found file: \" &lt;&lt; entry.path() &lt;&lt; '\\n'\n                         &lt;&lt; \"Size: \" &lt;&lt; file_size &lt;&lt; \" bytes\\n\";\n            }\n        }\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Filesystem error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n    }\n\n    return matching_files;\n}\n\n\/\/ \u518d\u5e30\u7684\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8d70\u67fb\u306e\u5b9f\u88c5\nvoid recursive_directory_scan(const fs::path&amp; dir_path) {\n    try {\n        \/\/ \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u305f\u518d\u5e30\u7684\u8d70\u67fb\n        fs::recursive_directory_iterator dir_iter(\n            dir_path,\n            fs::directory_options::skip_permission_denied |\n            fs::directory_options::follow_directory_symlink\n        );\n\n        for (const auto&amp; entry : dir_iter) {\n            \/\/ \u73fe\u5728\u306e\u6df1\u3055\u306e\u53d6\u5f97\n            std::cout &lt;&lt; \"Depth: \" &lt;&lt; dir_iter.depth() &lt;&lt; \", \";\n\n            if (entry.is_regular_file()) {\n                std::cout &lt;&lt; \"File: \" &lt;&lt; entry.path() &lt;&lt; '\\n';\n            } else if (entry.is_directory()) {\n                std::cout &lt;&lt; \"Directory: \" &lt;&lt; entry.path() &lt;&lt; '\\n';\n\n                \/\/ \u7279\u5b9a\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u30b9\u30ad\u30c3\u30d7\u3059\u308b\u4f8b\n                if (entry.path().filename() == \"temp\") {\n                    dir_iter.disable_recursion_pending();\n                }\n            }\n        }\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Error during directory scan: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u6a5f\u80fd\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5358\u4e00\u968e\u5c64\u306e\u8d70\u67fb<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>directory_iterator<\/code>\u3092\u4f7f\u7528\u3057\u305f\u52b9\u7387\u7684\u306a\u8d70\u67fb<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30eb\u60c5\u5831\u306e\u53d6\u5f97\u3068\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u518d\u5e30\u7684\u306a\u8d70\u67fb<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>recursive_directory_iterator<\/code>\u306b\u3088\u308b\u6df1\u3044\u968e\u5c64\u306e\u8d70\u67fb<\/li>\n\n\n\n<li>\u8d70\u67fb\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u5236\u5fa1<\/li>\n\n\n\n<li>\u7279\u5b9a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30b9\u30ad\u30c3\u30d7\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u30d5\u30a1\u30a4\u30eb\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u4f8b\u5916\u51e6\u7406\u3067\u5b9f\u73fe\u3059\u308b\u5b89\u5168\u306a\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3067\u306f\u3001\u9069\u5207\u306a\u4f8b\u5916\u51e6\u7406\u304c\u91cd\u8981\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class FileOperationManager {\npublic:\n    \/\/ \u5b89\u5168\u306a\u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc\u64cd\u4f5c\u306e\u5b9f\u88c5\n    static bool safe_copy_file(\n        const fs::path&amp; source,\n        const fs::path&amp; destination\n    ) {\n        try {\n            \/\/ \u30b3\u30d4\u30fc\u5148\u306e\u5b58\u5728\u78ba\u8a8d\u3068\u51e6\u7406\n            if (fs::exists(destination)) {\n                \/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u4f5c\u6210\n                auto backup_path = destination.string() + \".bak\";\n                fs::rename(destination, backup_path);\n            }\n\n            \/\/ \u30b3\u30d4\u30fc\u64cd\u4f5c\u306e\u5b9f\u884c\n            fs::copy_file(\n                source,\n                destination,\n                fs::copy_options::overwrite_existing\n            );\n            return true;\n\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Filesystem error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return false;\n        }\n    }\n\n    \/\/ \u539f\u5b50\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u66f4\u65b0\u306e\u5b9f\u88c5\n    static bool atomic_file_update(\n        const fs::path&amp; target_path,\n        const std::string&amp; new_content\n    ) {\n        auto temp_path = target_path.string() + \".tmp\";\n\n        try {\n            \/\/ \u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u66f8\u304d\u8fbc\u307f\n            {\n                std::ofstream temp_file(temp_path);\n                if (!temp_file) {\n                    throw std::runtime_error(\"Failed to create temporary file\");\n                }\n                temp_file &lt;&lt; new_content;\n            }\n\n            \/\/ \u539f\u5b50\u7684\u306a\u7f6e\u304d\u63db\u3048\n            fs::rename(temp_path, target_path);\n            return true;\n\n        } catch (const std::exception&amp; e) {\n            \/\/ \u30a8\u30e9\u30fc\u6642\u306e\u5f8c\u51e6\u7406\n            if (fs::exists(temp_path)) {\n                fs::remove(temp_path);\n            }\n            std::cerr &lt;&lt; \"Error during atomic update: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return false;\n        }\n    }\n};<\/pre>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u4f8b\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4f8b\u5916\u51e6\u7406\u306e\u4f53\u7cfb\u7684\u306a\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u4f8b\u5916\u578b\u306e\u4f7f\u7528<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u72b6\u614b\u304b\u3089\u306e\u56de\u5fa9\u51e6\u7406<\/li>\n\n\n\n<li>\u8a73\u7d30\u306a\u30a8\u30e9\u30fc\u60c5\u5831\u306e\u63d0\u4f9b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b89\u5168\u306a\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u4f5c\u6210\u306b\u3088\u308b\u5b89\u5168\u6027\u78ba\u4fdd<\/li>\n\n\n\n<li>\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3057\u305f\u539f\u5b50\u7684\u306a\u66f4\u65b0<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u306e\u9069\u5207\u306a\u89e3\u653e<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-4\">\u5b9f\u8df5\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u30c6\u30af\u30cb\u30c3\u30af\u6d3b\u7528<\/h2>\n\n\n\n<p>\u9ad8\u5ea6\u306a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306e\u5b9f\u8df5\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u518d\u5e30\u7684\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u5b9f\u73fe\u3059\u308b\u9ad8\u5ea6\u306a\u51e6\u7406<\/h3>\n\n\n\n<p>\u518d\u5e30\u7684\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u64cd\u4f5c\u306f\u3001\u8907\u96d1\u306a\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u30bf\u30b9\u30af\u306e\u57fa\u790e\u3068\u306a\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;functional&gt;\n#include &lt;unordered_map&gt;\n#include &lt;vector&gt;\n\nnamespace fs = std::filesystem;\n\nclass DirectoryProcessor {\npublic:\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30c4\u30ea\u30fc\u306e\u51e6\u7406\u7528\u95a2\u6570\u578b\u306e\u5b9a\u7fa9\n    using FileHandler = std::function&lt;void(const fs::path&amp;)&gt;;\n    using DirPreHandler = std::function&lt;bool(const fs::path&amp;)&gt;;\n    using DirPostHandler = std::function&lt;void(const fs::path&amp;)&gt;;\n\n    \/\/ \u51e6\u7406\u30cf\u30f3\u30c9\u30e9\u306e\u767b\u9332\n    void set_file_handler(FileHandler handler) { file_handler = handler; }\n    void set_dir_pre_handler(DirPreHandler handler) { dir_pre_handler = handler; }\n    void set_dir_post_handler(DirPostHandler handler) { dir_post_handler = handler; }\n\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30c4\u30ea\u30fc\u306e\u51e6\u7406\u5b9f\u884c\n    void process_directory(const fs::path&amp; root_path) {\n        try {\n            process_directory_internal(root_path);\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Error processing directory: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        }\n    }\n\nprivate:\n    FileHandler file_handler;\n    DirPreHandler dir_pre_handler;\n    DirPostHandler dir_post_handler;\n\n    void process_directory_internal(const fs::path&amp; dir_path) {\n        \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u524d\u51e6\u7406\n        if (dir_pre_handler &amp;&amp; !dir_pre_handler(dir_path)) {\n            return; \/\/ \u30b9\u30ad\u30c3\u30d7\u5224\u5b9a\n        }\n\n        for (const auto&amp; entry : fs::directory_iterator(dir_path)) {\n            if (entry.is_regular_file() &amp;&amp; file_handler) {\n                file_handler(entry.path());\n            } else if (entry.is_directory()) {\n                process_directory_internal(entry.path());\n            }\n        }\n\n        \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5f8c\u51e6\u7406\n        if (dir_post_handler) {\n            dir_post_handler(dir_path);\n        }\n    }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\uff1a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30b5\u30a4\u30ba\u306e\u8a08\u7b97\nvoid calculate_directory_sizes() {\n    std::unordered_map&lt;fs::path, uintmax_t&gt; dir_sizes;\n    DirectoryProcessor processor;\n\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u30cf\u30f3\u30c9\u30e9\n    processor.set_file_handler([&amp;](const fs::path&amp; path) {\n        auto size = fs::file_size(path);\n        auto parent = path.parent_path();\n        while (!parent.empty()) {\n            dir_sizes[parent] += size;\n            parent = parent.parent_path();\n        }\n    });\n\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4e8b\u524d\u51e6\u7406\u30cf\u30f3\u30c9\u30e9\n    processor.set_dir_pre_handler([](const fs::path&amp; path) {\n        std::cout &lt;&lt; \"Processing directory: \" &lt;&lt; path &lt;&lt; '\\n';\n        return true; \/\/ \u51e6\u7406\u7d9a\u884c\n    });\n\n    \/\/ \u5b9f\u884c\n    processor.process_directory(\".\/target_dir\");\n\n    \/\/ \u7d50\u679c\u51fa\u529b\n    for (const auto&amp; [path, size] : dir_sizes) {\n        std::cout &lt;&lt; path &lt;&lt; \": \" &lt;&lt; size &lt;&lt; \" bytes\\n\";\n    }\n}\n\n### \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u5236\u5fa1\u3067\u5b9f\u73fe\u3059\u308b\u30bb\u30ad\u30e5\u30a2\u306a\u5b9f\u88c5\n\n\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u5236\u5fa1\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\uff1a<\/pre>\n\n\n\n<p>cpp<br>class SecurityManager {<br>public:<br>\/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306e\u691c\u8a3c\u3068\u8a2d\u5b9a<br>static bool secure_directory(const fs::path&amp; dir_path) {<br>try {<br>\/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5b58\u5728\u78ba\u8a8d\u3068\u4f5c\u6210<br>if (!fs::exists(dir_path)) {<br>fs::create_directories(dir_path);<br>}<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        \/\/ \u73fe\u5728\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306e\u53d6\u5f97\n        auto perms = fs::status(dir_path).permissions();\n\n        \/\/ \u6240\u6709\u8005\u306e\u307f\u8aad\u307f\u66f8\u304d\u53ef\u80fd\u306b\u8a2d\u5b9a\n        fs::permissions(dir_path, \n            fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec,\n            fs::perm_options::replace);\n\n        return true;\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Security error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        return false;\n    }\n}\n\n\/\/ \u30bb\u30ad\u30e5\u30a2\u306a\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\nstatic bool create_secure_file(\n    const fs::path&amp; file_path,\n    const std::string&amp; content\n) {\n    try {\n        \/\/ \u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u751f\u6210\n        auto temp_path = file_path.string() + \".tmp\";\n\n        {\n            \/\/ \u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\u3068\u66f8\u304d\u8fbc\u307f\n            std::ofstream file(temp_path);\n            if (!file) {\n                throw std::runtime_error(\"Failed to create file\");\n            }\n            file &lt;&lt; content;\n        }\n\n        \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u8a2d\u5b9a\n        fs::permissions(temp_path,\n            fs::perms::owner_read | fs::perms::owner_write,\n            fs::perm_options::replace);\n\n        \/\/ \u672c\u6765\u306e\u30d1\u30b9\u3078\u306e\u79fb\u52d5\n        fs::rename(temp_path, file_path);\n        return true;\n\n    } catch (const std::exception&amp; e) {\n        std::cerr &lt;&lt; \"Error creating secure file: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        return false;\n    }\n}<\/pre>\n\n\n\n<p>};<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u30d5\u30a1\u30a4\u30eb\u76e3\u8996\u6a5f\u80fd\u3067\u5b9f\u73fe\u3059\u308b\u77ac\u9593\u51e6\u7406<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u5909\u66f4\u3092\u76e3\u8996\u3057\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u51e6\u7406\u3092\u884c\u3046\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class FileWatcher {\nprivate:\n    fs::path watch_path;\n    std::chrono::seconds poll_interval;\n    std::unordered_map&lt;fs::path, fs::file_time_type&gt; file_times;\n    bool running = false;\n\npublic:\n    FileWatcher(const fs::path&amp; path, std::chrono::seconds interval = std::chrono::seconds(1))\n        : watch_path(path), poll_interval(interval) {}\n\n    \/\/ \u76e3\u8996\u306e\u958b\u59cb\n    void start(const std::function&lt;void(const fs::path&amp;, const std::string&amp;)&gt;&amp; action) {\n        running = true;\n\n        \/\/ \u521d\u671f\u72b6\u614b\u306e\u8a18\u9332\n        for (const auto&amp; entry : fs::recursive_directory_iterator(watch_path)) {\n            if (entry.is_regular_file()) {\n                file_times[entry.path()] = fs::last_write_time(entry.path());\n            }\n        }\n\n        \/\/ \u76e3\u8996\u30eb\u30fc\u30d7\n        while (running) {\n            std::this_thread::sleep_for(poll_interval);\n            auto it = file_times.begin();\n\n            while (it != file_times.end()) {\n                if (!fs::exists(it-&gt;first)) {\n                    action(it-&gt;first, \"deleted\");\n                    it = file_times.erase(it);\n                } else {\n                    auto current_time = fs::last_write_time(it-&gt;first);\n                    if (current_time != it-&gt;second) {\n                        action(it-&gt;first, \"modified\");\n                        it-&gt;second = current_time;\n                    }\n                    ++it;\n                }\n            }\n\n            \/\/ \u65b0\u898f\u30d5\u30a1\u30a4\u30eb\u306e\u30c1\u30a7\u30c3\u30af\n            for (const auto&amp; entry : fs::recursive_directory_iterator(watch_path)) {\n                if (entry.is_regular_file()) {\n                    auto path = entry.path();\n                    if (file_times.find(path) == file_times.end()) {\n                        action(path, \"created\");\n                        file_times[path] = fs::last_write_time(path);\n                    }\n                }\n            }\n        }\n    }\n\n    \/\/ \u76e3\u8996\u306e\u505c\u6b62\n    void stop() { running = false; }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nvoid monitor_directory() {\n    FileWatcher watcher(\".\/watched_directory\");\n\n    auto handler = [](const fs::path&amp; path, const std::string&amp; event_type) {\n        std::cout &lt;&lt; \"File \" &lt;&lt; path &lt;&lt; \" was \" &lt;&lt; event_type &lt;&lt; '\\n';\n        \/\/ \u3053\u3053\u3067\u5fc5\u8981\u306a\u51e6\u7406\u3092\u5b9f\u884c\n    };\n\n    \/\/ \u5225\u30b9\u30ec\u30c3\u30c9\u3067\u76e3\u8996\u3092\u958b\u59cb\n    std::thread watcher_thread([&amp;]() {\n        watcher.start(handler);\n    });\n\n    \/\/ \u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3067\u306e\u5236\u5fa1\n    std::this_thread::sleep_for(std::chrono::minutes(5));\n    watcher.stop();\n    watcher_thread.join();\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u518d\u5e30\u7684\u51e6\u7406\u306e\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u6d3b\u7528\u3057\u305f\u67d4\u8edf\u306a\u51e6\u7406<\/li>\n\n\n\n<li>\u968e\u5c64\u69cb\u9020\u306e\u52b9\u7387\u7684\u306a\u8d70\u67fb<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u4e00\u5143\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8003\u616e\u4e8b\u9805<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u30a2\u30c8\u30df\u30c3\u30af\u306a\u64cd\u4f5c\u306e\u5b9f\u73fe<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u76e3\u8996\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52b9\u7387\u7684\u306a\u30dd\u30fc\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u30a4\u30d9\u30f3\u30c8\u30d9\u30fc\u30b9\u306e\u51e6\u7406<\/li>\n\n\n\n<li>\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u306a\u5b9f\u88c5<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5805\u7262\u3067\u52b9\u7387\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u958b\u767a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n\n\n\n<p>C++\u306efilesystem\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u305f\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u958b\u767a\u3067\u306f\u3001OS\u306e\u9055\u3044\u3092\u9069\u5207\u306b\u5438\u53ce\u3059\u308b\u5b9f\u88c5\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">Windows\/Linux\u9593\u306e\u4e92\u63db\u6027\u3092\u78ba\u4fdd\u3059\u308b\u5b9f\u88c5\u624b\u6cd5<\/h3>\n\n\n\n<p>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u9593\u306e\u9055\u3044\u3092\u5438\u53ce\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;string&gt;\n#include &lt;system_error&gt;\n\nnamespace fs = std::filesystem;\n\nclass CrossPlatformFileManager {\npublic:\n    \/\/ \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u5171\u901a\u306e\u30d1\u30b9\u64cd\u4f5c\n    static fs::path get_absolute_path(const fs::path&amp; path) {\n        try {\n            return fs::absolute(path).lexically_normal();\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Error normalizing path: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return path;\n        }\n    }\n\n    \/\/ \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u56fa\u6709\u306e\u51e6\u7406\u306e\u62bd\u8c61\u5316\n    static bool create_directory_with_permissions(const fs::path&amp; dir_path) {\n        try {\n            if (!fs::exists(dir_path)) {\n                fs::create_directories(dir_path);\n            }\n\n            #ifdef _WIN32\n                \/\/ Windows\u56fa\u6709\u306e\u51e6\u7406\n                return set_windows_permissions(dir_path);\n            #else\n                \/\/ UNIX\u7cfb\u306e\u51e6\u7406\n                return set_unix_permissions(dir_path);\n            #endif\n\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Error creating directory: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return false;\n        }\n    }\n\nprivate:\n    #ifdef _WIN32\n    static bool set_windows_permissions(const fs::path&amp; path) {\n        try {\n            \/\/ Windows\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a18\u8ff0\u5b50\u3092\u8a2d\u5b9a\n            fs::permissions(path,\n                fs::perms::owner_all |\n                fs::perms::group_read |\n                fs::perms::others_read,\n                fs::perm_options::replace);\n            return true;\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Error setting Windows permissions: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return false;\n        }\n    }\n    #else\n    static bool set_unix_permissions(const fs::path&amp; path) {\n        try {\n            \/\/ UNIX\u7cfb\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u8a2d\u5b9a\n            fs::permissions(path,\n                fs::perms::owner_all |\n                fs::perms::group_read | fs::perms::group_exec |\n                fs::perms::others_read | fs::perms::others_exec,\n                fs::perm_options::replace);\n            return true;\n        } catch (const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Error setting Unix permissions: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            return false;\n        }\n    }\n    #endif\n};\n\n### \u30d1\u30b9\u533a\u5207\u308a\u6587\u5b57\u306e\u9055\u3044\u3092\u5438\u53ce\u3059\u308b\u5b9f\u88c5\u624b\u6cd5\n\n\u7570\u306a\u308bOS\u306e\u30d1\u30b9\u8868\u73fe\u3092\u9069\u5207\u306b\u51e6\u7406\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/pre>\n\n\n\n<p>cpp<br>class PathNormalizer {<br>public:<br>\/\/ \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u975e\u4f9d\u5b58\u306e\u30d1\u30b9\u751f\u6210<br>static fs::path create_platform_path(const std::vector&amp; components) {<br>fs::path result;<br>for (const auto&amp; component : components) {<br>result \/= component; \/\/ operator\/\u3092\u4f7f\u7528\u3057\u3066\u81ea\u52d5\u7684\u306b\u9069\u5207\u306a\u533a\u5207\u308a\u6587\u5b57\u3092\u4f7f\u7528<br>}<br>return result;<br>}<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30d1\u30b9\u306e\u6b63\u898f\u5316\u3068\u691c\u8a3c\nstatic fs::path normalize_path(const fs::path&amp; input_path) {\n    try {\n        \/\/ \u7d76\u5bfe\u30d1\u30b9\u3078\u306e\u5909\u63db\u3068\u6b63\u898f\u5316\n        auto abs_path = fs::absolute(input_path);\n        auto norm_path = abs_path.lexically_normal();\n\n        \/\/ \u30d1\u30b9\u306e\u5b58\u5728\u78ba\u8a8d\n        if (fs::exists(norm_path)) {\n            return norm_path;\n        }\n\n        throw fs::filesystem_error(\n            \"Path does not exist\",\n            norm_path,\n            std::make_error_code(std::errc::no_such_file_or_directory)\n        );\n\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Path normalization error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        throw;  \/\/ \u30a8\u30e9\u30fc\u306e\u518d\u30b9\u30ed\u30fc\n    }\n}\n\n\/\/ \u30ea\u30e2\u30fc\u30c8\u30d1\u30b9\u306e\u51e6\u7406\nstatic bool is_network_path(const fs::path&amp; path) {\n    auto root = path.root_name().string();\n\n    #ifdef _WIN32\n        \/\/ Windows\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30d1\u30b9 (UNC) \u306e\u691c\u51fa\n        return root.starts_with(\"\\\\\\\\\") || root.starts_with(\"\/\/\");\n    #else\n        \/\/ UNIX\u306e\u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u3084NFS\u30d1\u30b9\u306e\u691c\u51fa\n        return root.starts_with(\"\/\/\") || root.starts_with(\"\/mnt\/\");\n    #endif\n}\n\n\/\/ \u76f8\u5bfe\u30d1\u30b9\u306e\u89e3\u6c7a\nstatic fs::path resolve_relative_path(\n    const fs::path&amp; base_path,\n    const fs::path&amp; relative_path\n) {\n    try {\n        \/\/ \u30d9\u30fc\u30b9\u30d1\u30b9\u306e\u6b63\u898f\u5316\n        auto norm_base = fs::absolute(base_path).lexically_normal();\n\n        \/\/ \u76f8\u5bfe\u30d1\u30b9\u306e\u7d50\u5408\u3068\u6b63\u898f\u5316\n        auto resolved = (norm_base \/ relative_path).lexically_normal();\n\n        \/\/ \u30d9\u30fc\u30b9\u30d1\u30b9\u304b\u3089\u306e\u9038\u8131\u30c1\u30a7\u30c3\u30af\n        auto relative = fs::relative(resolved, norm_base);\n        if (relative.string().find(\"..\") != std::string::npos) {\n            throw fs::filesystem_error(\n                \"Path traversal detected\",\n                resolved,\n                std::make_error_code(std::errc::invalid_argument)\n            );\n        }\n\n        return resolved;\n\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Path resolution error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        throw;\n    }\n}<\/pre>\n\n\n\n<p>};<\/p>\n\n\n\n<p>\/\/ \u4f7f\u7528\u4f8b<br>void demonstrate_cross_platform_paths() {<br>try {<br>\/\/ \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u975e\u4f9d\u5b58\u306e\u30d1\u30b9\u751f\u6210<br>auto file_path = PathNormalizer::create_platform_path({<br>\u201cdocuments\u201d,<br>\u201cprojects\u201d,<br>\u201creport.txt\u201d<br>});<br>std::cout &lt;&lt; \u201cGenerated path: \u201d &lt;&lt; file_path &lt;&lt; \u2018\\n\u2019;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/\/ \u30d1\u30b9\u306e\u6b63\u898f\u5316\n    auto norm_path = PathNormalizer::normalize_path(file_path);\n    std::cout &lt;&lt; \"Normalized path: \" &lt;&lt; norm_path &lt;&lt; '\\n';\n\n    \/\/ \u76f8\u5bfe\u30d1\u30b9\u306e\u89e3\u6c7a\n    auto base_dir = fs::current_path();\n    auto relative_path = fs::path(\"..\/documents\/report.txt\");\n    auto resolved_path = PathNormalizer::resolve_relative_path(\n        base_dir,\n        relative_path\n    );\n    std::cout &lt;&lt; \"Resolved path: \" &lt;&lt; resolved_path &lt;&lt; '\\n';\n\n} catch (const fs::filesystem_error&amp; e) {\n    std::cerr &lt;&lt; \"Filesystem error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n}<\/pre>\n\n\n\n<p>}<br>\u201c`<\/p>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u306b\u7126\u70b9\u3092\u5f53\u3066\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u56fa\u6709\u306e\u6a5f\u80fd\u306e\u62bd\u8c61\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d7\u30ea\u30d7\u30ed\u30bb\u30c3\u30b5\u6307\u4ee4\u306b\u3088\u308b\u6761\u4ef6\u5206\u5c90<\/li>\n\n\n\n<li>\u5171\u901a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u63d0\u4f9b<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u7d71\u4e00<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30b9\u64cd\u4f5c\u306e\u6a19\u6e96\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30b9\u533a\u5207\u308a\u6587\u5b57\u306e\u81ea\u52d5\u5909\u63db<\/li>\n\n\n\n<li>\u6b63\u898f\u5316\u306b\u3088\u308b\u4e00\u8cab\u6027\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u76f8\u5bfe\u30d1\u30b9\u306e\u5b89\u5168\u306a\u89e3\u6c7a<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8003\u616e\u4e8b\u9805<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30b9\u8d70\u67fb\u653b\u6483\u306e\u9632\u6b62<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u72b6\u614b\u306e\u9069\u5207\u306a\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u79fb\u690d\u6027\u306e\u5411\u4e0a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u4f9d\u5b58\u306e\u30b3\u30fc\u30c9\u306e\u5206\u96e2<\/li>\n\n\n\n<li>\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u4e00\u8cab\u3057\u305f\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u7570\u306a\u308bOS\u3067\u5b89\u5168\u306b\u52d5\u4f5c\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3068\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5<\/h2>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30c7\u30d0\u30c3\u30b0\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u624b\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306e\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u3092\u6539\u5584\u3059\u308b3\u3064\u306e\u624b\u6cd5<\/h3>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;fstream&gt;\n#include &lt;vector&gt;\n#include &lt;thread&gt;\n#include &lt;mutex&gt;\n#include &lt;queue&gt;\n#include &lt;condition_variable&gt;\n\nnamespace fs = std::filesystem;\n\nclass OptimizedFileProcessor {\nprivate:\n    \/\/ \u30b9\u30ec\u30c3\u30c9\u30d7\u30fc\u30eb\u7528\u306e\u30ef\u30fc\u30ab\u30fc\u30b9\u30ec\u30c3\u30c9\u6570\n    const size_t num_threads;\n    \/\/ \u30bf\u30b9\u30af\u30ad\u30e5\u30fc\n    std::queue&lt;fs::path&gt; task_queue;\n    \/\/ \u540c\u671f\u7528\u306e\u30df\u30e5\u30fc\u30c6\u30c3\u30af\u30b9\u3068\u6761\u4ef6\u5909\u6570\n    std::mutex queue_mutex;\n    std::condition_variable condition;\n    bool stop_flag = false;\n\n    \/\/ \u51e6\u7406\u7d50\u679c\u306e\u96c6\u8a08\n    std::mutex results_mutex;\n    std::vector&lt;std::pair&lt;fs::path, uintmax_t&gt;&gt; results;\n\npublic:\n    explicit OptimizedFileProcessor(size_t thread_count = std::thread::hardware_concurrency())\n        : num_threads(thread_count) {}\n\n    \/\/ \u6700\u9069\u5316\u624b\u6cd51: \u30d0\u30c3\u30d5\u30a1\u30b5\u30a4\u30ba\u306e\u6700\u9069\u5316\n    static void copy_with_optimal_buffer(\n        const fs::path&amp; source,\n        const fs::path&amp; dest,\n        size_t buffer_size = 8192 * 1024  \/\/ 8MB default buffer\n    ) {\n        std::ifstream src(source, std::ios::binary);\n        std::ofstream dst(dest, std::ios::binary);\n\n        std::vector&lt;char&gt; buffer(buffer_size);\n        while (src.read(buffer.data(), buffer_size)) {\n            dst.write(buffer.data(), src.gcount());\n        }\n        dst.write(buffer.data(), src.gcount());\n    }\n\n    \/\/ \u6700\u9069\u5316\u624b\u6cd52: \u4e26\u884c\u51e6\u7406\u306b\u3088\u308b\u9ad8\u901f\u5316\n    void process_directory_parallel(const fs::path&amp; dir_path) {\n        \/\/ \u30bf\u30b9\u30af\u306e\u30ad\u30e5\u30fc\u30a4\u30f3\u30b0\n        for (const auto&amp; entry : fs::recursive_directory_iterator(dir_path)) {\n            if (entry.is_regular_file()) {\n                std::lock_guard&lt;std::mutex&gt; lock(queue_mutex);\n                task_queue.push(entry.path());\n            }\n        }\n\n        \/\/ \u30ef\u30fc\u30ab\u30fc\u30b9\u30ec\u30c3\u30c9\u306e\u8d77\u52d5\n        std::vector&lt;std::thread&gt; workers;\n        for (size_t i = 0; i &lt; num_threads; ++i) {\n            workers.emplace_back([this]() { process_files_worker(); });\n        }\n\n        \/\/ \u30b9\u30ec\u30c3\u30c9\u306e\u7d42\u4e86\u5f85\u3061\n        for (auto&amp; worker : workers) {\n            worker.join();\n        }\n    }\n\n    \/\/ \u6700\u9069\u5316\u624b\u6cd53: \u30e1\u30e2\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u6d3b\u7528\n    static void process_large_file_mapped(const fs::path&amp; file_path) {\n        #ifdef _WIN32\n            \/\/ Windows\u3067\u306e\u30e1\u30e2\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5\n            HANDLE file_handle = CreateFileW(\n                file_path.wstring().c_str(),\n                GENERIC_READ,\n                FILE_SHARE_READ,\n                nullptr,\n                OPEN_EXISTING,\n                FILE_ATTRIBUTE_NORMAL,\n                nullptr\n            );\n\n            if (file_handle != INVALID_HANDLE_VALUE) {\n                HANDLE mapping = CreateFileMappingW(\n                    file_handle,\n                    nullptr,\n                    PAGE_READONLY,\n                    0,\n                    0,\n                    nullptr\n                );\n\n                if (mapping) {\n                    void* mapped_view = MapViewOfFile(\n                        mapping,\n                        FILE_MAP_READ,\n                        0,\n                        0,\n                        0\n                    );\n\n                    if (mapped_view) {\n                        \/\/ \u30de\u30c3\u30d7\u3055\u308c\u305f\u30e1\u30e2\u30ea\u306b\u5bfe\u3059\u308b\u51e6\u7406\n                        process_mapped_memory(mapped_view, fs::file_size(file_path));\n                        UnmapViewOfFile(mapped_view);\n                    }\n                    CloseHandle(mapping);\n                }\n                CloseHandle(file_handle);\n            }\n        #else\n            \/\/ UNIX\u7cfb\u3067\u306e\u30e1\u30e2\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5\n            int fd = open(file_path.c_str(), O_RDONLY);\n            if (fd != -1) {\n                size_t file_size = fs::file_size(file_path);\n                void* mapped = mmap(\n                    nullptr,\n                    file_size,\n                    PROT_READ,\n                    MAP_PRIVATE,\n                    fd,\n                    0\n                );\n\n                if (mapped != MAP_FAILED) {\n                    \/\/ \u30de\u30c3\u30d7\u3055\u308c\u305f\u30e1\u30e2\u30ea\u306b\u5bfe\u3059\u308b\u51e6\u7406\n                    process_mapped_memory(mapped, file_size);\n                    munmap(mapped, file_size);\n                }\n                close(fd);\n            }\n        #endif\n    }\n\nprivate:\n    void process_files_worker() {\n        while (true) {\n            fs::path current_file;\n\n            \/\/ \u30bf\u30b9\u30af\u306e\u53d6\u5f97\n            {\n                std::unique_lock&lt;std::mutex&gt; lock(queue_mutex);\n                condition.wait(lock, [this]() {\n                    return !task_queue.empty() || stop_flag;\n                });\n\n                if (stop_flag &amp;&amp; task_queue.empty()) {\n                    return;\n                }\n\n                current_file = task_queue.front();\n                task_queue.pop();\n            }\n\n            \/\/ \u30d5\u30a1\u30a4\u30eb\u51e6\u7406\n            try {\n                auto size = fs::file_size(current_file);\n\n                std::lock_guard&lt;std::mutex&gt; lock(results_mutex);\n                results.emplace_back(current_file, size);\n\n            } catch (const fs::filesystem_error&amp; e) {\n                std::cerr &lt;&lt; \"Error processing file: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            }\n        }\n    }\n\n    static void process_mapped_memory(void* data, size_t size) {\n        \/\/ \u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306e\u51e6\u7406\u4f8b\n        const char* buffer = static_cast&lt;const char*&gt;(data);\n        \/\/ \u3053\u3053\u3067\u30d0\u30c3\u30d5\u30a1\u306e\u51e6\u7406\u3092\u5b9f\u88c5\n    }\n};\n\n### \u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5\n\n\u4e00\u822c\u7684\u306a\u30a8\u30e9\u30fc\u306e\u30c7\u30d0\u30c3\u30b0\u3068\u89e3\u6c7a\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\uff1a<\/pre>\n\n\n\n<p>cpp<br>class FileSystemDebugger {<br>public:<br>\/\/ \u30a8\u30e9\u30fc1: \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u95a2\u9023\u306e\u554f\u984c<br>static bool check_and_fix_permissions(const fs::path&amp; path) {<br>try {<br>auto status = fs::status(path);<br>auto perms = status.permissions();<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        \/\/ \u8aad\u307f\u53d6\u308a\u6a29\u9650\u306e\u78ba\u8a8d\n        if ((perms &amp; fs::perms::owner_read) == fs::perms::none) {\n            \/\/ \u6a29\u9650\u306e\u4fee\u6b63\n            fs::permissions(path, \n                fs::perms::owner_read,\n                fs::perm_options::add\n            );\n            std::cout &lt;&lt; \"Added read permission to: \" &lt;&lt; path &lt;&lt; '\\n';\n        }\n        return true;\n\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Permission error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        return false;\n    }\n}\n\n\/\/ \u30a8\u30e9\u30fc2: \u30ed\u30c3\u30af\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\nstatic bool handle_locked_file(const fs::path&amp; path) {\n    const int max_retries = 5;\n    const std::chrono::milliseconds wait_time(100);\n\n    for (int i = 0; i &lt; max_retries; ++i) {\n        try {\n            if (fs::exists(path)) {\n                std::ifstream file(path);\n                if (file) {\n                    return true;\n                }\n            }\n        } catch (const fs::filesystem_error&amp;) {\n            std::this_thread::sleep_for(wait_time);\n            continue;\n        }\n    }\n    return false;\n}\n\n\/\/ \u30a8\u30e9\u30fc3: \u5b58\u5728\u3057\u306a\u3044\u30d1\u30b9\u306e\u51e6\u7406\nstatic fs::path verify_and_create_path(const fs::path&amp; path) {\n    try {\n        if (!fs::exists(path)) {\n            if (path.has_filename()) {\n                \/\/ \u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u5834\u5408\u306f\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\n                fs::create_directories(path.parent_path());\n            } else {\n                \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u306e\u5834\u5408\u306f\u76f4\u63a5\u4f5c\u6210\n                fs::create_directories(path);\n            }\n            std::cout &lt;&lt; \"Created missing path: \" &lt;&lt; path &lt;&lt; '\\n';\n        }\n        return fs::absolute(path);\n\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Path creation error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        throw;\n    }\n}\n\n\/\/ \u30a8\u30e9\u30fc4: \u30d1\u30b9\u6587\u5b57\u5217\u306e\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u554f\u984c\nstatic fs::path handle_path_encoding(const std::string&amp; path_str) {\n    try {\n        #ifdef _WIN32\n            std::wstring wide_path;\n            int required_size = MultiByteToWideChar(\n                CP_UTF8,\n                0,\n                path_str.c_str(),\n                -1,\n                nullptr,\n                0\n            );\n\n            if (required_size &gt; 0) {\n                wide_path.resize(required_size);\n                MultiByteToWideChar(\n                    CP_UTF8,\n                    0,\n                    path_str.c_str(),\n                    -1,\n                    &amp;wide_path[0],\n                    required_size\n                );\n                return fs::path(wide_path);\n            }\n        #endif\n        return fs::path(path_str);\n\n    } catch (const fs::filesystem_error&amp; e) {\n        std::cerr &lt;&lt; \"Path encoding error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        throw;\n    }\n}<\/pre>\n\n\n\n<p>};<br>\u201c`<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u624b\u6cd5<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6700\u9069\u306a\u30d0\u30c3\u30d5\u30a1\u30b5\u30a4\u30ba\u306e\u4f7f\u7528<\/li>\n\n\n\n<li>\u4e26\u884c\u51e6\u7406\u306b\u3088\u308b\u51e6\u7406\u306e\u9ad8\u901f\u5316<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u6d3b\u7528<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u51e6\u7406\u3068\u30c7\u30d0\u30c3\u30b0<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u554f\u984c\u306e\u89e3\u6c7a<\/li>\n\n\n\n<li>\u30ed\u30c3\u30af\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406<\/li>\n\n\n\n<li>\u5b58\u5728\u3057\u306a\u3044\u30d1\u30b9\u306e\u9069\u5207\u306a\u51e6\u7406<\/li>\n\n\n\n<li>\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u554f\u984c\u3078\u306e\u5bfe\u5fdc<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9f\u88c5\u4e0a\u306e\u6ce8\u610f\u70b9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u306e\u9069\u5207\u306a\u89e3\u653e<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u72b6\u614b\u304b\u3089\u306e\u56de\u5fa9<\/li>\n\n\n\n<li>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u56fa\u6709\u306e\u554f\u984c\u3078\u306e\u5bfe\u5fdc<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u51e6\u7406\u6642\u9593\u306e\u8a08\u6e2c<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u4f7f\u7528\u72b6\u6cc1\u306e\u8ffd\u8de1<\/li>\n\n\n\n<li>\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u7279\u5b9a<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u3092\u53c2\u8003\u306b\u3001\u52b9\u7387\u7684\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-11\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<p>\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u906d\u9047\u3059\u308b\u5177\u4f53\u7684\u306a\u8ab2\u984c\u306b\u5bfe\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u5927\u91cf\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u4e00\u62ec\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u5b9f\u88c5\u4f8b<\/h3>\n\n\n\n<p>\u5927\u91cf\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;thread&gt;\n#include &lt;queue&gt;\n#include &lt;mutex&gt;\n#include &lt;condition_variable&gt;\n#include &lt;chrono&gt;\n#include &lt;atomic&gt;\n#include &lt;unordered_map&gt;\n\nnamespace fs = std::filesystem;\n\nclass BatchFileProcessor {\nprivate:\n    \/\/ \u51e6\u7406\u306e\u9032\u6357\u7ba1\u7406\n    struct ProcessingStats {\n        std::atomic&lt;size_t&gt; processed_files{0};\n        std::atomic&lt;size_t&gt; total_files{0};\n        std::atomic&lt;uintmax_t&gt; total_size{0};\n        std::chrono::steady_clock::time_point start_time;\n    };\n\n    \/\/ \u30ef\u30fc\u30ab\u30fc\u30b9\u30ec\u30c3\u30c9\u30d7\u30fc\u30eb\n    class ThreadPool {\n    private:\n        std::vector&lt;std::thread&gt; workers;\n        std::queue&lt;std::function&lt;void()&gt;&gt; tasks;\n        std::mutex queue_mutex;\n        std::condition_variable condition;\n        bool stop;\n\n    public:\n        ThreadPool(size_t threads) : stop(false) {\n            for(size_t i = 0; i &lt; threads; ++i) {\n                workers.emplace_back([this] {\n                    while(true) {\n                        std::function&lt;void()&gt; task;\n                        {\n                            std::unique_lock&lt;std::mutex&gt; lock(queue_mutex);\n                            condition.wait(lock, [this] { \n                                return stop || !tasks.empty(); \n                            });\n                            if(stop &amp;&amp; tasks.empty()) return;\n                            task = std::move(tasks.front());\n                            tasks.pop();\n                        }\n                        task();\n                    }\n                });\n            }\n        }\n\n        template&lt;class F&gt;\n        void enqueue(F&amp;&amp; f) {\n            {\n                std::unique_lock&lt;std::mutex&gt; lock(queue_mutex);\n                tasks.emplace(std::forward&lt;F&gt;(f));\n            }\n            condition.notify_one();\n        }\n\n        ~ThreadPool() {\n            {\n                std::unique_lock&lt;std::mutex&gt; lock(queue_mutex);\n                stop = true;\n            }\n            condition.notify_all();\n            for(std::thread&amp; worker: workers) {\n                worker.join();\n            }\n        }\n    };\n\n    ProcessingStats stats;\n    ThreadPool thread_pool;\n\npublic:\n    BatchFileProcessor() : thread_pool(std::thread::hardware_concurrency()) {\n        stats.start_time = std::chrono::steady_clock::now();\n    }\n\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u62ec\u51e6\u7406\n    void process_directory(\n        const fs::path&amp; dir_path,\n        const std::function&lt;void(const fs::path&amp;)&gt;&amp; file_processor\n    ) {\n        try {\n            \/\/ \u7dcf\u30d5\u30a1\u30a4\u30eb\u6570\u306e\u30ab\u30a6\u30f3\u30c8\n            for(const auto&amp; entry : fs::recursive_directory_iterator(dir_path)) {\n                if(entry.is_regular_file()) {\n                    stats.total_files++;\n                    stats.total_size += entry.file_size();\n                }\n            }\n\n            \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u4e26\u5217\u51e6\u7406\n            for(const auto&amp; entry : fs::recursive_directory_iterator(dir_path)) {\n                if(entry.is_regular_file()) {\n                    thread_pool.enqueue([this, entry, file_processor]() {\n                        try {\n                            file_processor(entry.path());\n                            stats.processed_files++;\n                            print_progress();\n                        } catch(const std::exception&amp; e) {\n                            std::cerr &lt;&lt; \"Error processing file \" \n                                    &lt;&lt; entry.path() &lt;&lt; \": \" \n                                    &lt;&lt; e.what() &lt;&lt; '\\n';\n                        }\n                    });\n                }\n            }\n\n        } catch(const fs::filesystem_error&amp; e) {\n            std::cerr &lt;&lt; \"Filesystem error: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            throw;\n        }\n    }\n\n    \/\/ \u9032\u6357\u72b6\u6cc1\u306e\u8868\u793a\n    void print_progress() {\n        auto now = std::chrono::steady_clock::now();\n        auto duration = std::chrono::duration_cast&lt;std::chrono::seconds&gt;(\n            now - stats.start_time\n        ).count();\n\n        if(duration &gt; 0) {\n            size_t files_per_second = stats.processed_files \/ duration;\n            double progress = static_cast&lt;double&gt;(stats.processed_files) \/ \n                            stats.total_files * 100;\n\n            std::cout &lt;&lt; \"\\rProgress: \" &lt;&lt; std::fixed &lt;&lt; std::setprecision(2)\n                     &lt;&lt; progress &lt;&lt; \"% (\" \n                     &lt;&lt; stats.processed_files &lt;&lt; \"\/\" &lt;&lt; stats.total_files \n                     &lt;&lt; \" files, \" &lt;&lt; files_per_second &lt;&lt; \" files\/sec)\" \n                     &lt;&lt; std::flush;\n        }\n    }\n};\n\n### \u30d5\u30a1\u30a4\u30eb\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u4f8b\n\n\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30d5\u30a1\u30a4\u30eb\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/pre>\n\n\n\n<p>cpp<br>class BackupSystem {<br>private:<br>struct BackupConfig {<br>fs::path source_dir;<br>fs::path backup_dir;<br>std::vector exclude_patterns;<br>bool incremental;<br>size_t max_versions;<br>};<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct BackupMetadata {\n    std::chrono::system_clock::time_point timestamp;\n    std::unordered_map&lt;std::string, std::pair&lt;\n        std::chrono::system_clock::time_point,\n        uintmax_t\n    &gt;&gt; file_info;\n};\n\nBackupConfig config;\nstd::mutex metadata_mutex;<\/pre>\n\n\n\n<p>public:<br>explicit BackupSystem(const BackupConfig&amp; cfg) : config(cfg) {<br>initialize_backup_directory();<br>}<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u5b9f\u884c\nbool perform_backup() {\n    try {\n        auto backup_time = std::chrono::system_clock::now();\n        auto version_dir = create_version_directory(backup_time);\n\n        BackupMetadata previous_metadata;\n        if(config.incremental) {\n            load_previous_metadata(previous_metadata);\n        }\n\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u53ce\u96c6\u3068\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\n        std::vector&lt;fs::path&gt; files_to_backup;\n        collect_files_for_backup(\n            config.source_dir,\n            files_to_backup,\n            previous_metadata\n        );\n\n        \/\/ \u4e26\u5217\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u5b9f\u884c\n        backup_files_parallel(files_to_backup, version_dir);\n\n        \/\/ \u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\n        save_metadata(version_dir, backup_time);\n\n        \/\/ \u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u524a\u9664\n        cleanup_old_versions();\n\n        return true;\n\n    } catch(const std::exception&amp; e) {\n        std::cerr &lt;&lt; \"Backup failed: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n        return false;\n    }\n}<\/pre>\n\n\n\n<p>private:<br>\/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u521d\u671f\u5316<br>void initialize_backup_directory() {<br>if(!fs::exists(config.backup_dir)) {<br>fs::create_directories(config.backup_dir);<br>}<br>}<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210\nfs::path create_version_directory(\n    const std::chrono::system_clock::time_point&amp; timestamp\n) {\n    auto time_t = std::chrono::system_clock::to_time_t(timestamp);\n    std::stringstream ss;\n    ss &lt;&lt; std::put_time(std::localtime(&amp;time_t), \"%Y%m%d_%H%M%S\");\n\n    auto version_dir = config.backup_dir \/ ss.str();\n    fs::create_directories(version_dir);\n    return version_dir;\n}\n\n\/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u306e\u53ce\u96c6\nvoid collect_files_for_backup(\n    const fs::path&amp; dir,\n    std::vector&lt;fs::path&gt;&amp; files,\n    const BackupMetadata&amp; prev_metadata\n) {\n    for(const auto&amp; entry : fs::recursive_directory_iterator(dir)) {\n        if(!entry.is_regular_file()) continue;\n\n        \/\/ \u9664\u5916\u30d1\u30bf\u30fc\u30f3\u306e\u30c1\u30a7\u30c3\u30af\n        bool should_exclude = false;\n        for(const auto&amp; pattern : config.exclude_patterns) {\n            if(entry.path().string().find(pattern) != std::string::npos) {\n                should_exclude = true;\n                break;\n            }\n        }\n        if(should_exclude) continue;\n\n        \/\/ \u5897\u5206\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u5834\u5408\u306f\u5909\u66f4\u3092\u30c1\u30a7\u30c3\u30af\n        if(config.incremental) {\n            auto rel_path = fs::relative(entry.path(), config.source_dir);\n            auto it = prev_metadata.file_info.find(rel_path.string());\n\n            if(it != prev_metadata.file_info.end()) {\n                auto [prev_time, prev_size] = it-&gt;second;\n                auto curr_time = fs::last_write_time(entry.path());\n                auto curr_size = entry.file_size();\n\n                if(curr_time == prev_time &amp;&amp; curr_size == prev_size) {\n                    continue;\n                }\n            }\n        }\n\n        files.push_back(entry.path());\n    }\n}\n\n\/\/ \u4e26\u5217\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u5b9f\u884c\nvoid backup_files_parallel(\n    const std::vector&lt;fs::path&gt;&amp; files,\n    const fs::path&amp; version_dir\n) {\n    ThreadPool pool(std::thread::hardware_concurrency());\n    std::atomic&lt;size_t&gt; completed_files = 0;\n    size_t total_files = files.size();\n\n    for(const auto&amp; file : files) {\n        pool.enqueue([this, file, version_dir, &amp;completed_files, total_files] {\n            try {\n                auto rel_path = fs::relative(file, config.source_dir);\n                auto backup_path = version_dir \/ rel_path;\n\n                fs::create_directories(backup_path.parent_path());\n                fs::copy_file(\n                    file,\n                    backup_path,\n                    fs::copy_options::overwrite_existing\n                );\n\n                completed_files++;\n                print_backup_progress(completed_files, total_files);\n\n            } catch(const std::exception&amp; e) {\n                std::cerr &lt;&lt; \"Error backing up \" &lt;&lt; file &lt;&lt; \": \"\n                         &lt;&lt; e.what() &lt;&lt; '\\n';\n            }\n        });\n    }\n}\n\n\/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u9032\u6357\u8868\u793a\nvoid print_backup_progress(size_t completed, size_t total) {\n    double progress = static_cast&lt;double&gt;(completed) \/ total * 100;\n    std::cout &lt;&lt; \"\\rBackup progress: \" &lt;&lt; std::fixed &lt;&lt; std::setprecision(2)\n             &lt;&lt; progress &lt;&lt; \"% (\" &lt;&lt; completed &lt;&lt; \"\/\" &lt;&lt; total &lt;&lt; \" files)\"\n             &lt;&lt; std::flush;\n}\n\n\/\/ \u53e4\u3044\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u524a\u9664\nvoid cleanup_old_versions() {\n    std::vector&lt;fs::path&gt; versions;\n    for(const auto&amp; entry : fs::directory_iterator(config.backup_dir)) {\n        if(entry.is_directory()) {\n            versions.push_back(entry.path());\n        }\n    }\n\n    if(versions.size() &gt; config.max_versions) {\n        std::sort(versions.begin(), versions.end());\n        size_t to_delete = versions.size() - config.max_versions;\n\n        for(size_t i = 0; i &lt; to_delete; ++i) {\n            fs::remove_all(versions[i]);\n        }\n    }\n}<\/pre>\n\n\n\n<p>};<br>\u201c`<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5927\u91cf\u30d5\u30a1\u30a4\u30eb\u51e6\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b9\u30ec\u30c3\u30c9\u30d7\u30fc\u30eb\u306b\u3088\u308b\u4e26\u5217\u51e6\u7406<\/li>\n\n\n\n<li>\u9032\u6357\u7ba1\u7406\u3068\u8868\u793a<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b7\u30b9\u30c6\u30e0<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5897\u5206\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406<\/li>\n\n\n\n<li>\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7ba1\u7406<\/li>\n\n\n\n<li>\u4e26\u5217\u51e6\u7406\u306b\u3088\u308b\u9ad8\u901f\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9f\u88c5\u4e0a\u306e\u5de5\u592b<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u306e\u52b9\u7387\u7684\u306a\u4f7f\u7528<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u304b\u3089\u306e\u56de\u5fa9<\/li>\n\n\n\n<li>\u51e6\u7406\u306e\u4e2d\u65ad\u3068\u518d\u958b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u4fe1\u983c\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52b9\u7387\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u30ea\u30fc\u30af\u306e\u9632\u6b62<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u3092\u57fa\u306b\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u305f\u5b9f\u88c5\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-13\">\u4eca\u5f8c\u306e\u5c55\u958b\u3068\u6280\u8853\u95a2\u9023<\/h2>\n\n\n\n<p>C++\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u306b\u304a\u3051\u308b\u6700\u65b0\u306e\u6280\u8853\u52d5\u5411\u3068\u5c06\u6765\u306e\u5c55\u671b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">C++23\u3067\u8ffd\u52a0\u3055\u308c\u308b\u65b0\u6a5f\u80fd\u3068\u6d3b\u7528\u65b9\u6cd5<\/h3>\n\n\n\n<p>C++23\u3067\u5c0e\u5165\u3055\u308c\u308b\u65b0\u6a5f\u80fd\u3068\u305d\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;filesystem&gt;\n#include &lt;iostream&gt;\n#include &lt;expected&gt;  \/\/ C++23\n#include &lt;ranges&gt;    \/\/ C++20\/23\u306e\u62e1\u5f35\u6a5f\u80fd\n\nnamespace fs = std::filesystem;\n\nclass ModernFileSystem {\npublic:\n    \/\/ C++23: std::expected\u3092\u4f7f\u7528\u3057\u305f\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    std::expected&lt;std::vector&lt;fs::path&gt;, std::error_code&gt; \n    list_files(const fs::path&amp; dir_path) {\n        try {\n            std::vector&lt;fs::path&gt; files;\n\n            \/\/ C++23: ranges\u306e\u62e1\u5f35\u6a5f\u80fd\u3092\u4f7f\u7528\n            auto file_range = fs::directory_iterator(dir_path) \n                | std::views::filter([](const auto&amp; entry) {\n                    return entry.is_regular_file();\n                })\n                | std::views::transform([](const auto&amp; entry) {\n                    return entry.path();\n                });\n\n            files.assign(file_range.begin(), file_range.end());\n            return files;\n\n        } catch (const fs::filesystem_error&amp; e) {\n            return std::unexpected(e.code());\n        }\n    }\n\n    \/\/ C++23: \u76f8\u5bfe\u30d1\u30b9\u306e\u30b5\u30dd\u30fc\u30c8\u5f37\u5316\n    std::expected&lt;fs::path, std::error_code&gt; \n    get_relative_path(const fs::path&amp; path, const fs::path&amp; base) {\n        try {\n            \/\/ \u65b0\u3057\u3044\u76f8\u5bfe\u30d1\u30b9\u8a08\u7b97\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u4f7f\u7528\n            auto rel_path = fs::proximate(path, base);\n            return rel_path;\n        } catch (const fs::filesystem_error&amp; e) {\n            return std::unexpected(e.code());\n        }\n    }\n\n    \/\/ C++23: \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u76e3\u8996\u6a5f\u80fd\n    template&lt;typename Callback&gt;\n    void watch_directory(\n        const fs::path&amp; dir_path,\n        Callback&amp;&amp; callback\n    ) {\n        \/\/ \u5c06\u6765\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u76e3\u8996API\u306e\u5b9f\u88c5\u4f8b\n        auto watcher = fs::file_watcher(dir_path);\n        watcher.on_change([callback](const fs::path&amp; path, fs::file_status status) {\n            callback(path, status);\n        });\n    }\n};\n\n### \u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3078\u306e\u767a\u5c55\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5\n\n\u6700\u65b0\u306eC++\u6a5f\u80fd\u3092\u6d3b\u7528\u3057\u305f\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/pre>\n\n\n\n<p>cpp<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-15\">include<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-16\">include<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-17\">include<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-18\">include<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-19\">include<\/h1>\n\n\n\n<p>\/\/ \u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306e\u57fa\u672c\u30af\u30e9\u30b9<br>class AsyncFileSystem {<br>public:<br>\/\/ \u30b3\u30eb\u30fc\u30c1\u30f3\u3092\u4f7f\u7528\u3057\u305f\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u53d6\u308a<br>struct AsyncReadOperation {<br>struct promise_type {<br>AsyncReadOperation get_return_object() {<br>return AsyncReadOperation{<br>std::coroutine_handle::from_promise(*this)<br>};<br>}<br>std::suspend_never initial_suspend() { return {}; }<br>std::suspend_never final_suspend() noexcept { return {}; }<br>void return_void() {}<br>void unhandled_exception() {}<br>};<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    std::coroutine_handle&lt;promise_type&gt; handle;\n\n    AsyncReadOperation(std::coroutine_handle&lt;promise_type&gt; h) : handle(h) {}\n    ~AsyncReadOperation() { if (handle) handle.destroy(); }\n};\n\n\/\/ \u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u53d6\u308a\u306e\u5b9f\u88c5\nAsyncReadOperation async_read_file(const fs::path&amp; path) {\n    try {\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306e\u53d6\u5f97\n        auto file_size = fs::file_size(path);\n\n        \/\/ \u30d0\u30c3\u30d5\u30a1\u306e\u6e96\u5099\n        auto buffer = std::make_shared&lt;std::vector&lt;char&gt;&gt;(file_size);\n\n        \/\/ \u975e\u540c\u671f\u8aad\u307f\u53d6\u308a\u30bf\u30b9\u30af\u306e\u4f5c\u6210\n        auto future = std::async(std::launch::async, [path, buffer]() {\n            std::ifstream file(path, std::ios::binary);\n            if (file.read(buffer-&gt;data(), buffer-&gt;size())) {\n                return true;\n            }\n            throw std::runtime_error(\"Failed to read file\");\n        });\n\n        \/\/ \u7d50\u679c\u306e\u5f85\u6a5f\n        co_await std::suspend_always{};\n        auto result = future.get();\n\n        if (result) {\n            \/\/ \u6210\u529f\u6642\u306e\u51e6\u7406\n            process_buffer(buffer);\n        }\n\n    } catch (const std::exception&amp; e) {\n        std::cerr &lt;&lt; \"Error in async read: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n    }\n}\n\n\/\/ \u4e26\u884c\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u30ad\u30e5\u30fc\u306e\u5b9f\u88c5\nclass AsyncFileQueue {\nprivate:\n    struct FileOperation {\n        fs::path path;\n        std::function&lt;void(const fs::path&amp;)&gt; operation;\n    };\n\n    std::queue&lt;FileOperation&gt; op_queue;\n    std::mutex queue_mutex;\n    std::condition_variable condition;\n    bool stop_flag = false;\n    std::vector&lt;std::thread&gt; worker_threads;\n\npublic:\n    AsyncFileQueue(size_t thread_count = std::thread::hardware_concurrency()) {\n        for (size_t i = 0; i &lt; thread_count; ++i) {\n            worker_threads.emplace_back([this] { process_queue(); });\n        }\n    }\n\n    \/\/ \u64cd\u4f5c\u306e\u30ad\u30e5\u30fc\u30a4\u30f3\u30b0\n    template&lt;typename Func&gt;\n    void enqueue(const fs::path&amp; path, Func&amp;&amp; operation) {\n        {\n            std::lock_guard&lt;std::mutex&gt; lock(queue_mutex);\n            op_queue.push({path, std::forward&lt;Func&gt;(operation)});\n        }\n        condition.notify_one();\n    }\n\n    \/\/ \u30ad\u30e5\u30fc\u306e\u51e6\u7406\n    void process_queue() {\n        while (true) {\n            FileOperation op;\n            {\n                std::unique_lock&lt;std::mutex&gt; lock(queue_mutex);\n                condition.wait(lock, [this] {\n                    return !op_queue.empty() || stop_flag;\n                });\n\n                if (stop_flag &amp;&amp; op_queue.empty()) {\n                    return;\n                }\n\n                op = std::move(op_queue.front());\n                op_queue.pop();\n            }\n\n            try {\n                op.operation(op.path);\n            } catch (const std::exception&amp; e) {\n                std::cerr &lt;&lt; \"Error processing file: \" &lt;&lt; e.what() &lt;&lt; '\\n';\n            }\n        }\n    }\n\n    ~AsyncFileQueue() {\n        {\n            std::lock_guard&lt;std::mutex&gt; lock(queue_mutex);\n            stop_flag = true;\n        }\n        condition.notify_all();\n        for (auto&amp; thread : worker_threads) {\n            thread.join();\n        }\n    }\n};<\/pre>\n\n\n\n<p>private:<br>static void process_buffer(const std::shared_ptr&gt;&amp; buffer) {<br>\/\/ \u30d0\u30c3\u30d5\u30a1\u51e6\u7406\u306e\u5b9f\u88c5<br>}<br>};<\/p>\n\n\n\n<p>\/\/ \u9ad8\u5ea6\u306a\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u4f8b<br>class AdvancedAsyncFileSystem {<br>public:<br>\/\/ \u30a4\u30d9\u30f3\u30c8\u30d9\u30fc\u30b9\u306e\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u76e3\u8996<br>class FileEventMonitor {<br>private:<br>fs::path watch_path;<br>std::function callback;<br>std::atomic running{false};<br>std::thread monitor_thread;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public:\n    FileEventMonitor(\n        const fs::path&amp; path,\n        std::function&lt;void(const fs::path&amp;, const std::string&amp;)&gt; cb\n    ) : watch_path(path), callback(std::move(cb)) {}\n\n    void start() {\n        running = true;\n        monitor_thread = std::thread([this] {\n            while (running) {\n                \/\/ \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u30a4\u30d9\u30f3\u30c8\u306e\u76e3\u8996\u3068\u901a\u77e5\n                \/\/ \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u56fa\u6709\u306eAPI\u3092\u4f7f\u7528\n                \/\/ (\u4f8b: inotify, kqueue, ReadDirectoryChangesW)\n                std::this_thread::sleep_for(std::chrono::milliseconds(100));\n            }\n        });\n    }\n\n    void stop() {\n        running = false;\n        if (monitor_thread.joinable()) {\n            monitor_thread.join();\n        }\n    }\n\n    ~FileEventMonitor() {\n        stop();\n    }\n};<\/pre>\n\n\n\n<p>};<br>\u201c`<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u4ee5\u4e0b\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u793a\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>C++23\u306e\u65b0\u6a5f\u80fd\u6d3b\u7528<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>std::expected\u306b\u3088\u308b\u6539\u5584\u3055\u308c\u305f\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>ranges\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u62e1\u5f35\u6a5f\u80fd\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0API\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u975e\u540c\u671f\u51e6\u7406\u306e\u767a\u5c55<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30eb\u30fc\u30c1\u30f3\u3092\u4f7f\u7528\u3057\u305f\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c<\/li>\n\n\n\n<li>\u30a4\u30d9\u30f3\u30c8\u30d9\u30fc\u30b9\u306e\u30d5\u30a1\u30a4\u30eb\u76e3\u8996<\/li>\n\n\n\n<li>\u52b9\u7387\u7684\u306a\u4e26\u884c\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5c06\u6765\u7684\u306a\u5c55\u671b<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u76e3\u8996API\u306e\u6a19\u6e96\u5316<\/li>\n\n\n\n<li>\u975e\u540c\u671f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306e\u6a19\u6e96\u5316<\/li>\n\n\n\n<li>\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u6a5f\u80fd\u306e\u62e1\u5145<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9f\u88c5\u306e\u6539\u5584\u70b9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5f37\u5316<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>API\u306e\u4f7f\u3044\u3084\u3059\u3055\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u65b0\u6a5f\u80fd\u3068\u5b9f\u88c5\u624b\u6cd5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u64cd\u4f5c\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":{"0":"post-2100","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-cpp","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2100"}],"version-history":[{"count":1,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2100\/revisions"}],"predecessor-version":[{"id":2101,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2100\/revisions\/2101"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}