[Cuis-dev] fix for leading tilda in DirectoryEntry, or am I going about this the wrong way?

Juan Vuletich juan at cuis.st
Thu Jul 27 13:26:45 PDT 2023


Hi Imran,

There are a few issues with your change set.
- It breaks paths like '../../stuff' .The loop was there for a reason.
- Even with OSProcess it is possible that the $HOME variable is not defined.
- Holding a workaround folder in a class variable can be problematic, 
especially if the image is saved. Or if OSProcess is loaded after this. 
It can also hide this problem for other code that asks for a folder.

I pushed instead a different implementation that addresses this issues, 
as update #5898.

To handle the situation you can do something like

[ '~/Toto' asDirectoryEntry ] on: Error do: [ :error | error description 
print. error retryUsing: '/elToto' asDirectoryEntry ]

Having the description of the error in available in a method lets you 
validate the kind of error, to be sure.

Finally, to test base image functionality, a change set to be loaded in 
BaseImageTests is OK. If you also want to test the behavior with 
OSProcess loaded, another test for the OSProcess package is an 
alternative. In that test, don't forget to test that the HOME variable 
can be resolved, and do nothing if not. Otherwise the test will fail in 
some environments (I can think of Windows, but I'm sure there are others 
where HOME is not an environment variable).

Thanks,

On 7/27/2023 11:07 AM, Imran Rafique via Cuis-dev wrote:
> Juan&  Hernan,
>
> I **think** the attached changeset does what you wanted. I may have
> overcomplicated things somewhat, but in any case, its a great learning
> experience.
>
>
> Gives an exception if OSProcess is not available:
>
>      '~/foo' asFileEntry.
>
>
> Sets a default homedir in case we cannot read environment variables:
>
>      [ '~/foo' asDirectoryEntry ] on: NeedsPackage do: [ :ex |
> FileIOAccessor homeDirDefault: '/home/guess'. ex retry ]
>
>
> BTW, whats the preferred way of including tests for changesets like this?
>
> --
> Regards,
>         Imran Sher Rafique

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich



More information about the Cuis-dev mailing list