Resource

From Visual DialogShell Wiki
Jump to navigation Jump to search
function resource ($a,$b,$c) {
       switch ($a) {
           load{
               return [Byte[]](resource decode (get-content $b))
           }
           import{
               $import = [System.IO.File]::ReadAllBytes($b)
               return [System.Convert]::ToBase64String($import)
           }
           export{
               $export = [System.Convert]::FromBase64String($b)
               [System.IO.File]::WriteAllBytes($c,$export)
           }
           asciiencode{
               $enc = [system.Text.Encoding]::ASCII
               return [System.Convert]::ToBase64String($enc.GetBytes($b))
           }
           asciidecode{
               $decode = [System.Convert]::FromBase64String($b)
               return [System.Text.Encoding]::ASCII.GetString($decode)
           }
           decode {
               return [System.Convert]::FromBase64String($b)
               #although this works, it returns a system object, which is not usable. We need raw. Not sure how to fix.
           }
   }
<#
   .SYNOPSIS
   Comment
    
   .DESCRIPTION
    VDS
   
       $resource = resource load .\resource.res
           #imports and decodes a base64 encoded file

       $resource = resource import .\resource.ico
           #import a resource directly from file, imports to base64

       resource export $resource .\resource.res
           #Exports a resource to a base64 encoded file
	
       $encode = resource asciiencode "this string"

       $decode = resource asciidecode "dGhpcyBzdHJpbmc="

       $decode = resource decode $resrouce #not working yet I think

   .LINK
   https://dialogshell.com/vds/help/index.php/resource
#>
}