Begin removing simple pass-through wrapper for POSIX-style file system functions from safegtk module.
This commit is contained in:
@@ -320,65 +320,84 @@ void DFManager::init( Glib::ustring pathname )
|
||||
return;
|
||||
}
|
||||
|
||||
dfInfo *DFManager::addFileInfo(const Glib::ustring &filename , bool pool )
|
||||
dfInfo* DFManager::addFileInfo (const Glib::ustring& filename, bool pool)
|
||||
{
|
||||
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(filename);
|
||||
auto file = Gio::File::create_for_path (filename);
|
||||
|
||||
if (!file ) {
|
||||
if (!file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !file->query_exists()) {
|
||||
if (!file->query_exists ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
||||
try {
|
||||
|
||||
if (info && info->get_file_type() != Gio::FILE_TYPE_DIRECTORY && (!info->is_hidden() || !options.fbShowHidden)) {
|
||||
size_t lastdot = info->get_name().find_last_of ('.');
|
||||
auto info = file->query_info ();
|
||||
|
||||
if (options.is_extention_enabled(lastdot != Glib::ustring::npos ? info->get_name().substr (lastdot + 1) : "")) {
|
||||
RawImage ri(filename);
|
||||
int res = ri.loadRaw(false); // Read informations about shot
|
||||
if (!info && info->get_file_type () == Gio::FILE_TYPE_DIRECTORY) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !res ) {
|
||||
dfList_t::iterator iter;
|
||||
if (!options.fbShowHidden && info->is_hidden ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!pool) {
|
||||
dfInfo n(filename, "", "", 0, 0, 0);
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( "", n ) );
|
||||
return &(iter->second);
|
||||
}
|
||||
Glib::ustring ext;
|
||||
|
||||
RawMetaDataLocation rml;
|
||||
rml.exifBase = ri.get_exifBase();
|
||||
rml.ciffBase = ri.get_ciffBase();
|
||||
rml.ciffLength = ri.get_ciffLen();
|
||||
ImageData idata(filename, &rml);
|
||||
/* Files are added in the map, divided by same maker/model,ISO and shutter*/
|
||||
std::string key( dfInfo::key(((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed()) );
|
||||
iter = dfList.find( key );
|
||||
auto lastdot = info->get_name ().find_last_of ('.');
|
||||
if (lastdot != Glib::ustring::npos) {
|
||||
ext = info->get_name ().substr (lastdot + 1);
|
||||
}
|
||||
|
||||
if( iter == dfList.end() ) {
|
||||
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS() );
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
|
||||
} else {
|
||||
while( iter != dfList.end() && iter->second.key() == key && ABS(iter->second.timestamp - idata.getDateTimeAsTS()) > 60 * 60 * 6 ) { // 6 hour difference
|
||||
iter++;
|
||||
}
|
||||
if (!options.is_extention_enabled (ext)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( iter != dfList.end() ) {
|
||||
iter->second.pathNames.push_back( filename );
|
||||
} else {
|
||||
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS());
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
|
||||
}
|
||||
}
|
||||
RawImage ri (filename);
|
||||
int res = ri.loadRaw (false); // Read informations about shot
|
||||
|
||||
return &(iter->second);
|
||||
if (res != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
dfList_t::iterator iter;
|
||||
|
||||
if(!pool) {
|
||||
dfInfo n(filename, "", "", 0, 0, 0);
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( "", n ) );
|
||||
return &(iter->second);
|
||||
}
|
||||
|
||||
RawMetaDataLocation rml;
|
||||
rml.exifBase = ri.get_exifBase();
|
||||
rml.ciffBase = ri.get_ciffBase();
|
||||
rml.ciffLength = ri.get_ciffLen();
|
||||
ImageData idata(filename, &rml);
|
||||
/* Files are added in the map, divided by same maker/model,ISO and shutter*/
|
||||
std::string key( dfInfo::key(((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed()) );
|
||||
iter = dfList.find( key );
|
||||
|
||||
if( iter == dfList.end() ) {
|
||||
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS() );
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
|
||||
} else {
|
||||
while( iter != dfList.end() && iter->second.key() == key && ABS(iter->second.timestamp - idata.getDateTimeAsTS()) > 60 * 60 * 6 ) { // 6 hour difference
|
||||
iter++;
|
||||
}
|
||||
|
||||
if( iter != dfList.end() ) {
|
||||
iter->second.pathNames.push_back( filename );
|
||||
} else {
|
||||
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS());
|
||||
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &(iter->second);
|
||||
|
||||
} catch(Gio::Error&) {}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -253,65 +253,85 @@ void FFManager::init( Glib::ustring pathname )
|
||||
return;
|
||||
}
|
||||
|
||||
ffInfo *FFManager::addFileInfo(const Glib::ustring &filename, bool pool )
|
||||
ffInfo* FFManager::addFileInfo (const Glib::ustring& filename, bool pool)
|
||||
{
|
||||
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(filename);
|
||||
auto file = Gio::File::create_for_path (filename);
|
||||
|
||||
if (!file ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !file->query_exists()) {
|
||||
if (!file->query_exists ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
||||
try {
|
||||
|
||||
if (info && info->get_file_type() != Gio::FILE_TYPE_DIRECTORY && (!info->is_hidden() || !options.fbShowHidden)) {
|
||||
size_t lastdot = info->get_name().find_last_of ('.');
|
||||
auto info = file->query_info ();
|
||||
|
||||
if (options.is_extention_enabled(lastdot != Glib::ustring::npos ? info->get_name().substr (lastdot + 1) : "")) {
|
||||
RawImage ri(filename);
|
||||
int res = ri.loadRaw(false); // Read informations about shot
|
||||
if (!info || info->get_file_type () == Gio::FILE_TYPE_DIRECTORY) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !res ) {
|
||||
ffList_t::iterator iter;
|
||||
if (!options.fbShowHidden && info->is_hidden ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!pool) {
|
||||
ffInfo n(filename, "", "", "", 0, 0, 0);
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( "", n ) );
|
||||
return &(iter->second);
|
||||
}
|
||||
Glib::ustring ext;
|
||||
|
||||
RawMetaDataLocation rml;
|
||||
rml.exifBase = ri.get_exifBase();
|
||||
rml.ciffBase = ri.get_ciffBase();
|
||||
rml.ciffLength = ri.get_ciffLen();
|
||||
ImageData idata(filename, &rml);
|
||||
/* Files are added in the map, divided by same maker/model,lens and aperture*/
|
||||
std::string key( ffInfo::key(idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber()) );
|
||||
iter = ffList.find( key );
|
||||
auto lastdot = info->get_name ().find_last_of ('.');
|
||||
if (lastdot != Glib::ustring::npos) {
|
||||
ext = info->get_name ().substr (lastdot + 1);
|
||||
}
|
||||
|
||||
if( iter == ffList.end() ) {
|
||||
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
|
||||
} else {
|
||||
while( iter != ffList.end() && iter->second.key() == key && ABS(iter->second.timestamp - ri.get_timestamp()) > 60 * 60 * 6 ) { // 6 hour difference
|
||||
iter++;
|
||||
}
|
||||
if (!options.is_extention_enabled (ext)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( iter != ffList.end() ) {
|
||||
iter->second.pathNames.push_back( filename );
|
||||
} else {
|
||||
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
|
||||
}
|
||||
}
|
||||
|
||||
return &(iter->second);
|
||||
RawImage ri (filename);
|
||||
int res = ri.loadRaw (false); // Read informations about shot
|
||||
|
||||
if (res != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ffList_t::iterator iter;
|
||||
|
||||
if(!pool) {
|
||||
ffInfo n(filename, "", "", "", 0, 0, 0);
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( "", n ) );
|
||||
return &(iter->second);
|
||||
}
|
||||
|
||||
RawMetaDataLocation rml;
|
||||
rml.exifBase = ri.get_exifBase();
|
||||
rml.ciffBase = ri.get_ciffBase();
|
||||
rml.ciffLength = ri.get_ciffLen();
|
||||
ImageData idata(filename, &rml);
|
||||
/* Files are added in the map, divided by same maker/model,lens and aperture*/
|
||||
std::string key( ffInfo::key(idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber()) );
|
||||
iter = ffList.find( key );
|
||||
|
||||
if( iter == ffList.end() ) {
|
||||
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
|
||||
} else {
|
||||
while( iter != ffList.end() && iter->second.key() == key && ABS(iter->second.timestamp - ri.get_timestamp()) > 60 * 60 * 6 ) { // 6 hour difference
|
||||
iter++;
|
||||
}
|
||||
|
||||
if( iter != ffList.end() ) {
|
||||
iter->second.pathNames.push_back( filename );
|
||||
} else {
|
||||
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
|
||||
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &(iter->second);
|
||||
|
||||
} catch (Gio::Error&) {}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1011,7 +1011,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
|
||||
*/
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
fclose(file);
|
||||
safe_g_remove(fname);
|
||||
g_remove (fname.c_str());
|
||||
return IMIO_CANNOTWRITEFILE;
|
||||
}
|
||||
|
||||
@@ -1130,7 +1130,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
|
||||
delete [] row;
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
fclose(file);
|
||||
safe_g_remove(fname);
|
||||
g_remove (fname.c_str());
|
||||
return IMIO_CANNOTWRITEFILE;
|
||||
}
|
||||
|
||||
@@ -1142,7 +1142,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
|
||||
jpeg_destroy_compress (&cinfo);
|
||||
delete [] row;
|
||||
fclose (file);
|
||||
safe_g_remove(fname);
|
||||
g_remove (fname.c_str());
|
||||
return IMIO_CANNOTWRITEFILE;
|
||||
}
|
||||
|
||||
@@ -1370,7 +1370,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
|
||||
if(writeOk) {
|
||||
return IMIO_SUCCESS;
|
||||
} else {
|
||||
safe_g_remove(fname);
|
||||
g_remove (fname.c_str());
|
||||
return IMIO_CANNOTWRITEFILE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,9 @@
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "../rtgui/guiutils.h"
|
||||
|
||||
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
|
||||
{
|
||||
Glib::RefPtr<Gio::FileInfo> info;
|
||||
|
||||
try {
|
||||
info = file->query_info();
|
||||
} catch (...) { }
|
||||
|
||||
return info;
|
||||
}
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
Glib::RefPtr<Gio::FileInfo> safe_next_file (Glib::RefPtr<Gio::FileEnumerator> &dirList)
|
||||
{
|
||||
@@ -261,18 +252,3 @@ bool safe_file_test (const Glib::ustring& filename, Glib::FileTest test)
|
||||
{
|
||||
return Glib::file_test (filename, test);
|
||||
}
|
||||
|
||||
int safe_g_remove(const Glib::ustring& filename)
|
||||
{
|
||||
return ::g_remove(filename.c_str());
|
||||
}
|
||||
|
||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename)
|
||||
{
|
||||
return ::g_rename(oldFilename.c_str(), newFilename.c_str());
|
||||
}
|
||||
|
||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode)
|
||||
{
|
||||
return ::g_mkdir_with_parents(dirName.c_str(), mode);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <glibmm.h>
|
||||
#include <giomm.h>
|
||||
|
||||
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file);
|
||||
void safe_build_file_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ustring> &names, const Glib::ustring &directory = "", const std::vector<Glib::ustring> *extensions = NULL);
|
||||
|
||||
bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8);
|
||||
@@ -16,13 +15,10 @@ Glib::ustring safe_locale_to_utf8 (const std::string& src); // from rtengine
|
||||
std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str);
|
||||
std::string safe_filename_from_utf8 (const Glib::ustring& utf8_str);
|
||||
|
||||
FILE * safe_g_fopen(const Glib::ustring& src, const gchar *mode);
|
||||
FILE * safe_g_fopen_WriteBinLock(const Glib::ustring& fname);
|
||||
int safe_open_ReadOnly(const char *fname);
|
||||
|
||||
FILE * safe_g_fopen(const Glib::ustring& src, const gchar *mode);
|
||||
bool safe_file_test (const Glib::ustring& filename, Glib::FileTest test);
|
||||
int safe_g_remove(const Glib::ustring& filename);
|
||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename);
|
||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user