Begin removing simple pass-through wrapper for POSIX-style file system functions from safegtk module.

This commit is contained in:
Adam Reichold
2015-12-26 01:35:22 +01:00
parent b62b78e2f8
commit 747a28014b
11 changed files with 248 additions and 277 deletions

View File

@@ -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;
}