forked from HelenOS/helenos
-
Notifications
You must be signed in to change notification settings - Fork 1
Wildcards #20
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
PatrikPrit15
wants to merge
20
commits into
vhotspur:master
Choose a base branch
from
PatrikPrit15:master
base: master
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
Wildcards #20
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a2fcac2
wildcards add
PatrikPrit15 daeb19d
wildcards change to recursive
PatrikPrit15 2a0d31b
wildcards incorporation to bdsh
PatrikPrit15 a093644
code clean up
PatrikPrit15 b99bf62
code clean up
PatrikPrit15 bd4cf82
code clean up+tests
PatrikPrit15 10df7d7
add ? support+test
PatrikPrit15 eb7bbae
add utf8 support+test
PatrikPrit15 0cc61c1
memfix utf8
PatrikPrit15 3037d4f
add auto tests 4 expansions
PatrikPrit15 f31a0d9
return fixes, clean up, issue resolves
PatrikPrit15 5fce45f
calback rename 4 clarity
PatrikPrit15 e9b9bbb
tests structure change
PatrikPrit15 ed2ce51
recursive matching+tests
PatrikPrit15 46bd0aa
copyright and readme
PatrikPrit15 5921605
Update info.md
PatrikPrit15 6d3a5c9
Update info.md
PatrikPrit15 1840002
change wildcards lib structure
PatrikPrit15 57f610e
change freeing and include in test
PatrikPrit15 a6b8987
wildcards readme add czech version
PatrikPrit15 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 |
|---|---|---|
|
|
@@ -122,6 +122,8 @@ libs = [ | |
|
|
||
| 'ui', | ||
| 'vt', | ||
|
|
||
| 'wildcards', | ||
| ] | ||
|
|
||
| # Generated list of include directory paths | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright (c) 2025 Patrik Pritrsky | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * - Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * - The name of the author may not be used to endorse or promote products | ||
| * derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #ifndef MAIN_H | ||
| #define MAIN_H | ||
| #include <stdbool.h> | ||
|
|
||
| typedef errno_t (*wildcards_match_found_callback_t)(char *, void *arg); | ||
|
|
||
|
|
||
| bool contains_wildcard(const char *pattern); | ||
| errno_t wildcard_comp(const char *pattern, const char *file_name, bool *result); | ||
| errno_t expand_wildcard_patterns(const char *pattern, const char *path, wildcards_match_found_callback_t callback, void* arg); | ||
|
|
||
| #endif // MAIN_H |
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Wildcard support for HelenOS - MSoC Project by Patrik Pritrsky | ||
|
|
||
| In this project, I added support for wildcards in the HelenOS shell. | ||
| So, if the user wants to delete all text files in a directory, they just | ||
| need to type 'rm *.txt', instead of listing them all one by one. | ||
|
|
||
| ## Features | ||
|
|
||
| ### Standard wildcard * | ||
|
|
||
| Expands to zero or more characters, evaluation happens recursively at | ||
| all levels where it occurs. | ||
|
|
||
| For example, 'folder*/file*.txt' will find all text files starting with | ||
| 'file', in all subdirectories of the current directory that start with | ||
| 'folder'. | ||
|
|
||
| ### Recursive wildcard ** | ||
|
|
||
| Used to find files at arbitrary depth. | ||
|
|
||
| For example, '**/*.txt' will find all text files, at any depth within | ||
| the current directory. | ||
|
|
||
| ## List of changes to HelenOS | ||
|
|
||
| - Added automated tests for wildcards | ||
| - Created a function to detect whether a string contains a wildcard | ||
| - Created a function to check whether a wildcard pattern matches a | ||
| file/directory name | ||
| - Created a function for recursive expansion and finding all | ||
| occurrences of files/directories that match a path/filename containing | ||
| wildcards | ||
| - Modified the HelenOS shell tokenizer to support wildcard expansion | ||
|
|
||
| # Podpora zástupných znaků (wildcards) v HelenOSím shellu - MSoC Project by Patrik Pritrsky | ||
|
|
||
| V tomto projekte som pridal podporu pre zástupné znaky (wildcards) v HelenOS shelle. | ||
| Teda, ak používateľ bude chcieť vymazať všetky textové súbory v priečinku, | ||
| tak mu stačí napísať 'rm *.txt', namiesto toho, aby ich všetky vymenoval. | ||
|
|
||
| ## Funkcie | ||
|
|
||
| ### Štandardný zástupný znak/wildcard * | ||
|
|
||
| Expanduje sa na nula alebo viacero znakov, | ||
| vyhodnocovanie prebieha rekurzívne na všetkých úrovniach, kde sa nachádza. | ||
|
|
||
| Teda napríklad 'priecinok*/subor*.txt', nájde všetky textové súbory začínajúce sa na 'subor', | ||
| vo všetkých podprečinkoch aktuálneho priečinku začínajúcich sa na 'priecinok'. | ||
|
|
||
| ### Rekurzívny zástupný znak/wildcard ** | ||
|
|
||
| Funguje na nájdenie súborov, ktoré sú ľubovoľne hlboko. | ||
|
|
||
| Teda napríklad '**/*.txt', nájde všetky textové súbory, ľubovoľne hlboko v aktuálnom priečinku. | ||
|
|
||
| ## Zoznam zmien do HelenOS | ||
|
|
||
| - Pridanie automatizovaných testov pre zástupné znaky | ||
| - Vytvorenie funkcie na detekovanie, či reťazec obsahuje zástupný znak | ||
| - Vytvorenie funkcie na porovnanie, či sa zástupný znak pattern zhoduje s názvom súboru/priečinku | ||
| - Vytvorenie funkcie na rekurzívne expandovanie a nájdenie všetkých výskytov súborov/priečinkov, | ||
| ktoré sa zhodujú s cestou/názvom súboru obsahujúcim zástupné znaky | ||
| - Zmena v tokenizátore HelenOS shellu, tak, aby podporoval expanziu zástupných znakov |
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # | ||
| # Copyright (c) 2025 Patrik Pritrsky | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # | ||
| # - Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # - Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # - The name of the author may not be used to endorse or promote products | ||
| # derived from this software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| # | ||
|
|
||
| src = files(['src/wildcards.c']) | ||
|
|
||
| test_src = files(['test/wildcards_test.c', 'src/wildcards.c']) |
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.
Uh oh!
There was an error while loading. Please reload this page.