{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/23433658","id":23433658,"diff_hunk":"@@ -4247,38 +4247,35 @@ void game::death_screen()\n \n void game::move_save_to_graveyard()\n {\n-    const std::string savedir = world_generator->active_world->world_path;\n-    const std::string graveyarddir = FILENAMES[\"graveyarddir\"];\n-    const std::string prefix = base64_encode( u.name ) + \".\";\n-    if( !assure_dir_exist( graveyarddir ) ) {\n-        debugmsg( \"could not create graveyard path %s\", graveyarddir.c_str() );\n-    }\n-    struct dirent *save_dirent = NULL;\n-    DIR *save_dir = opendir( savedir.c_str() );\n-    if( save_dir == NULL ) {\n-        debugmsg( \"could not open savedir %s\", savedir.c_str() );\n-        return;\n+    auto const &save_dir      = world_generator->active_world->world_path;\n+    auto const &graveyard_dir = FILENAMES[\"graveyarddir\"];\n+    auto const &prefix        = base64_encode(u.name) + \".\";\n+    \n+    if (!assure_dir_exist(graveyard_dir)) {\n+        debugmsg(\"could not create graveyard path '%s'\", graveyard_dir.c_str());\n+    }\n+\n+    auto const save_files = get_files_from_path(prefix, save_dir);\n+    if (save_files.empty()) {\n+        debugmsg(\"could not find save files in '%s'\", save_dir.c_str());\n     }\n-    while( ( save_dirent = readdir( save_dir ) ) != NULL ) {\n-        const std::string name = save_dirent->d_name;\n-        // Player character specific files are formed as\n-        // <base64(player-name)>.<extension>\n-        // extensions is '.sav' for the main save, .log for the memorial, ...\n-        if( name.compare( 0, prefix.length(), prefix ) != 0 ) {\n+\n+    for (auto const &src_path : save_files) {\n+        auto const dst_path = graveyard_dir +\n+            src_path.substr(src_path.rfind('/'), std::string::npos);\n+\n+        if (rename_file(src_path, dst_path)) {\n             continue;\n         }\n-        const std::string dstpath = graveyarddir + \"/\" + name;\n-        const std::string srcpath = savedir + \"/\" + name;\n-        // this might fail if the graveyard dir does not exist\n-        if( !rename_file( srcpath, dstpath ) ) {\n-            // Permadeath! The player file must be gone!\n-            if( !remove_file( srcpath ) ) {\n-                // AHHH, who or what prevents permadeath?\n-                debugmsg( \"could not remove file %s\", srcpath.c_str() );\n-            }\n+\n+        debugmsg(\"could not rename file '%s' to '%s'\", src_path.c_str(), dst_path.substr());","path":"src/game.cpp","position":51,"original_position":51,"commit_id":"ce8c3157bb543feb7f8a0b36ce1c411ea2e0b284","original_commit_id":"ce8c3157bb543feb7f8a0b36ce1c411ea2e0b284","user":{"login":"kevingranade","id":860276,"avatar_url":"https://avatars.githubusercontent.com/u/860276?v=3","gravatar_id":"","url":"https://api.github.com/users/kevingranade","html_url":"https://github.com/kevingranade","followers_url":"https://api.github.com/users/kevingranade/followers","following_url":"https://api.github.com/users/kevingranade/following{/other_user}","gists_url":"https://api.github.com/users/kevingranade/gists{/gist_id}","starred_url":"https://api.github.com/users/kevingranade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevingranade/subscriptions","organizations_url":"https://api.github.com/users/kevingranade/orgs","repos_url":"https://api.github.com/users/kevingranade/repos","events_url":"https://api.github.com/users/kevingranade/events{/privacy}","received_events_url":"https://api.github.com/users/kevingranade/received_events","type":"User","site_admin":false},"body":"Jenkins is complaining about this, I think it wants dst_path.c_str(), not substr.  Why substr anyway?","created_at":"2015-01-23T06:14:47Z","updated_at":"2015-01-23T06:14:47Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971#discussion_r23433658","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/23433658"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971#discussion_r23433658"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971","id":27900660,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10971","number":10971,"state":"open","locked":false,"title":"This is a partial cleanup of the remaining filesystem loose ends.","user":{"login":"bkentel","id":780369,"avatar_url":"https://avatars.githubusercontent.com/u/780369?v=3","gravatar_id":"","url":"https://api.github.com/users/bkentel","html_url":"https://github.com/bkentel","followers_url":"https://api.github.com/users/bkentel/followers","following_url":"https://api.github.com/users/bkentel/following{/other_user}","gists_url":"https://api.github.com/users/bkentel/gists{/gist_id}","starred_url":"https://api.github.com/users/bkentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkentel/subscriptions","organizations_url":"https://api.github.com/users/bkentel/orgs","repos_url":"https://api.github.com/users/bkentel/repos","events_url":"https://api.github.com/users/bkentel/events{/privacy}","received_events_url":"https://api.github.com/users/bkentel/received_events","type":"User","site_admin":false},"body":"Updated `game::move_save_to_graveyard()`.","created_at":"2015-01-23T04:28:17Z","updated_at":"2015-01-23T06:14:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cf7a6d8b039abdc23ea7d3e4e116f226a4fea17","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971/comments","review_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/{number}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10971/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/ce8c3157bb543feb7f8a0b36ce1c411ea2e0b284","head":{"label":"bkentel:partial-fsys-cleanup-1","ref":"partial-fsys-cleanup-1","sha":"ce8c3157bb543feb7f8a0b36ce1c411ea2e0b284","user":{"login":"bkentel","id":780369,"avatar_url":"https://avatars.githubusercontent.com/u/780369?v=3","gravatar_id":"","url":"https://api.github.com/users/bkentel","html_url":"https://github.com/bkentel","followers_url":"https://api.github.com/users/bkentel/followers","following_url":"https://api.github.com/users/bkentel/following{/other_user}","gists_url":"https://api.github.com/users/bkentel/gists{/gist_id}","starred_url":"https://api.github.com/users/bkentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkentel/subscriptions","organizations_url":"https://api.github.com/users/bkentel/orgs","repos_url":"https://api.github.com/users/bkentel/repos","events_url":"https://api.github.com/users/bkentel/events{/privacy}","received_events_url":"https://api.github.com/users/bkentel/received_events","type":"User","site_admin":false},"repo":{"id":28679284,"name":"Cataclysm-DDA","full_name":"bkentel/Cataclysm-DDA","owner":{"login":"bkentel","id":780369,"avatar_url":"https://avatars.githubusercontent.com/u/780369?v=3","gravatar_id":"","url":"https://api.github.com/users/bkentel","html_url":"https://github.com/bkentel","followers_url":"https://api.github.com/users/bkentel/followers","following_url":"https://api.github.com/users/bkentel/following{/other_user}","gists_url":"https://api.github.com/users/bkentel/gists{/gist_id}","starred_url":"https://api.github.com/users/bkentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkentel/subscriptions","organizations_url":"https://api.github.com/users/bkentel/orgs","repos_url":"https://api.github.com/users/bkentel/repos","events_url":"https://api.github.com/users/bkentel/events{/privacy}","received_events_url":"https://api.github.com/users/bkentel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bkentel/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/bkentel/Cataclysm-DDA","forks_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/issues/comments/{number}","contents_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/bkentel/Cataclysm-DDA/releases{/id}","created_at":"2015-01-01T02:36:43Z","updated_at":"2015-01-23T02:07:24Z","pushed_at":"2015-01-23T04:30:00Z","git_url":"git://github.com/bkentel/Cataclysm-DDA.git","ssh_url":"git@github.com:bkentel/Cataclysm-DDA.git","clone_url":"https://github.com/bkentel/Cataclysm-DDA.git","svn_url":"https://github.com/bkentel/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":344170,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CleverRaven:master","ref":"master","sha":"5c5ba93e9cb3d99349f7aee556cfb162f6d87ce7","user":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"repo":{"id":5973855,"name":"Cataclysm-DDA","full_name":"CleverRaven/Cataclysm-DDA","owner":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":false,"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","forks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/{number}","contents_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/releases{/id}","created_at":"2012-09-26T22:57:43Z","updated_at":"2015-01-23T03:35:19Z","pushed_at":"2015-01-23T03:35:19Z","git_url":"git://github.com/CleverRaven/Cataclysm-DDA.git","ssh_url":"git@github.com:CleverRaven/Cataclysm-DDA.git","clone_url":"https://github.com/CleverRaven/Cataclysm-DDA.git","svn_url":"https://github.com/CleverRaven/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":414470,"stargazers_count":572,"watchers_count":572,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":634,"mirror_url":null,"open_issues_count":787,"forks":634,"open_issues":787,"watchers":572,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/10971"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10971"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10971/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971/comments"},"review_comment":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/10971/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/ce8c3157bb543feb7f8a0b36ce1c411ea2e0b284"}}}}