From: Rory Y. <ror...@gm...> - 2014-03-05 12:50:38
|
[sent to Yasuhiro not list...] Hi Yasuhiro, How about this instead? diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c index b5b2975..23c645f 100644 --- a/src/itdb_sqlite.c +++ b/src/itdb_sqlite.c @@ -2278,8 +2278,9 @@ int itdb_sqlite_generate_itdbs(FExport *fexp) tzoffset = fexp->itdb->tzoffset; - tmpdir = g_build_path(g_get_tmp_dir(), tmpnam(NULL), NULL); - if (g_mkdir(tmpdir, 0755) != 0) { + tmpdir = g_build_path(G_DIR_SEPARATOR_S, g_get_tmp_dir(), "libgpod.XXXXXX", NULL); + + if (!g_mkdtemp(tmpdir)) { g_set_error (&fexp->error, G_FILE_ERROR, g_file_error_from_errno(errno), "Could not create temporary directory '%s': %s", tmpdir, strerror(errno)); mkstemp() creates a temporary file and returns its file-handle, according to https://developer.gnome.org/glib/2.37/glib-File-Utilities.html#g-mkstemp (and, I think, in common with typical mkstemp() implementations). Your patch caused libgpod.BLAH files to be created in the CWD, as well as /tmp/libgpod.BLAH to be created. It looks like mkdtemp() is what we want, though I see there's a g_dir_make_tmp() too. I don't know if this will work on Windows, but I imagine it should. Regards, Rory Yasuhiro MATSUMOTO <mat...@gm...> writes: > Hi. > > libgpod manipulate sqlite3 db in temporary directory. But the temporary > directory is unexpected. > > tmpdir = g_build_path(g_get_tmp_dir(), tmpnam(NULL), NULL); > > This doesn't work correctly. IFAIK, g_build_path take path separator for > first argument. And if want to make temporary directory, it should be call > like follow. > > tmpdir = g_build_path(G_DIR_SEPARATOR_S, g_get_tmp_dir(), ...); > > I noticed one more bug. tmpnam(NULL) returns full path string on POSIX > environment. For example: > > UNIX: > ex: /tmp/a2aja35 > > Windows: > ex: \2s5s. > > I guess that this is not expected. Below is a patch. Please check and > include. > BTW, Right now, I came to be able to transfer the music in windows with > this patch. :) > > https://gist.github.com/mattn/9345867 > > > -- > - Yasuhiro Matsumoto > ------------------------------------------------------------------------------ > Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. > With Perforce, you get hassle-free workflows. Merge that actually works. > Faster operations. Version large binaries. Built-in WAN optimization and the > freedom to use Git, Perforce or both. Make the move to Perforce. > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk > _______________________________________________ > Gtkpod-devel mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtkpod-devel |