Added UTF8 international character support for file operations; see issue #413

This commit is contained in:
Oliver Duis
2010-12-18 17:41:03 +01:00
parent 1f2f3b1209
commit 94449dc9e4
29 changed files with 166 additions and 152 deletions

View File

@@ -7,7 +7,7 @@ link_directories (${CMAKE_CURRENT_SOURCE_DIR}/../rtexif ${EXTRA_LIBDIR} ${GTHREA
${GOBJECT_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${GLIBMM_LIBRARY_DIRS}
${IPTCDATA_LIBRARY_DIRS} ${LCMS_LIBRARY_DIRS})
set (RTENGINESOURCEFILES colortemp.cc curves.cc dcraw.cc iccstore.cc dfmanager.cc rawimage.cc
set (RTENGINESOURCEFILES safegtk.cc colortemp.cc curves.cc dcraw.cc iccstore.cc dfmanager.cc rawimage.cc
image8.cc image16.cc imagedata.cc imageio.cc improcfun.cc init.cc dcrop.cc
loadinitial.cc procparams.cc rawimagesource.cc shmap.cc simpleprocess.cc refreshmap.cc
stdimagesource.cc myfile.cc iccjpeg.c hlmultipliers.cc improccoordinator.cc

View File

@@ -427,7 +427,7 @@
+
+ THREAD_LOCK
+
+ ifname = fname.c_str();
+ ifname = safe_locale_from_utf8(fname).c_str();
+ image = NULL;
+ exif_base = -1;
+ ciff_base = -1;
@@ -435,7 +435,7 @@
+ verbose = settings->verbose;
+ oprof = NULL;
+
+ ifp = gfopen (fname.c_str());
+ ifp = gfopen (ifname);
+ if (!ifp)
+ return 3;
+
@@ -641,13 +641,13 @@
+ THREAD_LOCK
+
+ image = NULL;
+ ifname = fname.c_str();
+ ifname = safe_locale_from_utf8(fname).c_str();
+ exif_base = -1;
+ ciff_base = -1;
+ ciff_len = -1;
+ verbose = settings->verbose;
+ oprof = NULL;
+ ifp = gfopen (fname.c_str());
+ ifp = gfopen (ifname);
+ if (!ifp) {
+ printf("DCRAW: failed0\n");
+ return NULL;
@@ -705,13 +705,13 @@
+t0.set ();
+
+ image = NULL;
+ ifname = fname.c_str();
+ ifname = safe_locale_from_utf8(fname).c_str();
+ exif_base = -1;
+ ciff_base = -1;
+ ciff_len = -1;
+ verbose = settings->verbose;
+ oprof = NULL;
+ ifp = gfopen (fname.c_str());
+ ifp = gfopen (ifname);
+ if (!ifp) {
+ return NULL;
+ }

View File

@@ -24,6 +24,7 @@
#endif
#include <iccmatrices.h>
#include <glib/gstdio.h>
#include <safegtk.h>
namespace rtengine {
@@ -137,7 +138,7 @@ cmsHPROFILE ICCStore::getProfile (Glib::ustring name) {
if (r!=fileProfiles.end())
return r->second;
else {
if (!name.compare (0, 5, "file:") && Glib::file_test (name.substr(5), Glib::FILE_TEST_EXISTS) && !Glib::file_test (name.substr(5), Glib::FILE_TEST_IS_DIR)) {
if (!name.compare (0, 5, "file:") && safe_file_test (name.substr(5), Glib::FILE_TEST_EXISTS) && !safe_file_test (name.substr(5), Glib::FILE_TEST_IS_DIR)) {
ProfileContent pc (name.substr(5));
if (pc.data) {
cmsHPROFILE profile = pc.toProfile ();
@@ -171,7 +172,7 @@ std::vector<std::string> ICCStore::parseDir (Glib::ustring pdir) {
Glib::ustring dirname = pdir;
Glib::Dir* dir = NULL;
try {
if (!Glib::file_test (dirname, Glib::FILE_TEST_IS_DIR))
if (!safe_file_test (dirname, Glib::FILE_TEST_IS_DIR))
return result;
dir = new Glib::Dir (dirname);
}
@@ -183,7 +184,7 @@ std::vector<std::string> ICCStore::parseDir (Glib::ustring pdir) {
Glib::ustring fname = dirname + *i;
Glib::ustring sname = *i;
// ignore directories
if (!Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) {
int lastdot = sname.find_last_of ('.');
if (lastdot!=Glib::ustring::npos && lastdot<=(int)sname.size()-4 && (!sname.casefold().compare (lastdot, 4, ".icm") || !sname.casefold().compare (lastdot, 4, ".icc"))) {
// printf ("processing file %s...\n", fname.c_str());
@@ -208,7 +209,7 @@ std::vector<std::string> ICCStore::parseDir (Glib::ustring pdir) {
ProfileContent::ProfileContent (Glib::ustring fileName) {
data = NULL;
FILE* f = g_fopen (fileName.c_str(), "rb");
FILE* f = safe_g_fopen (fileName, "rb");
if (!f)
return;
fseek (f, 0, SEEK_END);

View File

@@ -45,7 +45,7 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) {
#ifdef RAWZOR_SUPPORT
// RAWZOR support begin
if (dotpos<fname.size()-3 && !fname.casefold().compare (dotpos, 4, ".rwz") && ri && (ri->exifBase>=0 || ri->ciffBase>=0)) {
FILE* f = g_fopen (fname.c_str (), "rb");
FILE* f = safe_g_fopen (fname, "rb");
if (f) {
fseek (f, 0, SEEK_END);
int rzwSize = ftell (f);
@@ -66,7 +66,7 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) {
else if (ri->ciffBase>=0)
root = rtexif::ExifManager::parseCIFF (tf, ri->ciffBase, ri->ciffLength);
fclose (tf);
::g_remove (tfname.c_str());
safe_g_remove (tfname);
extractInfo ();
}
delete [] rawData;
@@ -79,7 +79,7 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) {
else
#endif
if (ri && (ri->exifBase>=0 || ri->ciffBase>=0)) {
FILE* f = g_fopen (fname.c_str(), "rb");
FILE* f = safe_g_fopen (fname, "rb");
if (f) {
if (ri->exifBase>=0) {
root = rtexif::ExifManager::parse (f, ri->exifBase);
@@ -96,18 +96,18 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) {
}
}
else if (dotpos<(int)fname.size()-3 && !fname.casefold().compare (dotpos, 4, ".jpg")) {
FILE* f = g_fopen (fname.c_str (), "rb");
FILE* f = safe_g_fopen (fname, "rb");
if (f) {
root = rtexif::ExifManager::parseJPEG (f);
extractInfo ();
fclose (f);
FILE* ff = g_fopen (fname.c_str (), "rb");
FILE* ff = safe_g_fopen (fname, "rb");
iptc = iptc_data_new_from_jpeg_file (ff);
fclose (ff);
}
}
else if ((dotpos<(int)fname.size()-3 && !fname.casefold().compare (dotpos, 4, ".tif")) || (dotpos<fname.size()-4 && !fname.casefold().compare (dotpos, 5, ".tiff"))) {
FILE* f = g_fopen (fname.c_str (), "rb");
FILE* f = safe_g_fopen (fname, "rb");
if (f) {
root = rtexif::ExifManager::parseTIFF (f);
fclose (f);

View File

@@ -130,7 +130,7 @@ void png_flush(png_struct_def *png_ptr);
int ImageIO::loadPNG (Glib::ustring fname) {
FILE *file = g_fopen (fname.c_str(),"rb");
FILE *file = safe_g_fopen (fname,"rb");
if (!file)
return IMIO_CANNOTREADFILE;
@@ -325,7 +325,7 @@ int ImageIO::loadJPEGFromMemory (const char* buffer, int bufsize)
int ImageIO::loadJPEG (Glib::ustring fname) {
FILE *file=g_fopen(fname.c_str(),"rb");
FILE *file=safe_g_fopen(fname,"rb");
if (!file)
return IMIO_CANNOTREADFILE;
@@ -505,7 +505,7 @@ int ImageIO::savePNG (Glib::ustring fname, int compression, int bps) {
Glib::ustring tmpFname=fname;
tmpFname.append(".tmp");
FILE *file = g_fopen (safe_locale_from_utf8(tmpFname).c_str (), "wb");
FILE *file = safe_g_fopen (tmpFname, "wb");
if (!file)
return IMIO_CANNOTREADFILE;
@@ -573,7 +573,7 @@ int ImageIO::savePNG (Glib::ustring fname, int compression, int bps) {
fclose (file);
// Rename temporary filename, practically atomic
g_rename(safe_locale_from_utf8(tmpFname).c_str (),safe_locale_from_utf8(fname).c_str ());
safe_g_rename(tmpFname,fname);
if (pl) {
pl->setProgressStr ("Ready.");
@@ -596,7 +596,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality) {
Glib::ustring tmpFname=fname;
tmpFname.append(".tmp");
FILE *file = g_fopen (safe_locale_from_utf8(tmpFname).c_str (), "wb");
FILE *file = safe_g_fopen (tmpFname, "wb");
if (!file)
return IMIO_CANNOTREADFILE;
@@ -687,7 +687,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality) {
fclose (file);
// Rename temporary filename, practically atomic
g_rename(safe_locale_from_utf8(tmpFname).c_str (),safe_locale_from_utf8(fname).c_str ());
safe_g_rename(tmpFname,fname);
if (pl) {
pl->setProgressStr ("Ready.");
@@ -709,7 +709,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) {
unsigned char* linebuffer = new unsigned char[lineWidth];
// TODO the following needs to be looked into - do we really need two ways to write a Tiff file ?
if (exifRoot && uncompressed) {
FILE *file = g_fopen (safe_locale_from_utf8(fname).c_str (), "wb");
FILE *file = safe_g_fopen (fname, "wb");
if (!file)
return IMIO_CANNOTREADFILE;

View File

@@ -446,7 +446,7 @@ int ProcParams::save (Glib::ustring fname) const {
keyFile.set_string_list ("IPTC", iptc[i].field, values);
}
FILE *f = g_fopen (safe_locale_from_utf8(fname).c_str(), "wt");
FILE *f = safe_g_fopen (fname, "wt");
if (f==NULL)
return 1;
@@ -463,7 +463,7 @@ int ProcParams::load (Glib::ustring fname) {
try {
setDefaults ();
FILE* f = g_fopen (fname.c_str(), "rt");
FILE* f = safe_g_fopen (fname, "rt");
if (!f)
return 1;
char* buffer = new char[1024];

View File

@@ -13,7 +13,7 @@
#else
#include <netinet/in.h>
#endif
#include <safegtk.h>
namespace rtengine{
@@ -128,12 +128,12 @@ skip_block: ;
int RawImage::loadRaw (bool loadData, bool closeFile)
{
ifname = filename.c_str();
ifname = safe_locale_from_utf8(filename).c_str();
image = NULL;
verbose = settings->verbose;
oprof = NULL;
ifp = gfopen (filename.c_str());
ifp = gfopen (ifname);
if (!ifp)
return 3;

View File

@@ -33,6 +33,7 @@
#include <glib/gstdio.h>
#include <setjmp.h>
#include <safekeyfile.h>
#include <safegtk.h>
#include <rawimage.h>
#include "jpeg.h"
@@ -962,7 +963,7 @@ bool Thumbnail::writeImage (const Glib::ustring& fname, int format) {
}
if (format==1) {
FILE* f = g_fopen (fname.c_str(), "wb");
FILE* f = safe_g_fopen (fname, "wb");
if (!f) {
delete [] tmpdata;
return false;
@@ -973,7 +974,7 @@ bool Thumbnail::writeImage (const Glib::ustring& fname, int format) {
fclose (f);
}
else if (format==3) {
FILE* f = g_fopen (fname.c_str(), "wb");
FILE* f = safe_g_fopen (fname, "wb");
if (!f) {
delete [] tmpdata;
return false;
@@ -1018,7 +1019,7 @@ bool Thumbnail::writeImage (const Glib::ustring& fname, int format) {
return true;
}
else if (format==2) {
FILE* f = g_fopen (fname.c_str(), "wb");
FILE* f = safe_g_fopen (fname, "wb");
if (!f)
return false;
fwrite (&thumbImg->width, 1, sizeof (int), f);
@@ -1042,17 +1043,17 @@ bool Thumbnail::readImage (const Glib::ustring& fname) {
thumbImg = NULL;
int imgType = 0;
if (Glib::file_test (fname+".cust16", Glib::FILE_TEST_EXISTS))
if (safe_file_test (fname+".cust16", Glib::FILE_TEST_EXISTS))
imgType = 2;
if (Glib::file_test (fname+".cust", Glib::FILE_TEST_EXISTS))
if (safe_file_test (fname+".cust", Glib::FILE_TEST_EXISTS))
imgType = 1;
else if (Glib::file_test (fname+".jpg", Glib::FILE_TEST_EXISTS))
else if (safe_file_test (fname+".jpg", Glib::FILE_TEST_EXISTS))
imgType = 3;
if (!imgType)
return false;
else if (imgType==1) {
FILE* f = g_fopen ((fname+".cust").c_str(), "rb");
FILE* f = safe_g_fopen (fname+".cust", "rb");
if (!f)
return false;
int width, height;
@@ -1085,7 +1086,7 @@ bool Thumbnail::readImage (const Glib::ustring& fname) {
return true;
}
else if (imgType==2) {
FILE* f = g_fopen ((fname+".cust16").c_str(), "rb");
FILE* f = safe_g_fopen (fname+".cust16", "rb");
if (!f)
return false;
int width, height;
@@ -1102,7 +1103,7 @@ bool Thumbnail::readImage (const Glib::ustring& fname) {
return true;
}
else if (imgType==3) {
FILE* f = g_fopen ((fname+".jpg").c_str(), "rb");
FILE* f = safe_g_fopen (fname+".jpg", "rb");
if (!f)
return false;
struct jpeg_decompress_struct cinfo;
@@ -1200,7 +1201,7 @@ bool Thumbnail::writeData (const Glib::ustring& fname) {
SafeKeyFile keyFile;
try {
if( Glib::file_test(fname,Glib::FILE_TEST_EXISTS) )
if( safe_file_test(fname,Glib::FILE_TEST_EXISTS) )
keyFile.load_from_file (fname);
} catch (...) {}
@@ -1220,7 +1221,7 @@ bool Thumbnail::writeData (const Glib::ustring& fname) {
Glib::ArrayHandle<double> cm ((double*)colorMatrix, 9, Glib::OWNERSHIP_NONE);
keyFile.set_double_list ("LiveThumbData", "ColorMatrix", cm);
FILE *f = g_fopen (fname.c_str(), "wt");
FILE *f = safe_g_fopen (fname, "wt");
if (!f)
return false;
else {

View File

@@ -18,7 +18,7 @@ set (BASESOURCEFILES
histogrampanel.cc history.cc imagearea.cc
imageareapanel.cc iptcpanel.cc labcurve.cc lumadenoise.cc main.cc
multilangmgr.cc mycurve.cc options.cc
preferences.cc profilepanel.cc safegtk.cc saveasdlg.cc
preferences.cc profilepanel.cc saveasdlg.cc
saveformatpanel.cc splash.cc
thumbnail.cc tonecurve.cc toolbar.cc
guiutils.cc zoompanel.cc toolpanelcoord.cc

View File

@@ -91,7 +91,7 @@ bool BatchQueue::saveBatchQueue( )
{
Glib::ustring savedQueueFile;
savedQueueFile = options.rtdir+"/batch/queue";
FILE *f = g_fopen (safe_locale_from_utf8(savedQueueFile).c_str(), "wt");
FILE *f = safe_g_fopen (savedQueueFile, "wt");
if (f==NULL)
return false;
@@ -108,7 +108,7 @@ bool BatchQueue::loadBatchQueue( )
{
Glib::ustring savedQueueFile;
savedQueueFile = options.rtdir+"/batch/queue";
FILE *f = g_fopen (safe_locale_from_utf8(savedQueueFile).c_str(), "rt");
FILE *f = safe_g_fopen (savedQueueFile, "rt");
if (f==NULL)
return false;
@@ -172,7 +172,7 @@ Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring filename
strftime (stringTimestamp,sizeof(stringTimestamp),"_%Y%m%d%H%M%S_",timeinfo);
Glib::ustring savedParamPath;
savedParamPath = options.rtdir+"/batch/";
g_mkdir_with_parents (savedParamPath.c_str(), 0755);
safe_g_mkdir_with_parents (savedParamPath, 0755);
savedParamPath += Glib::path_get_basename (filename);
savedParamPath += stringTimestamp;
savedParamPath += paramFileExtension;
@@ -181,7 +181,7 @@ Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring filename
int deleteitem (void* data)
{
::remove( safe_locale_from_utf8( ((BatchQueueEntry*)data)->savedParamsFile).c_str () );
safe_g_remove( ((BatchQueueEntry*)data)->savedParamsFile );
gdk_threads_enter ();
delete (BatchQueueEntry*)data;
gdk_threads_leave ();
@@ -357,7 +357,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
next->removeButtonSet ();
}
if( saveBatchQueue( ) ){
::remove( safe_locale_from_utf8(processedParams).c_str () );
safe_g_remove( processedParams );
// Delete all files in directory \batch when finished, just to be sure to remove zombies
if( fd.size()==0 ){
std::vector<Glib::ustring> names;
@@ -365,7 +365,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (batchdir);
safe_build_file_list (dir, names, batchdir);
for(std::vector<Glib::ustring>::iterator iter=names.begin(); iter != names.end();iter++ )
::remove( safe_locale_from_utf8(*iter).c_str () );
safe_g_remove( *iter );
}
}
redraw ();
@@ -460,7 +460,7 @@ Glib::ustring BatchQueue::autoCompleteFileName (const Glib::ustring& fileName, c
Glib::ustring dstfname = Glib::path_get_basename (fileName);
// create directory, if does not exist
if (g_mkdir_with_parents (dstdir.c_str(), 0755) )
if (safe_g_mkdir_with_parents (dstdir, 0755) )
return "";
// In overwrite mode we TRY to delete the old file first.
@@ -474,11 +474,10 @@ Glib::ustring BatchQueue::autoCompleteFileName (const Glib::ustring& fileName, c
else
fname = Glib::ustring::compose ("%1-%2.%3", Glib::build_filename (dstdir, dstfname), tries, format);
int fileExists=Glib::file_test (fname, Glib::FILE_TEST_EXISTS);
int fileExists=safe_file_test (fname, Glib::FILE_TEST_EXISTS);
if (inOverwriteMode && fileExists) {
// do NOT use g_remove as it has compiler problems on Unix and OSX (GTK namespace problem)
if (::remove(safe_locale_from_utf8(fname).c_str ()) == -1)
if (safe_g_remove(fname) == -1)
inOverwriteMode = false; // failed to delete- revert to old naming scheme
else
fileExists = false; // deleted now

View File

@@ -21,6 +21,7 @@
#include <preferences.h>
#include <multilangmgr.h>
#include <rtwindow.h>
#include <safegtk.h>
BatchQueuePanel::BatchQueuePanel () {
@@ -77,7 +78,7 @@ BatchQueuePanel::BatchQueuePanel () {
saveFormatPanel->init (options.saveFormat);
outdirTemplate->set_text (options.savePathTemplate);
if (Glib::file_test (options.savePathFolder, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (options.savePathFolder, Glib::FILE_TEST_IS_DIR))
outdirFolder->set_current_folder (options.savePathFolder);
useTemplate->set_active (options.saveUsePathTemplate);
useFolder->set_active (!options.saveUsePathTemplate);

View File

@@ -20,6 +20,7 @@
#include <vector>
#include <glib/gstdio.h>
#include <safekeyfile.h>
#include <safegtk.h>
CacheImageData::CacheImageData ()
: md5(""), supported(false), format(FT_Invalid), rank(0), inTrash(false), recentlySaved(false),
@@ -96,7 +97,7 @@ int CacheImageData::save (const Glib::ustring& fname) {
rtengine::SafeKeyFile keyFile;
if (::g_file_test(fname.c_str(),G_FILE_TEST_EXISTS)) keyFile.load_from_file (fname);
if (safe_file_test(fname,Glib::FILE_TEST_EXISTS)) keyFile.load_from_file (fname);
keyFile.set_string ("General", "MD5", md5);
keyFile.set_integer ("General", "Version", options.version);
@@ -132,7 +133,7 @@ int CacheImageData::save (const Glib::ustring& fname) {
keyFile.set_integer ("ExtraRawInfo", "ThumbImageOffset", thumbOffset);
}
FILE *f = g_fopen (fname.c_str(), "wt");
FILE *f = safe_g_fopen (fname, "wt");
if (!f)
return 1;
else {

View File

@@ -47,18 +47,18 @@ void CacheManager::init () {
openEntries.clear ();
baseDir = options.cacheBaseDir;
if (!Glib::file_test (baseDir, Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (baseDir.c_str(), 511);
if (!Glib::file_test (Glib::build_filename (baseDir, "profiles"), Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "profiles")).c_str(), 511);
if (!Glib::file_test (Glib::build_filename (baseDir, "images"), Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "images")).c_str(), 511);
if (!Glib::file_test (Glib::build_filename (baseDir, "aehistograms"), Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "aehistograms")).c_str(), 511);
if (!Glib::file_test (Glib::build_filename (baseDir, "embprofiles"), Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "embprofiles")).c_str(), 511);
if (!Glib::file_test (Glib::build_filename (baseDir, "data"), Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "data")).c_str(), 511);
if (!safe_file_test (baseDir, Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (baseDir, 511);
if (!safe_file_test (Glib::build_filename (baseDir, "profiles"), Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "profiles")), 511);
if (!safe_file_test (Glib::build_filename (baseDir, "images"), Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "images")), 511);
if (!safe_file_test (Glib::build_filename (baseDir, "aehistograms"), Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "aehistograms")), 511);
if (!safe_file_test (Glib::build_filename (baseDir, "embprofiles"), Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "embprofiles")), 511);
if (!safe_file_test (Glib::build_filename (baseDir, "data"), Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "data")), 511);
}
Thumbnail* CacheManager::getEntry (const Glib::ustring& fname) {
@@ -87,7 +87,7 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname) {
Glib::ustring cfname = getCacheFileName ("data", fname, md5) + ".txt";
// let's see if we have it in the cache
if (Glib::file_test (cfname, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (cfname, Glib::FILE_TEST_EXISTS)) {
CacheImageData* cfs = new CacheImageData ();
int e = cfs->load (cfname);
if (!e && cfs->supported==true)
@@ -150,23 +150,23 @@ void CacheManager::deleteEntry (const Glib::ustring& fname) {
// if in the editor, the thumbnail still exists. If not, delete it:
r = openEntries.find (fname);
if (r==openEntries.end() && md5!="") {
::g_remove ((getCacheFileName ("data", fname, md5) + ".txt").c_str());
::g_remove ((getCacheFileName ("profiles", fname, md5) + paramFileExtension).c_str());
::g_remove ((getCacheFileName ("images", fname, md5) + ".cust").c_str());
::g_remove ((getCacheFileName ("images", fname, md5) + ".jpg").c_str());
::g_remove ((getCacheFileName ("aehistograms", fname, md5)).c_str());
::g_remove ((getCacheFileName ("embprofiles", fname, md5) + ".icc").c_str());
safe_g_remove (getCacheFileName ("data", fname, md5) + ".txt");
safe_g_remove (getCacheFileName ("profiles", fname, md5) + paramFileExtension);
safe_g_remove (getCacheFileName ("images", fname, md5) + ".cust");
safe_g_remove (getCacheFileName ("images", fname, md5) + ".jpg");
safe_g_remove (getCacheFileName ("aehistograms", fname, md5));
safe_g_remove (getCacheFileName ("embprofiles", fname, md5) + ".icc");
}
}
else {
std::string md5 = getMD5 (fname);
if (md5!="") {
::g_remove ((getCacheFileName ("data", fname, md5) + ".txt").c_str());
::g_remove ((getCacheFileName ("profiles", fname, md5) + paramFileExtension).c_str());
::g_remove ((getCacheFileName ("images", fname, md5) + ".cust").c_str());
::g_remove ((getCacheFileName ("images", fname, md5) + ".jpg").c_str());
::g_remove ((getCacheFileName ("aehistograms", fname, md5)).c_str());
::g_remove ((getCacheFileName ("embprofiles", fname, md5) + ".icc").c_str());
safe_g_remove (getCacheFileName ("data", fname, md5) + ".txt");
safe_g_remove (getCacheFileName ("profiles", fname, md5) + paramFileExtension);
safe_g_remove (getCacheFileName ("images", fname, md5) + ".cust");
safe_g_remove (getCacheFileName ("images", fname, md5) + ".jpg");
safe_g_remove (getCacheFileName ("aehistograms", fname, md5));
safe_g_remove (getCacheFileName ("embprofiles", fname, md5) + ".icc");
}
}
}
@@ -178,12 +178,12 @@ void CacheManager::renameEntry (const std::string& oldfilename, const std::strin
std::string newmd5 = getMD5 (newfilename);
::g_rename ((getCacheFileName ("profiles", oldfilename, oldmd5) + paramFileExtension).c_str(), (getCacheFileName ("profiles", newfilename, newmd5) + paramFileExtension).c_str());
::g_rename ((getCacheFileName ("images", oldfilename, oldmd5) + ".cust").c_str(), (getCacheFileName ("images", newfilename, newmd5) + ".cust").c_str());
::g_rename ((getCacheFileName ("images", oldfilename, oldmd5) + ".jpg").c_str(), (getCacheFileName ("images", newfilename, newmd5) + ".jpg").c_str());
::g_rename ((getCacheFileName ("aehistograms", oldfilename, oldmd5)).c_str(), (getCacheFileName ("aehistograms", newfilename, newmd5)).c_str());
::g_rename ((getCacheFileName ("embprofiles", oldfilename, oldmd5) + ".icc").c_str(), (getCacheFileName ("embprofiles", newfilename, newmd5) + ".icc").c_str());
::g_rename ((getCacheFileName ("data", oldfilename, oldmd5) + ".txt").c_str(), (getCacheFileName ("data", newfilename, newmd5) + ".txt").c_str());
safe_g_rename (getCacheFileName ("profiles", oldfilename, oldmd5) + paramFileExtension, (getCacheFileName ("profiles", newfilename, newmd5) + paramFileExtension).c_str());
safe_g_rename (getCacheFileName ("images", oldfilename, oldmd5) + ".cust", getCacheFileName ("images", newfilename, newmd5) + ".cust");
safe_g_rename (getCacheFileName ("images", oldfilename, oldmd5) + ".jpg", getCacheFileName ("images", newfilename, newmd5) + ".jpg");
safe_g_rename (getCacheFileName ("aehistograms", oldfilename, oldmd5), getCacheFileName ("aehistograms", newfilename, newmd5));
safe_g_rename (getCacheFileName ("embprofiles", oldfilename, oldmd5) + ".icc", getCacheFileName ("embprofiles", newfilename, newmd5) + ".icc");
safe_g_rename (getCacheFileName ("data", oldfilename, oldmd5) + ".txt", getCacheFileName ("data", newfilename, newmd5) + ".txt");
// check if it is opened
string_thumb_map::iterator r = openEntries.find (oldfilename);
@@ -254,7 +254,7 @@ void CacheManager::deleteDir (const Glib::ustring& dirName) {
try {
Glib::Dir* dir = new Glib::Dir (Glib::build_filename (baseDir, dirName));
for (Glib::DirIterator i = dir->begin(); i!=dir->end(); ++i)
::g_remove (Glib::build_filename (Glib::build_filename (baseDir, dirName), *i).c_str());
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, dirName), *i));
delete dir;
}
catch (const Glib::FileError& fe) {
@@ -290,12 +290,12 @@ void CacheManager::applyCacheSizeLimitation () {
if (flist.size() > options.maxCacheEntries) {
std::sort (flist.begin(), flist.end());
while (flist.size() > options.maxCacheEntries) {
::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "data"), flist.front().fname) + ".txt").c_str());
::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "images"), flist.front().fname) + ".cust").c_str());
::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "images"), flist.front().fname) + ".jpg").c_str());
::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "aehistograms"), flist.front().fname)).c_str());
::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "embprofiles"), flist.front().fname) + ".icc").c_str());
// ::g_remove ((Glib::build_filename (Glib::build_filename (baseDir, "profiles"), flist.front().fname) + paramFileExtension).c_str());
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "data"), flist.front().fname) + ".txt");
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "images"), flist.front().fname) + ".cust");
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "images"), flist.front().fname) + ".jpg");
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "aehistograms"), flist.front().fname));
safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "embprofiles"), flist.front().fname) + ".icc");
// safe_g_remove (Glib::build_filename (Glib::build_filename (baseDir, "profiles"), flist.front().fname) + paramFileExtension);
flist.erase (flist.begin());
}
}

View File

@@ -20,6 +20,7 @@
*/
#include <curveeditorgroup.h>
#include <multilangmgr.h>
#include <safegtk.h>
extern Glib::ustring argv0;
@@ -393,7 +394,7 @@ void CurveEditorGroup::savePressed () {
if (getExtension (fname)!="rtc")
fname = fname + ".rtc";
if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (fname, Glib::FILE_TEST_EXISTS)) {
Glib::ustring msg_ = Glib::ustring("<b>") + fname + ": " + M("MAIN_MSG_ALREADYEXISTS") + "\n" + M("MAIN_MSG_QOVERWRITE") + "</b>";
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
int response = msgd.run ();

View File

@@ -235,8 +235,8 @@ void DirBrowser::updateDir (const Gtk::TreeModel::iterator& iter) {
while (change) {
change = false;
for (Gtk::TreeModel::iterator it=iter->children().begin(); it!=iter->children().end(); it++)
if (!Glib::file_test (it->get_value (dtColumns.dirname), Glib::FILE_TEST_EXISTS)
|| !Glib::file_test (it->get_value (dtColumns.dirname), Glib::FILE_TEST_IS_DIR)) {
if (!safe_file_test (it->get_value (dtColumns.dirname), Glib::FILE_TEST_EXISTS)
|| !safe_file_test (it->get_value (dtColumns.dirname), Glib::FILE_TEST_IS_DIR)) {
dirTreeModel->erase (it);
change = true;
break;
@@ -272,7 +272,7 @@ void DirBrowser::addDir (const Gtk::TreeModel::iterator& iter, const Glib::ustri
void DirBrowser::row_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) {
Glib::ustring dname = dirTreeModel->get_iter (path)->get_value (dtColumns.dirname);
if (Glib::file_test (dname, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (dname, Glib::FILE_TEST_IS_DIR))
for (int i=0; i<dllisteners.size(); i++)
dllisteners[i]->dirSelected (dname);
}
@@ -352,7 +352,7 @@ void DirBrowser::open (const Glib::ustring& dirname, const Glib::ustring& fileNa
void DirBrowser::file_changed (const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<Gio::File>& other_file, Gio::FileMonitorEvent event_type, const Gtk::TreeModel::iterator& iter, const Glib::ustring& dirName) {
if (!file || !Glib::file_test (dirName, Glib::FILE_TEST_IS_DIR) || event_type==Gio::FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED)
if (!file || !safe_file_test (dirName, Glib::FILE_TEST_IS_DIR) || event_type==Gio::FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED)
return;
gdk_threads_enter();

View File

@@ -214,7 +214,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) : beforePreviewHandler(NULL), be
show_all ();
// save as dialog
if (Glib::file_test (options.lastSaveAsPath, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (options.lastSaveAsPath, Glib::FILE_TEST_IS_DIR))
saveAsDialog = new SaveAsDialog (options.lastSaveAsPath);
else
saveAsDialog = new SaveAsDialog (Glib::get_user_special_dir (G_USER_DIRECTORY_PICTURES));
@@ -763,7 +763,7 @@ int EditorPanel::saveImage (rtengine::IImage16* img, Glib::ustring& fname, SaveF
Glib::ustring fileName = Glib::ustring::compose ("%1.%2", fname, sf.format);
if (findNewNameIfNeeded) {
int tries = 1;
while (Glib::file_test (fileName, Glib::FILE_TEST_EXISTS) && tries<1000) {
while (safe_file_test (fileName, Glib::FILE_TEST_EXISTS) && tries<1000) {
fileName = Glib::ustring::compose("%1-%2.%3", fname, tries, sf.format);
tries++;
}
@@ -845,7 +845,7 @@ void EditorPanel::saveAsPressed () {
else
fnameTemp = Glib::ustring::compose ("%1-%2.%3", Glib::build_filename (dstdir, dstfname), tries, sf.format);
if (!Glib::file_test (fnameTemp, Glib::FILE_TEST_EXISTS)) {
if (!safe_file_test (fnameTemp, Glib::FILE_TEST_EXISTS)) {
fname = fnameTemp;
fnameOK = true;
break;
@@ -855,7 +855,7 @@ void EditorPanel::saveAsPressed () {
// check if it exists
if (!fnameOK) {
fname = Glib::ustring::compose ("%1.%2", Glib::build_filename (dstdir, dstfname), sf.format);
if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (fname, Glib::FILE_TEST_EXISTS)) {
Glib::ustring msg_ = Glib::ustring("<b>") + fname + ": " + M("MAIN_MSG_ALREADYEXISTS") + "\n" + M("MAIN_MSG_QOVERWRITE") + "</b>";
Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
int response = msgd.run ();
@@ -926,7 +926,7 @@ bool EditorPanel::idle_sendToGimp( ProgressConnector<rtengine::IImage16*> *pc){
Glib::ustring fileName = Glib::ustring::compose ("%1.%2", fname, sf.format);
int tries = 1;
while (Glib::file_test (fileName, Glib::FILE_TEST_EXISTS) && tries<1000) {
while (safe_file_test (fileName, Glib::FILE_TEST_EXISTS) && tries<1000) {
fileName = Glib::ustring::compose("%1-%2.%3", fname, tries, sf.format);
tries++;
}
@@ -966,7 +966,7 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector<int> *pc,rtengine::IImage16*
#ifdef _WIN32
executable = Glib::build_filename (Glib::build_filename(options.gimpDir,"bin"), "gimp-win-remote");
cmdLine = Glib::ustring("\"") + executable + Glib::ustring("\" gimp-2.4.exe ") + Glib::ustring("\"") + filename + Glib::ustring("\"");
if ( Glib::file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
if ( safe_file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
success = safe_spawn_command_line_async (cmdLine);
}
#else
@@ -978,7 +978,7 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector<int> *pc,rtengine::IImage16*
int ver = 12;
while (!success && ver) {
executable = Glib::build_filename (Glib::build_filename(options.gimpDir,"bin"), Glib::ustring::compose(Glib::ustring("gimp-2.%1.exe"),ver));
if ( Glib::file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
if ( safe_file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
cmdLine = Glib::ustring("\"") + executable + Glib::ustring("\" \"") + filename + Glib::ustring("\"");
success = safe_spawn_command_line_async (cmdLine);
}
@@ -996,7 +996,7 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector<int> *pc,rtengine::IImage16*
else if (options.editorToSendTo==2) {
#ifdef _WIN32
executable = Glib::build_filename(options.psDir,"Photoshop.exe");
if ( Glib::file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
if ( safe_file_test(executable, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
cmdLine = Glib::ustring("\"") + executable + Glib::ustring("\" \"") + filename + Glib::ustring("\"");
success = safe_spawn_command_line_async (cmdLine);
}
@@ -1011,7 +1011,7 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector<int> *pc,rtengine::IImage16*
}
else if (options.editorToSendTo==3) {
#ifdef _WIN32
if ( Glib::file_test(options.customEditorProg, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
if ( safe_file_test(options.customEditorProg, (Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) ) {
cmdLine = Glib::ustring("\"") + options.customEditorProg + Glib::ustring("\" \"") + filename + Glib::ustring("\"");
success = safe_spawn_command_line_async (cmdLine);
}

View File

@@ -477,13 +477,13 @@ void FileCatalog::deleteRequested (std::vector<FileBrowserEntry*> tbe) {
// remove from cache
cacheMgr->deleteEntry (fname);
// delete from file system
::g_remove (fname.c_str());
safe_g_remove (fname);
// delete paramfile if found
::g_remove (Glib::ustring(fname+paramFileExtension).c_str());
::g_remove (Glib::ustring(removeExtension(fname)+paramFileExtension).c_str());
safe_g_remove (Glib::ustring(fname+paramFileExtension));
safe_g_remove (Glib::ustring(removeExtension(fname)+paramFileExtension));
// delete .thm file
::g_remove (Glib::ustring(removeExtension(fname)+".thm").c_str());
::g_remove (Glib::ustring(removeExtension(fname)+".THM").c_str());
safe_g_remove (Glib::ustring(removeExtension(fname)+".thm"));
safe_g_remove (Glib::ustring(removeExtension(fname)+".THM"));
}
redrawAll ();
}
@@ -537,7 +537,7 @@ void FileCatalog::renameRequested (std::vector<FileBrowserEntry*> tbe) {
if (ext=="")
nBaseName += "." + getExtension (baseName);
Glib::ustring nfname = Glib::build_filename (dirName, nBaseName);
if (!::g_rename (ofname.c_str(), nfname.c_str())) {
if (!safe_g_rename (ofname, nfname)) {
cacheMgr->renameEntry (ofname, tbe[i]->thumbnail->getMD5(), nfname);
reparseDirectory ();
}
@@ -583,7 +583,7 @@ void FileCatalog::renameRequested (std::vector<FileBrowserEntry*> tbe) {
nBaseName += "." + (lastdot!=Glib::ustring::npos ? baseName.substr (lastdot+1) : "");
}
Glib::ustring nfname = Glib::build_filename (dirName, nBaseName);
if (!::g_rename (ofname.c_str(), nfname.c_str())) {
if (!safe_g_rename (ofname, nfname)) {
cacheMgr->renameEntry (ofname, tbe[i]->thumbnail->getMD5(), nfname);
// the remaining part (removing old and adding new entry) is done by the directory monitor
reparseDirectory ();
@@ -734,7 +734,7 @@ int FileCatalog::reparseDirectory () {
if (selectedDirectory=="")
return 0;
if (!Glib::file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) {
if (!safe_file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) {
closeDir ();
return 0;
}
@@ -745,7 +745,7 @@ int FileCatalog::reparseDirectory () {
const std::vector<ThumbBrowserEntryBase*>& t = fileBrowser->getEntries ();
std::vector<Glib::ustring> fileNamesToDel;
for (size_t i=0; i<t.size(); i++)
if (!Glib::file_test (t[i]->filename, Glib::FILE_TEST_EXISTS))
if (!safe_file_test (t[i]->filename, Glib::FILE_TEST_EXISTS))
fileNamesToDel.push_back (t[i]->filename);
for (size_t i=0; i<fileNamesToDel.size(); i++) {
delete fileBrowser->delEntry (fileNamesToDel[i]);

View File

@@ -19,6 +19,7 @@
*/
#include <filepanel.h>
#include <rtwindow.h>
#include <safegtk.h>
int fbinit (void* data) {
@@ -200,9 +201,9 @@ void FilePanel::saveOptions () {
void FilePanel::open (const Glib::ustring& d) {
if (Glib::file_test (d, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (d, Glib::FILE_TEST_IS_DIR))
dirBrowser->open (d.c_str());
else if (Glib::file_test (d, Glib::FILE_TEST_EXISTS))
else if (safe_file_test (d, Glib::FILE_TEST_EXISTS))
dirBrowser->open (Glib::path_get_dirname(d), Glib::path_get_basename(d));
}

View File

@@ -19,6 +19,7 @@
#include <icmpanel.h>
#include <options.h>
#include <guiutils.h>
#include <safegtk.h>
using namespace rtengine;
using namespace rtengine::procparams;
@@ -118,7 +119,7 @@ ICMPanel::ICMPanel () : ToolPanel(), iunchanged(NULL), icmplistener(NULL) {
opDialog->add_filter (filter_icc);
opDialog->add_filter (filter_any);
if (Glib::file_test (options.rtSettings.iccDirectory, Glib::FILE_TEST_IS_DIR)) {
if (safe_file_test (options.rtSettings.iccDirectory, Glib::FILE_TEST_IS_DIR)) {
ipDialog->set_current_folder (options.rtSettings.iccDirectory);
opDialog->set_current_folder (options.rtSettings.iccDirectory);
}

View File

@@ -103,8 +103,8 @@ int main(int argc, char **argv)
#ifndef _WIN32
// Move the old path to the new one if the new does not exist
if (Glib::file_test(Glib::build_filename(options.rtdir,"cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test(options.cacheBaseDir, Glib::FILE_TEST_IS_DIR))
::g_rename(Glib::build_filename(options.rtdir,"cache").c_str(), options.cacheBaseDir.c_str());
if (safe_file_test(Glib::build_filename(options.rtdir,"cache"), Glib::FILE_TEST_IS_DIR) && !safe_file_test(options.cacheBaseDir, Glib::FILE_TEST_IS_DIR))
safe_g_rename(Glib::build_filename(options.rtdir,"cache"), options.cacheBaseDir);
#endif
// Gtk::RC::add_default_file (argv0+"/themes/"+options.theme);

View File

@@ -26,7 +26,7 @@ MultiLangMgr langMgr;
Glib::ustring M (std::string key) { return langMgr.getStr (key); }
bool MultiLangMgr::load (Glib::ustring fname, MultiLangMgr* fb) {
FILE *f = g_fopen (fname.c_str(), "rt");
FILE *f = safe_g_fopen (fname, "rt");
fallBack = fb;
@@ -72,7 +72,7 @@ bool MultiLangMgr::load (Glib::ustring fname, MultiLangMgr* fb) {
bool MultiLangMgr::save (Glib::ustring fname) {
FILE *f = g_fopen (fname.c_str(), "wt");
FILE *f = safe_g_fopen (fname, "wt");
if (f==NULL)
return false;

View File

@@ -24,6 +24,7 @@
#include <multilangmgr.h>
#include <safekeyfile.h>
#include <addsetids.h>
#include <safegtk.h>
Options options;
Glib::ustring versionString = "v3.0 alpha 1";
@@ -149,7 +150,7 @@ int Options::readFromFile (Glib::ustring fname) {
rtengine::SafeKeyFile keyFile;
try {
if( !Glib::file_test(fname,Glib::FILE_TEST_EXISTS))
if( !safe_file_test(fname,Glib::FILE_TEST_EXISTS))
return 1;
if (!keyFile.load_from_file (fname))
return 1;
@@ -424,7 +425,7 @@ int Options::saveToFile (Glib::ustring fname) {
keyFile.set_integer_list ("Batch Processing", "AdjusterBehavior", bab);
FILE *f = g_fopen (fname.c_str(), "wt");
FILE *f = safe_g_fopen (fname, "wt");
if (f==NULL)
return 1;
else {
@@ -444,9 +445,9 @@ void Options::load () {
cacheBaseDir = argv0 + "/cache";
if (options.multiUser) {
int r = options.readFromFile (rtdir + "/options");
if (r && !g_mkdir_with_parents (rtdir.c_str(), 511)) {
if (r && !safe_g_mkdir_with_parents (rtdir, 511)) {
Glib::ustring profdir = rtdir + "/profiles";
g_mkdir_with_parents (profdir.c_str(), 511);
safe_g_mkdir_with_parents (profdir, 511);
options.saveToFile (rtdir + "/options");
}
#ifdef _WIN32

View File

@@ -69,7 +69,7 @@ PopUpCommon::type_signal_changed PopUpCommon::signal_changed() {
bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) {
bool added = false;
if ( Glib::file_test(safe_locale_from_utf8(imagePath), Glib::FILE_TEST_EXISTS) && label.size() ) {
if ( safe_file_test(imagePath, Glib::FILE_TEST_EXISTS) && label.size() ) {
imagePaths.push_back(imagePath);
sItems.push_back(label);
// Create the image

View File

@@ -24,6 +24,7 @@
#include <addsetids.h>
#include <dfmanager.h>
#include <sstream>
#include <safegtk.h>
extern Options options;
extern Glib::ustring argv0;
@@ -687,7 +688,7 @@ void Preferences::parseDir (Glib::ustring dirname, std::vector<Glib::ustring>& i
Glib::ustring fname = dirname + *i;
Glib::ustring sname = *i;
// ignore directories
if (!Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= ext.size() && sname.substr (sname.size()-ext.size(), ext.size()).casefold() == ext)
if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= ext.size() && sname.substr (sname.size()-ext.size(), ext.size()).casefold() == ext)
items.push_back (sname.substr(0,sname.size()-ext.size()));
}
delete dir;
@@ -796,9 +797,9 @@ void Preferences::fillPreferences () {
rprofiles->set_active_text (moptions.defProfRaw);
iprofiles->set_active_text (moptions.defProfImg);
dateformat->set_text (moptions.dateFormat);
if (Glib::file_test (moptions.rtSettings.monitorProfile, Glib::FILE_TEST_EXISTS))
if (safe_file_test (moptions.rtSettings.monitorProfile, Glib::FILE_TEST_EXISTS))
monProfile->set_filename (moptions.rtSettings.monitorProfile);
if (Glib::file_test (moptions.rtSettings.iccDirectory, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (moptions.rtSettings.iccDirectory, Glib::FILE_TEST_IS_DIR))
iccDir->set_current_folder (moptions.rtSettings.iccDirectory);
intent->set_active (moptions.rtSettings.colorimetricIntent);
languages->set_active_text (moptions.language);
@@ -821,13 +822,13 @@ void Preferences::fillPreferences () {
edOther->set_active (moptions.editorToSendTo==3);
#ifdef _WIN32
edPS->set_active (moptions.editorToSendTo==2);
if (Glib::file_test (moptions.gimpDir, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (moptions.gimpDir, Glib::FILE_TEST_IS_DIR))
gimpDir->set_filename (moptions.gimpDir);
if (Glib::file_test (moptions.psDir, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (moptions.psDir, Glib::FILE_TEST_IS_DIR))
psDir->set_filename (moptions.psDir);
#elif defined __APPLE__
edPS->set_active (moptions.editorToSendTo==2);
if (Glib::file_test (moptions.psDir, Glib::FILE_TEST_IS_DIR))
if (safe_file_test (moptions.psDir, Glib::FILE_TEST_IS_DIR))
psDir->set_filename (moptions.psDir);
#endif
editorToSendTo->set_text (moptions.customEditorProg);

View File

@@ -19,6 +19,8 @@
#include <preprocess.h>
#include <options.h>
#include <guiutils.h>
#include <safegtk.h>
using namespace rtengine;
using namespace rtengine::procparams;
@@ -90,7 +92,7 @@ void PreProcess::read(const rtengine::procparams::ProcParams* pp, const ParamsEd
greenEqThreshold->setEditedState( pedited->raw.greenEq ? Edited : UnEdited );
}
if (Glib::file_test (pp->raw.dark_frame, Glib::FILE_TEST_EXISTS))
if (safe_file_test (pp->raw.dark_frame, Glib::FILE_TEST_EXISTS))
darkFrameFile->set_filename (pp->raw.dark_frame);
else if( !options.rtSettings.darkFramesPath.empty() )
darkFrameFile->set_current_folder( options.rtSettings.darkFramesPath );

View File

@@ -20,6 +20,7 @@
#include <set>
#include <previewloader.h>
#include <guiutils.h>
#include <safegtk.h>
#ifdef _OPENMP
#include <omp.h>
@@ -104,7 +105,7 @@ public:
// if something got
Thumbnail* tmb = 0;
{
if (Glib::file_test(j.dir_entry_, Glib::FILE_TEST_EXISTS))
if (safe_file_test(j.dir_entry_, Glib::FILE_TEST_EXISTS))
{
tmb = cacheMgr->getEntry(j.dir_entry_);
}

View File

@@ -21,6 +21,7 @@
#include <profilestore.h>
#include <clipboard.h>
#include <multilangmgr.h>
#include <safegtk.h>
using namespace rtengine;
using namespace rtengine::procparams;
@@ -158,7 +159,7 @@ void ProfilePanel::save_clicked () {
if (!hasext)
fname = fname + paramFileExtension;
if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (fname, Glib::FILE_TEST_EXISTS)) {
Glib::ustring msg_ = Glib::ustring("<b>") + fname + ": " + M("MAIN_MSG_ALREADYEXISTS") + "\n" + M("MAIN_MSG_QOVERWRITE") + "</b>";
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
int response = msgd.run ();

View File

@@ -19,6 +19,7 @@
#include <profilestore.h>
#include <options.h>
#include <toolpanel.h>
#include <safegtk.h>
ProfileStore profileStore;
@@ -36,8 +37,8 @@ void ProfileStore::parseProfiles () {
if (options.multiUser) {
Glib::ustring userPD = options.rtdir + "/" + options.profilePath;
if (!Glib::file_test (userPD, Glib::FILE_TEST_IS_DIR))
g_mkdir_with_parents (userPD.c_str(), 511);
if (!safe_file_test (userPD, Glib::FILE_TEST_IS_DIR))
safe_g_mkdir_with_parents (userPD, 511);
parseDir (userPD);
}
parseDir (argv0 + "/" + options.profilePath);
@@ -61,7 +62,7 @@ void ProfileStore::parseDir (const Glib::ustring& pdir) {
Glib::ustring fname = dirname + *i;
Glib::ustring sname = *i;
// ignore directories
if (!Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) {
int lastdot = sname.find_last_of ('.');
if (lastdot!=Glib::ustring::npos && lastdot<=sname.size()-4 && !sname.casefold().compare (lastdot, 4, paramFileExtension)) {
printf ("Processing file %s...\n", fname.c_str());

View File

@@ -29,6 +29,7 @@
#include <guiutils.h>
#include <profilestore.h>
#include <batchqueue.h>
#include <safegtk.h>
using namespace rtengine::procparams;
@@ -180,16 +181,16 @@ void Thumbnail::clearProcParams (int whoClearedIt) {
needsReProcessing = true;
// remove param file from cache
Glib::ustring fname_ = getCacheFileName ("profiles")+paramFileExtension;
if (Glib::file_test (fname_, Glib::FILE_TEST_EXISTS))
::g_remove (fname_.c_str());
if (safe_file_test (fname_, Glib::FILE_TEST_EXISTS))
safe_g_remove (fname_);
// remove param file located next to the file
// fname_ = removeExtension(fname) + paramFileExtension;
fname_ = fname + paramFileExtension;
if (Glib::file_test (fname_, Glib::FILE_TEST_EXISTS))
::g_remove (fname_.c_str());
if (safe_file_test(fname_, Glib::FILE_TEST_EXISTS))
safe_g_remove (fname_);
fname_ = removeExtension(fname) + paramFileExtension;
if (Glib::file_test (fname_, Glib::FILE_TEST_EXISTS))
::g_remove (fname_.c_str());
if (safe_file_test (fname_, Glib::FILE_TEST_EXISTS))
safe_g_remove (fname_);
for (int i=0; i<listeners.size(); i++)
listeners[i]->procParamsChanged (this, whoClearedIt);
@@ -437,9 +438,9 @@ void Thumbnail::_saveThumbnail () {
if (!tpp)
return;
::g_remove ((getCacheFileName ("images")+".cust").c_str());
::g_remove ((getCacheFileName ("images")+".cust16").c_str());
::g_remove ((getCacheFileName ("images")+".jpg").c_str());
safe_g_remove (getCacheFileName ("images")+".cust");
safe_g_remove (getCacheFileName ("images")+".cust16");
safe_g_remove (getCacheFileName ("images")+".jpg");
// save thumbnail image
if (options.thumbnailFormat == FT_Custom)
@@ -520,7 +521,7 @@ bool Thumbnail::openDefaultViewer(int destination) {
if (destination==1) {
openFName = Glib::ustring::compose ("%1.%2", BatchQueue::calcAutoFileNameBase(fname), options.saveFormat.format);
if (Glib::file_test (openFName, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (openFName, Glib::FILE_TEST_EXISTS)) {
ShellExecute(NULL, "open", openFName.c_str(), NULL, NULL, SW_SHOWMAXIMIZED );
} else {
printf("File not found\n");
@@ -532,7 +533,7 @@ bool Thumbnail::openDefaultViewer(int destination) {
printf("Opening %s\n", openFName.c_str());
if (Glib::file_test (openFName, Glib::FILE_TEST_EXISTS)) {
if (safe_file_test (openFName, Glib::FILE_TEST_EXISTS)) {
// Output file exists, so open explorer and select output file
const char* org=Glib::ustring::compose("/select,\"%1\"", openFName).c_str();
char* par=new char[strlen(org)+1];
@@ -548,7 +549,7 @@ bool Thumbnail::openDefaultViewer(int destination) {
ShellExecute(NULL, "open", "explorer.exe", par, NULL, SW_SHOWNORMAL );
delete[] par;
} else if (Glib::file_test (Glib::path_get_dirname(openFName), Glib::FILE_TEST_EXISTS)) {
} else if (safe_file_test (Glib::path_get_dirname(openFName), Glib::FILE_TEST_EXISTS)) {
// Out file does not exist, but directory
ShellExecute(NULL, "explore", Glib::path_get_dirname(openFName).c_str(), NULL, NULL, SW_SHOWNORMAL );
} else {