From 984979566181ef0eced18a59f014c18fe7bc33d7 Mon Sep 17 00:00:00 2001 From: keescook Date: Sun, 17 Feb 2008 01:40:25 +0000 Subject: [PATCH] fixups for previous OCAL tempfile wranglings --- src/ui/dialog/ocaldialogs.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 0c20ffa43..dfeea700b 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -278,15 +278,20 @@ void FileListViewText::on_cursor_changed() GnomeVFSResult result; guint8 buffer[8192]; + // FIXME: this would be better as a per-user OCAL cache of files + // instead of filling /tmp with downloads. + // // create file path - const std::string tmptemplate = "ocal-XXXXXX"; + const std::string tmptemplate = "ocal-"; std::string tmpname; int fd = Glib::file_open_tmp(tmpname, tmptemplate); if (fd<0) return; close(fd); - Glib::ustring myFilename = Glib::path_get_dirname(tmpname); - myFilename.append(G_DIR_SEPARATOR_S); + // make sure we don't collide with other users on the same machine + Glib::ustring myFilename = tmpname; + myFilename.append("-"); myFilename.append(get_text(posArray[0], 2)); + // rename based on original image's name, retaining extension if (rename(tmpname.c_str(),myFilename.c_str())<0) { unlink(tmpname.c_str()); g_warning("Error creating destination file '%s': %s", myFilename.c_str(), strerror(errno)); -- 2.30.2