Skip to content
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

Shell: renamed all FS functions to align with new findings #9

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@



function HestiaKERNEL-Get-Files-FS {
function HestiaKERNEL-FS-Get-Files {
param (
[string]$___directory,
[string]$___filter,
Expand All @@ -24,31 +24,31 @@ function HestiaKERNEL-Get-Files-FS {


# validate input
if ($(HestiaKERNEL-Is-Directory-FS $___directory) -ne ${env:HestiaKERNEL_ERROR_OK}) {
if ($(HestiaKERNEL-FS-Is-Directory $___directory) -ne ${env:HestiaKERNEL_ERROR_OK}) {
return [string[]]@()
}


# execute
[System.Collections.Generic.List[string]]$___list = @()
foreach ($____item in (Get-ChildItem $___directory)) {
if ($(HestiaKERNEL-Is-Directory-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) {
if ($(HestiaKERNEL-FS-Is-Directory $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) {
if ($___recursive -eq 0) {
continue
} elseif ($___recursive -gt 0) {
$___results = HestiaKERNEL-Get-Files-FS $____item.FullName `
$___results = HestiaKERNEL-FS-Get-Files $____item.FullName `
$___filter `
($___recursive - 1)
} else {
$___results = HestiaKERNEL-Get-Files-FS $____item.FullName `
$___results = HestiaKERNEL-FS-Get-Files $____item.FullName `
$___filter `
-1
}

foreach ($___result in $___results) {
$___list.Add($___result)
}
} elseif ($(HestiaKERNEL-Is-File-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) {
} elseif ($(HestiaKERNEL-FS-Is-File $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) {
if ($____item.Name -like "*${___filter}*") {
$___list.Add($____item.FullName)
}
Expand Down
12 changes: 6 additions & 6 deletions Shell/libraries/HestiaKERNEL/FS/Get_Files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@



HestiaKERNEL_Get_Files_FS() {
HestiaKERNEL_FS_Get_Files() {
#___directory="$1"
#___filter="$2"
#___recursive="$3"


# validate input
if [ $(HestiaKERNEL_Is_Directory_FS "$1") -ne $HestiaKERNEL_ERROR_OK ]; then
if [ $(HestiaKERNEL_FS_Is_Directory "$1") -ne $HestiaKERNEL_ERROR_OK ]; then
printf -- ""
return $HestiaKERNEL_ERROR_ENTITY_INVALID
fi


# execute
for ____item in "$1"/*; do
if [ $(HestiaKERNEL_Is_Directory_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then
if [ $(HestiaKERNEL_FS_Is_Directory "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then
if [ $(HestiaKERNEL_Is_Number "$3") -ne $HestiaKERNEL_ERROR_OK ]; then
continue
fi

if [ $3 -eq 0 ]; then
continue
elif [ $3 -gt 0 ]; then
HestiaKERNEL_Get_Files_FS "$____item" "$2" "$(($3 - 1))"
HestiaKERNEL_FS_Get_Files "$____item" "$2" "$(($3 - 1))"
else
HestiaKERNEL_Get_Files_FS "$____item" "$2" "$3"
HestiaKERNEL_FS_Get_Files "$____item" "$2" "$3"
fi
elif [ $(HestiaKERNEL_Is_File_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then
elif [ $(HestiaKERNEL_FS_Is_File "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then
____filename="${____item##*/}"

if [ "$2" = "" ]; then
Expand Down
2 changes: 1 addition & 1 deletion Shell/libraries/HestiaKERNEL/FS/Is_Directory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



function HestiaKERNEL-Is-Directory-FS {
function HestiaKERNEL-FS-Is-Directory {
param (
[string]$___target
)
Expand Down
2 changes: 1 addition & 1 deletion Shell/libraries/HestiaKERNEL/FS/Is_Directory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@



HestiaKERNEL_Is_Directory_FS() {
HestiaKERNEL_FS_Is_Directory() {
#___target="$1"


Expand Down
2 changes: 1 addition & 1 deletion Shell/libraries/HestiaKERNEL/FS/Is_File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



function HestiaKERNEL-Is-File-FS {
function HestiaKERNEL-FS-Is-File {
param (
[string]$___target
)
Expand Down
2 changes: 1 addition & 1 deletion Shell/libraries/HestiaKERNEL/FS/Is_File.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@



HestiaKERNEL_Is_File_FS() {
HestiaKERNEL_FS_Is_File() {
#___target="$1"


Expand Down
2 changes: 1 addition & 1 deletion Shell/shell/init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $null = New-Item -Path ${env:DIR_TEMP} -ItemType Directory -Force

# source all init scripts if available
if (Test-Path -Path "${env:DIR_WORKSPACE}\init" -PathType Container) {
foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\init" ".ps1")) {
foreach ($___script in $(HestiaKERNEL-FS-Get-Files "${env:DIR_WORKSPACE}\init" ".ps1")) {
$null = Write-Host "Sourcing ${___script} ..."
$___process = . $___script
if ($___process -ne 0) {
Expand Down
4 changes: 2 additions & 2 deletions Shell/shell/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export DIR_TEMP="${DIR_WORKSPACE}/temp"



# setup locale
# import required libraries
___old_IFS="$IFS"
while IFS="" read -r ___line || [ -n "$___line" ]; do
if [ ! -f "$___line" ]; then
Expand All @@ -52,7 +52,7 @@ mkdir -p "$DIR_TEMP"

# source all init scripts if available
if [ -d "${DIR_WORKSPACE}/init" ]; then
for ___script in $(HestiaKERNEL_Get_Files_FS "${DIR_WORKSPACE}/init" ".sh"); do
for ___script in $(HestiaKERNEL_FS_Get_Files "${DIR_WORKSPACE}/init" ".sh"); do
if [ ! -f "$___script" ]; then
continue
fi
Expand Down
19 changes: 15 additions & 4 deletions Shell/shell/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ if ($___process -ne 0) {


# import required libraries
. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Codes.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Exec_Test_Case.ps1"
foreach ($___line in @(
"${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\Unicode\Init.ps1",
"${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\FS\Get_Files.ps1",
"${env:LIBS_HESTIA}\HestiaKERNEL\Test\Codes.ps1",
"${env:LIBS_HESTIA}\HestiaKERNEL\Test\Exec_Test_Case.ps1"
)) {
$null = Write-Host "Importing '${___line}' ..."
if (-not (Test-Path $___line)) {
$null = Write-Host "[ ERROR ] Missing library."
return 1
}

$null = . $___line
}



Expand All @@ -37,7 +48,7 @@ if (Test-Path -Path "${env:DIR_WORKSPACE}\tests" -PathType Container) {
foreach (
$___script
in
$(HestiaKERNEL-Get-Files-FS "${env:DIR_WORKSPACE}\tests" ".ps1" -1)
$(HestiaKERNEL-FS-Get-Files "${env:DIR_WORKSPACE}\tests" ".ps1" -1)
) {
# increase total count
$___scripts_total += 1
Expand Down
20 changes: 17 additions & 3 deletions Shell/shell/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,22 @@ fi


# import required libraries
. "${LIBS_HESTIA}/HestiaKERNEL/Test/Codes.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Test/Exec_Test_Case.sh"
___old_IFS="$IFS"
while IFS="" read -r ___line || [ -n "$___line" ]; do
1>&2 printf -- "Importing '${___line}' ...\n"
if [ ! -f "$___line" ]; then
1>&2 printf -- "[ ERROR ] Missing library.\n"
return 1
fi

. "$___line"
done <<EOF
${LIBS_HESTIA}/HestiaKERNEL/Unicode/Init.sh
${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh
${LIBS_HESTIA}/HestiaKERNEL/Test/Codes.sh
${LIBS_HESTIA}/HestiaKERNEL/Test/Exec_Test_Case.sh
EOF
IFS="$___old_IFS" && unset ___old_IFS



Expand All @@ -34,7 +48,7 @@ ___scripts_total=0
___scripts_passed=0
___only_failed="" # value: 'true' (string)
if [ -d "${DIR_WORKSPACE}/tests" ]; then
for ___script in $(HestiaKERNEL_Get_Files_FS "${DIR_WORKSPACE}/tests" ".sh" "-1"); do
for ___script in $(HestiaKERNEL_FS_Get_Files "${DIR_WORKSPACE}/tests" ".sh" "-1"); do
# increase total count
___scripts_total=$(($___scripts_total + 1))

Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/0.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
$null = Write-Host @"
TEST CASE :
HestiaKERNEL-Get-Files
HestiaKERNEL-FS-Get-Files

DESCRIPTION:
Function can get all files.
Expand Down Expand Up @@ -42,7 +42,7 @@ if (-not (Test-Path -Path $___target)) {

$null = Write-Host "Import function library..."
$null = . $___target
if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) {
if (-not (Get-Command 'HestiaKERNEL-FS-Get-Files' -errorAction SilentlyContinue)) {
$null = Write-Host "[ FAILED ] error on import!`n"
exit 1
}
Expand All @@ -52,7 +52,7 @@ if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)

$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS"
$___expect = ""
$___output = HestiaKERNEL-Get-Files-FS $___input
$___output = HestiaKERNEL-FS-Get-Files $___input
$null = Write-Host "Given input :`n|${___input}|`n"
$null = Write-Host "Given expect :`n|not empty|`n"
$null = Write-Host "Got Output :`n|${___output}|`n"
Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
1>&2 printf -- "%s\n" "\
TEST CASE :
HestiaKERNEL_Get_Files
HestiaKERNEL_FS_Get_Files

DESCRIPTION:
Function can get all files.
Expand Down Expand Up @@ -41,7 +41,7 @@ fi

1>&2 printf -- "Import function library...\n"
. "$___target"
___target="$(type HestiaKERNEL_Get_Files_FS)"
___target="$(type HestiaKERNEL_FS_Get_Files)"
if [ ! "${___target##*not found}" = "$___target" ]; then
1>&2 printf -- "[ FAILED ] error on import!\n"
exit 1
Expand All @@ -56,7 +56,7 @@ ___input="${LIBS_HESTIA}/HestiaKERNEL/FS"
___expect=""
1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty"

___output="$(HestiaKERNEL_Get_Files_FS "$___input")"
___output="$(HestiaKERNEL_FS_Get_Files "$___input")"
___process=$?
1>&2 printf -- "Given output :\n|%s|\n\n" "$___output"
1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process"
Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
$null = Write-Host @"
TEST CASE :
HestiaKERNEL-Get-Files
HestiaKERNEL-FS-Get-Files

DESCRIPTION:
Function can get all files with specified filter.
Expand Down Expand Up @@ -42,7 +42,7 @@ if (-not (Test-Path -Path $___target)) {

$null = Write-Host "Import function library..."
$null = . $___target
if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) {
if (-not (Get-Command 'HestiaKERNEL-FS-Get-Files' -errorAction SilentlyContinue)) {
$null = Write-Host "[ FAILED ] error on import!`n"
exit 1
}
Expand All @@ -53,7 +53,7 @@ if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)
$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS"
$___input_filter = ".ps1"
$___expect = ""
$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter
$___output = HestiaKERNEL-FS-Get-Files $___input $___input_filter
$null = Write-Host "Given input :`n|${___input}|`n"
$null = Write-Host "Given input filter :`n|${___input_filter}|`n"
$null = Write-Host "Given expect :`n|not empty|`n"
Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
1>&2 printf -- "%s\n" "\
TEST CASE :
HestiaKERNEL_Get_Files
HestiaKERNEL_FS_Get_Files

DESCRIPTION:
Function can get all files with specified filter.
Expand Down Expand Up @@ -41,7 +41,7 @@ fi

1>&2 printf -- "Import function library...\n"
. "$___target"
___target="$(type HestiaKERNEL_Get_Files_FS)"
___target="$(type HestiaKERNEL_FS_Get_Files)"
if [ ! "${___target##*not found}" = "$___target" ]; then
1>&2 printf -- "[ FAILED ] error on import!\n"
exit 1
Expand All @@ -58,7 +58,7 @@ ___input_filter=".sh"
___expect=""
1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty"

___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter")"
___output="$(HestiaKERNEL_FS_Get_Files "$___input" "$___input_filter")"
___process=$?
1>&2 printf -- "Given output :\n|%s|\n\n" "$___output"
1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process"
Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
$null = Write-Host @"
TEST CASE :
HestiaKERNEL-Get-Files
HestiaKERNEL-FS-Get-Files

DESCRIPTION:
Function can get all files with specified filter recursively.
Expand Down Expand Up @@ -42,7 +42,7 @@ if (-not (Test-Path -Path $___target)) {

$null = Write-Host "Import function library..."
$null = . $___target
if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) {
if (-not (Get-Command 'HestiaKERNEL-FS-Get-Files' -errorAction SilentlyContinue)) {
$null = Write-Host "[ FAILED ] error on import!`n"
exit 1
}
Expand All @@ -54,7 +54,7 @@ $___input = ${env:LIBS_HESTIA}
$___input_filter = ".ps1"
$___input_recursive = -1
$___expect = ""
$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive
$___output = HestiaKERNEL-FS-Get-Files $___input $___input_filter $___input_recursive
$null = Write-Host "Given input :`n|${___input}|`n"
$null = Write-Host "Given input filter :`n|${___input_filter}|`n"
$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n"
Expand Down
6 changes: 3 additions & 3 deletions Shell/tests/FS/Get_Files/2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# the permissions and limitations set forth in the license.
1>&2 printf -- "%s\n" "\
TEST CASE :
HestiaKERNEL_Get_Files
HestiaKERNEL_FS_Get_Files

DESCRIPTION:
Function can get all files with specified filter recursively.
Expand Down Expand Up @@ -41,7 +41,7 @@ fi

1>&2 printf -- "Import function library...\n"
. "$___target"
___target="$(type HestiaKERNEL_Get_Files_FS)"
___target="$(type HestiaKERNEL_FS_Get_Files)"
if [ ! "${___target##*not found}" = "$___target" ]; then
1>&2 printf -- "[ FAILED ] error on import!\n"
exit 1
Expand All @@ -60,7 +60,7 @@ ___input_recursive="-1"
___expect=""
1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty"

___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")"
___output="$(HestiaKERNEL_FS_Get_Files "$___input" "$___input_filter" "$___input_recursive")"
___process=$?
1>&2 printf -- "Given output :\n|%s|\n\n" "$___output"
1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process"
Expand Down
Loading
Loading