On Sat, Oct 2, 2010 at 11:41 AM, Gustavo Sverzut Barbieri
<[email protected]> wrote:
> On Sat, Oct 2, 2010 at 8:34 AM, Carsten Haitzler <[email protected]> wrote:
>> On Wed, 29 Sep 2010 05:53:04 -0300 Gustavo Sverzut Barbieri
>> <[email protected]> said:
>>
>> the attached is what i was thinking of
>
> Did you actually try my code? It does exactly the same as you want,
> but does not rely on ugly enumerates and thus allows extensions like
> themes and so on.
>
> Okay, the names are different, you call it "seed" and "argv0" while I
> call them "populate_from" and "namespace".
>
> From your idea I just lack the "seed_envs", which I said in my initial mail.
>
> My code even did auto-detection of posix compliant file hierarchy by
> checking if one's symbol/argv0 is in one of bin/ share/ lib/ libexec/
> ... and in that case registers the root (ie: /usr/bin/app register
> /usr that in turn can find out include/, share/ ...)
>
> So yeah, if you wish I can rename to seed and add couple of #define
> ECORE_RESOURCE_LIB "lib", but i guess it's not required.
>
> I also clear distinction of app and system, as I guess it is better
> than trying to mix them all, but I could do ecore_app_resource_*
> fallback to ecore_sys_resource_* if it did not find.
>
> Anyway, I guess you just have something in your mind already and
> instead of trying to understand what you did you just want me to
> exactly what you wondered even if it is not the best solution.

See the following example based on yours:

int
main(int argc, char **argv)
{
   Eina_List *lst;

   ecore_init();

   ecore_app_args_set(argc, argv); // sets namespace to argv[0]
automatically populates from its path, looking into $PATH as well.

   // TODO: ecore_resource_seed_envs(NULL, "APPNAME");

#ifdef PACKAGE_PREFIX
   ecore_app_resource_dir_append(PACKAGE_PREFIX);
#endif

   // no fixed enum, free-form categories (usually: bin, includes, ...)
   // categories are layered on top of this with combinations of
namespace and category!
   // so it get $PREFIX/$NS/$CAT, $PREFIX/$CAT/$NS, ...
   printf("theme: %s\n", ecore_app_resource_get("themes", "default.edj"));
   lst = ecore_app_resource_get_all("themes", "default.edj");
   if (lst)
     {
        const Eina_List *l;
        const char *path;

        printf("all entries:\n");
        EINA_LIST_FOREACH(lst, l, path)
          printf("\t'%s'\n", path);
        ecore_resource_list_free(lst);
     }

   ecore_shutdown();
}


I did not cover "get dir", if you find it useful I can do in the same
way as file lookup, but we should ask for resources as the best one is
looked (app may prepend/append dirs dynamically, based on its own
configuration), and we ensure we return a valid (access(path, R_OK))
path, that way we avoid apps having to do snprintf() + lots of
duplicated work to get usable values.

I based my design use cases around apps that want to find default
configurations, themes and so on. My initial code already feeds some
platform dependent paths for system (/usr, /usr/local), but we could
later on have them in configuration file. We could also consider XDG
paths and for apps even add ~/.config/$NAMESPACE as it is the
recommended place to store configuration files.

One thing that is missing is the resource_get_arch that would look for
that with linux-gnu-i686 and like.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to