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

Imran Rafique imran at rafique.org
Thu Jul 27 15:50:53 PDT 2023


Juan,

Thanks for taking the time to point me in the right direction. Much
appreciated. Yes, lots I hadn't thought of.

Just one question: in Cuis, do you prefer to not have specific Error
subclasses and just call 'self error:' ?


On Thu, Jul 27, 2023, 1:27 PM Juan Vuletich <juan at cuis.st> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230727/4620c75c/attachment.htm>


More information about the Cuis-dev mailing list