-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
New+ Support for variables in template filenames (35287) #37074
Open
cgaarden
wants to merge
19
commits into
microsoft:main
Choose a base branch
from
cgaarden:New+feature-35287-support-for-variables-in-templates
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.
+591
−97
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bd175a2
Add variable support - initial version without UI
cgaarden 7e36a23
Add variable in template filename support in New+
cgaarden 0f5a8ed
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden bb3c47d
Merge remote-tracking branch 'upstream/main' into New+feature-35287-s…
cgaarden b7bf769
Several little fixes
cgaarden e3824f4
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden bd13af1
Merge remote-tracking branch 'upstream/main' into New+feature-35287-s…
cgaarden cca4878
New+feature-35287-support-for-variables-in-templates
cgaarden 1fc8d65
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden 51ca5b8
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden ba4f07e
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden a8b6a1c
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden 81240c3
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden 0b41e5b
Merge remote-tracking branch 'upstream/main' into New+feature-35287-s…
cgaarden d40aae2
Merge branch 'microsoft:main' into New+feature-35287-support-for-vari…
cgaarden 1b2d01d
Merge remote-tracking branch 'upstream/main' into New+feature-35287-s…
cgaarden b9be940
Merge branch 'New+feature-35287-support-for-variables-in-templates' o…
cgaarden 6b1f684
Merge branch 'main' into pr37074
jaimecbernardo 643bec6
Fix XAML style
jaimecbernardo 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 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 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 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 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 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 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 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 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 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 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 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 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
59 changes: 59 additions & 0 deletions
59
src/modules/NewPlus/NewShellExtensionContextMenu/helpers_filesystem.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
|
||
#include "helpers_variables.h" | ||
|
||
namespace newplus::helpers::filesystem | ||
{ | ||
namespace constants::non_localizable | ||
{ | ||
constexpr WCHAR desktop_ini_filename[] = L"desktop.ini"; | ||
} | ||
|
||
inline bool is_hidden(const std::filesystem::path path) | ||
{ | ||
const std::filesystem::path::string_type name = path.filename(); | ||
if (name == constants::non_localizable::desktop_ini_filename) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
inline bool is_directory(const std::filesystem::path path) | ||
{ | ||
const auto entry = std::filesystem::directory_entry(path); | ||
return entry.is_directory(); | ||
} | ||
|
||
inline std::wstring make_valid_filename(const std::wstring& string, const wchar_t replace_with = L' ') | ||
{ | ||
// replace all non-filename-valid chars with replace_with wchar | ||
std::wstring valid_filename = string; | ||
|
||
std::replace_if(valid_filename.begin(), valid_filename.end(), [](wchar_t c) { return c == L'/' || c == L'\\' || c == L':' || c == L'*' || c == L'?' || c == L'"' || c == L'<' || c == L'>' || c == L'|'; }, replace_with); | ||
|
||
return valid_filename; | ||
} | ||
|
||
inline std::wstring make_unique_path_name(const std::wstring& initial_path) | ||
{ | ||
std::filesystem::path folder_path(initial_path); | ||
std::filesystem::path path_based_on(initial_path); | ||
|
||
int counter = 1; | ||
|
||
while (std::filesystem::exists(folder_path)) | ||
{ | ||
std::wstring new_filename = path_based_on.stem().wstring() + L" (" + std::to_wstring(counter) + L")"; | ||
if (path_based_on.has_extension()) | ||
{ | ||
new_filename += path_based_on.extension().wstring(); | ||
} | ||
folder_path = path_based_on.parent_path() / new_filename; | ||
counter++; | ||
} | ||
|
||
return folder_path.wstring(); | ||
} | ||
} |
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.
Why is this string removed? I suspect a bad merge.