On Mon, 10 Dec 2012 17:05:42 -0200 Gustavo Sverzut Barbieri <barbi...@profusion.mobi> said:
> Raster, > > Wouldn't be nice to expose this in eina as this is a common problem? > We use mktemps() when possible, or use some other technique like ou > did if not? problem is portability of mkstemps.. so yes - a portable solution that allows for an "arbitrary" string with any part "replaceable" would be nice in eina. > Also would be nice to use $XDG_RUNTIME_DIR if possible. This envvar is > set with an user-scope, then it's safe by nature to store stuff in > there. Currently just systemd implements, but it should be trivial to > add this to other systems. > http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html > What systemd does is just mkdir /run/user/$UID as 0700 in a tmpfs, > then export XDG_RUNTIME_DIR=/run/user/$UID. People could easily do an > work around for /home/$USER/.tmp or use systemd's approach. i guess this is another alternative to a tmpdir. its just an alternative to /tmp. we should/could have this a s a general eina helper call.. "give ma a unique tmp file thanks... and the fd too thanks"... in fact it possibly should allow for also giving u not just a file, but a fifo, a socket or even a shm file too - so u'd want type too. either that or you want a unique tmp DIR in which to create these new unique file types... up for debate. it's the same need either way. > On Mon, Dec 10, 2012 at 5:13 AM, Enlightenment SVN > <no-re...@enlightenment.org> wrote: > > Log: > > actually us fdopen and hex, and random numbers for tmp shot file. > > > > > > > > Author: raster > > Date: 2012-12-09 23:13:55 -0800 (Sun, 09 Dec 2012) > > New Revision: 80571 > > Trac: http://trac.enlightenment.org/e/changeset/80571 > > > > Modified: > > trunk/e/src/modules/shot/e_mod_main.c > > > > Modified: trunk/e/src/modules/shot/e_mod_main.c > > =================================================================== > > --- trunk/e/src/modules/shot/e_mod_main.c 2012-12-10 07:02:32 UTC > > (rev 80570) +++ trunk/e/src/modules/shot/e_mod_main.c 2012-12-10 > > 07:13:55 UTC (rev 80571) @@ -431,11 +431,22 @@ > > Evas_Coord mw, mh; > > char buf[PATH_MAX]; > > FILE *f; > > + int i, fd = -1; > > > > - if (quality == 100) snprintf(buf, sizeof(buf), > > "/tmp/e-shot-XXXXXX.png"); > > - else snprintf(buf, sizeof(buf), "/tmp/e-shot-XXXXXX.jpg"); > > - if (!mkstemps(buf, 4)) > > + srand(time(NULL)); > > + for (i = 0; i < 10240; i++) > > { > > + int v = rand(); > > + > > + if (quality == 100) > > + snprintf(buf, sizeof(buf), "/tmp/e-shot-%x.png", v); > > + else > > + snprintf(buf, sizeof(buf), "/tmp/e-shot-%x.jpg", v); > > + fd = open(buf, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); > > + if (fd >= 0) break; > > + } > > + if (fd < 0) > > + { > > e_util_dialog_show(_("Error - Can't create file"), > > _("Cannot create temporary file '%s': %s"), > > buf, strerror(errno)); > > @@ -452,7 +463,7 @@ > > e_object_del(E_OBJECT(win)); > > win = NULL; > > } > > - f = fopen(buf, "rb"); > > + f = fdopen(fd, "rb"); > > if (!f) > > { > > e_util_dialog_show(_("Error - Can't open file"), > > > > > > ------------------------------------------------------------------------------ > > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > > Remotely access PCs and mobile devices and provide instant support > > Improve your efficiency, and focus on delivering more value-add services > > Discover what IT Professionals Know. Rescue delivers > > http://p.sf.net/sfu/logmein_12329d2d > > _______________________________________________ > > enlightenment-svn mailing list > > enlightenment-...@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > > > -- > Gustavo Sverzut Barbieri > http://profusion.mobi embedded systems > -------------------------------------- > MSN: barbi...@gmail.com > Skype: gsbarbieri > Mobile: +55 (19) 9225-2202 > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) ras...@rasterman.com ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel