-
Couldn't load subscription status.
- Fork 269
Remove ddio_MakePath() function usage from code #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
winterheart
wants to merge
11
commits into
DescentDevelopers:main
Choose a base branch
from
winterheart:ddio_makepath_remove
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a7044e4
Fix compilation warnings in misc
winterheart 04e4b49
Change msafe_struct attributes type
winterheart 1287759
Reduce usage of ddio_MakePath()
winterheart 8e19856
Use std::fs::path in functions related to user's custom data
winterheart 54895b3
Rewrite FixFilenameCase() to use std::fs::path
winterheart 0662352
Remove ddio_MakePath() usage in LoadGameDialogCB()
winterheart d82eeda
Remove ddio_*() functions usage in mission_download.cpp
winterheart f556040
Converting most filepaths in manage
winterheart 6c30bc4
Remove ddio_MakePath() from netcon dlls API
winterheart 1ac163f
Remove ddio_MakePath()/ddio_SplitPath() from dmfc dlls API
winterheart cb00ec5
Fix compilation of LevelEditor
winterheart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -119,8 +119,9 @@ | |||||
| */ | ||||||
|
|
||||||
| #include <cstdio> | ||||||
| #include <future> | ||||||
| #include <filesystem> | ||||||
| #include <fstream> | ||||||
| #include <future> | ||||||
|
|
||||||
| #include "mem.h" | ||||||
| #include "args.h" | ||||||
|
|
@@ -673,16 +674,6 @@ char *msn_SecondsToString(int time_sec) { | |||||
| return fmttime; | ||||||
| } | ||||||
|
|
||||||
| void _get_zipfilename(char *output, char *directory, char *zipfilename) { | ||||||
| char *s = strrchr(zipfilename, '/'); | ||||||
| if (s) | ||||||
| s++; | ||||||
| else | ||||||
| s = zipfilename; | ||||||
|
|
||||||
| ddio_MakePath(output, directory, s, NULL); | ||||||
| } | ||||||
|
|
||||||
| // return 0 on failure | ||||||
| // return 1 on success | ||||||
| int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::filesystem::path &mn3name) { | ||||||
|
|
@@ -693,11 +684,9 @@ int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::file | |||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| char mission_directory[_MAX_PATH]; | ||||||
| char output_filename[_MAX_PATH]; | ||||||
| char buffer[256 + 32]; | ||||||
|
|
||||||
| ddio_MakePath(mission_directory, LocalD3Dir, "missions", NULL); | ||||||
| std::filesystem::path mission_directory = std::filesystem::path(LocalD3Dir) / "missions"; | ||||||
|
|
||||||
| // now go through the zip file and extract all the files out that we can | ||||||
| ZIP zfile; | ||||||
|
|
@@ -740,14 +729,15 @@ int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::file | |||||
| console.puts(GR_GREEN, buffer); | ||||||
|
|
||||||
| // create the filename for this file | ||||||
| _get_zipfilename(output_filename, mission_directory, ze->name); | ||||||
| std::filesystem::path output_filename = mission_directory / ze->name; | ||||||
|
|
||||||
| if (cfexist(output_filename)) { | ||||||
| snprintf(buffer, sizeof(buffer), "%s already exists. Overwrite?", output_filename); | ||||||
| snprintf(buffer, sizeof(buffer), "%s already exists. Overwrite?", output_filename.u8string().c_str()); | ||||||
| if (DoMessageBox("Confirm", buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { | ||||||
| // delete the file | ||||||
| LOG_DEBUG.printf("Deleting %s", zipfilename.u8string().c_str()); | ||||||
| if (!ddio_DeleteFile(output_filename)) { | ||||||
| std::error_code ec; | ||||||
| if (!std::filesystem::remove(output_filename, ec)) { | ||||||
| process_file = false; | ||||||
| console.puts(GR_GREEN, "[Unable to Write] "); | ||||||
| } else { | ||||||
|
|
@@ -765,7 +755,7 @@ int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::file | |||||
| DoUIFrame(); | ||||||
| rend_Flip(); | ||||||
|
|
||||||
| int ret = zfile.ExtractFile(ze, output_filename); | ||||||
| int ret = zfile.ExtractFile(ze, output_filename.u8string().c_str()); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (ret < 0) { | ||||||
| if (ret == -9) { | ||||||
| LOG_WARNING << " Error writing to file"; | ||||||
|
|
@@ -776,7 +766,8 @@ int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::file | |||||
| } | ||||||
| console.puts(GR_GREEN, buffer); | ||||||
| if (cfexist(output_filename)) { | ||||||
| ddio_DeleteFile(output_filename); | ||||||
| std::error_code ec; | ||||||
| std::filesystem::remove(output_filename, ec); | ||||||
| } | ||||||
| } else { | ||||||
| // check the CRC | ||||||
|
|
@@ -790,7 +781,8 @@ int msn_ExtractZipFile(const std::filesystem::path &zipfilename, const std::file | |||||
| } | ||||||
| } else { | ||||||
| console.puts(GR_GREEN, "CRC FAIL!"); | ||||||
| ddio_DeleteFile(output_filename); | ||||||
| std::error_code ec; | ||||||
| std::filesystem::remove(output_filename, ec); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use
std::u8string