Change variable linux to unix_names

Turns out that compilers have `#define linux 1` somewhere inside them
and for some reason this wasn't a problem when compiling with the `-c`
flag
This commit is contained in:
zvon 2020-04-16 15:11:46 +02:00
parent 12194d12e2
commit afd6ca6607
6 changed files with 37 additions and 35 deletions

View File

@ -460,11 +460,11 @@ void prepareDB( const string &_pattern ) {
#ifndef GUI #ifndef GUI
void addToDB( string &show, const string &path, const string &language, void addToDB( string &show, const string &path, const string &language,
bool linux, bool dvd ) { bool unix_names, bool dvd ) {
#else #else
void addToDB( const string &show, const string &path, const string &language, void addToDB( const string &show, const string &path, const string &language,
const string &id, const string &pattern, bool linux, bool dvd, const string &id, const string &pattern, bool unix_names,
void *progress_ptr ) { bool dvd, void *progress_ptr ) {
#endif #endif
if ( !FSLib::exists( getDBName() ) ) if ( !FSLib::exists( getDBName() ) )
prepareDB(); prepareDB();
@ -517,8 +517,8 @@ void addToDB( const string &show, const string &path, const string &language,
size_t i = 0; size_t i = 0;
size_t seasons_size = seasons.size(); size_t seasons_size = seasons.size();
for ( auto &x : seasons ) { for ( auto &x : seasons ) {
singleSeason( absolute, show, x.first, id, language, pattern, linux, singleSeason( absolute, show, x.first, id, language, pattern,
true, &x.second, false, dvd ); unix_names, true, &x.second, false, dvd );
i++; i++;
p.print( ( i * 100 ) / seasons_size ); p.print( ( i * 100 ) / seasons_size );
} }
@ -576,9 +576,9 @@ void cleanUpLine() {
#endif #endif
#ifndef GUI #ifndef GUI
void refreshDB( bool linux ) { void refreshDB( bool unix_names ) {
#else #else
void refreshDB( bool linux, void *progress_ptr ) { void refreshDB( bool unix_names, void *progress_ptr ) {
#endif #endif
if ( !FSLib::exists( getDBName() ) ) if ( !FSLib::exists( getDBName() ) )
return; return;
@ -629,8 +629,8 @@ void refreshDB( bool linux, void *progress_ptr ) {
for ( auto &x : seasons ) { for ( auto &x : seasons ) {
singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )], singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )],
x.first, show[TEXT( "TVID" )], x.first, show[TEXT( "TVID" )],
show[TEXT( "LANGUAGE" )], pattern, linux, true, show[TEXT( "LANGUAGE" )], pattern, unix_names,
&x.second, false, true, &x.second, false,
show[TEXT( "DVD" )] == TEXT( "1" ) ); show[TEXT( "DVD" )] == TEXT( "1" ) );
i++; i++;
p.print( ( i * 100 ) / seasons_size ); p.print( ( i * 100 ) / seasons_size );
@ -667,9 +667,9 @@ void refreshDB( bool linux, void *progress_ptr ) {
} }
#ifndef GUI #ifndef GUI
void updateDB( bool linux ) { void updateDB( bool unix_names ) {
#else #else
void updateDB( bool linux, void *progress_ptr ) { void updateDB( bool unix_names, void *progress_ptr ) {
#endif #endif
if ( !FSLib::exists( getDBName() ) ) if ( !FSLib::exists( getDBName() ) )
return; return;
@ -735,8 +735,8 @@ void updateDB( bool linux, void *progress_ptr ) {
for ( auto &x : new_eps ) { for ( auto &x : new_eps ) {
singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )], singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )],
x.first, show[TEXT( "TVID" )], x.first, show[TEXT( "TVID" )],
show[TEXT( "LANGUAGE" )], pattern, linux, true, show[TEXT( "LANGUAGE" )], pattern, unix_names,
&x.second, false, true, &x.second, false,
show[TEXT( "DVD" )] == TEXT( "1" ) ); show[TEXT( "DVD" )] == TEXT( "1" ) );
i++; i++;
p.print( ( i * 100 ) / size ); p.print( ( i * 100 ) / size );
@ -892,7 +892,7 @@ void changeDB( size_t index, const string &path, const string &language,
TEXT( " WHERE ID == " ) + show_id + TEXT( ";" ) ); TEXT( " WHERE ID == " ) + show_id + TEXT( ";" ) );
} }
void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux, void refreshSelectDB( std::unordered_set< size_t > indexes, bool unix_names,
void *progress_ptr ) { void *progress_ptr ) {
if ( !FSLib::exists( getDBName() ) ) if ( !FSLib::exists( getDBName() ) )
return; return;
@ -939,8 +939,8 @@ void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux,
for ( auto &x : seasons ) { for ( auto &x : seasons ) {
singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )], singleSeason( show[TEXT( "PATH" )], show[TEXT( "SHOW" )],
x.first, show[TEXT( "TVID" )], x.first, show[TEXT( "TVID" )],
show[TEXT( "LANGUAGE" )], pattern, linux, true, show[TEXT( "LANGUAGE" )], pattern, unix_names,
&x.second, false, true, &x.second, false,
show[TEXT( "DVD" )] == TEXT( "1" ) ); show[TEXT( "DVD" )] == TEXT( "1" ) );
i++; i++;
p.print( ( i * 100 ) / size ); p.print( ( i * 100 ) / size );

View File

@ -53,21 +53,21 @@ string userHome();
void prepareDB( const string &_pattern = TEXT( "" ) ); void prepareDB( const string &_pattern = TEXT( "" ) );
#ifndef GUI #ifndef GUI
void addToDB( string &show, const string &path, const string &language, void addToDB( string &show, const string &path, const string &language,
bool linux, bool dvd ); bool unix_names, bool dvd );
#else #else
void addToDB( const string &show, const string &path, const string &language, void addToDB( const string &show, const string &path, const string &language,
const string &id, const string &pattern, bool linux, bool dvd, const string &id, const string &pattern, bool unix_names,
void *progress_ptr ); bool dvd, void *progress_ptr );
#endif #endif
void removeFromDB( const string &path ); void removeFromDB( const string &path );
void changeDBPattern( const string &pattern ); void changeDBPattern( const string &pattern );
#ifndef GUI #ifndef GUI
void refreshDB( bool linux ); void refreshDB( bool unix_names );
void updateDB( bool linux ); void updateDB( bool unix_names );
void cleanDB(); void cleanDB();
#else #else
void refreshDB( bool linux, void *progress_ptr ); void refreshDB( bool unix_names, void *progress_ptr );
void updateDB( bool linux, void *progress_ptr ); void updateDB( bool unix_names, void *progress_ptr );
void cleanDB( void *progress_ptr ); void cleanDB( void *progress_ptr );
#endif #endif
@ -75,7 +75,7 @@ void cleanDB( void *progress_ptr );
std::vector< std::unordered_map< string, string > > dbGetShows(); std::vector< std::unordered_map< string, string > > dbGetShows();
void changeDB( size_t index, const string &path, const string &language, void changeDB( size_t index, const string &path, const string &language,
const string &id, bool dvd ); const string &id, bool dvd );
void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux, void refreshSelectDB( std::unordered_set< size_t > indexes, bool unix_names,
void *progress_ptr ); void *progress_ptr );
void renameFiles( const std::vector< std::tuple< int, string, string, string > > void renameFiles( const std::vector< std::tuple< int, string, string, string > >
&renamed_files ); &renamed_files );

View File

@ -21,9 +21,10 @@ DatabaseWindow::~DatabaseWindow() {
} }
DatabaseWindow::DatabaseWindow( DatabaseWindow::DatabaseWindow(
bool _linux, std::map< std::string, std::string > &_language_map, bool _unix_names, std::map< std::string, std::string > &_language_map,
Glib::RefPtr< Gtk::Application > _app ) Glib::RefPtr< Gtk::Application > _app )
: linux( _linux ), language_map( _language_map ), app( _app ) { : unix_names( _unix_names ), language_map( _language_map ),
app( _app ) {
set_title( _( DATABASE ) ); set_title( _( DATABASE ) );
property_modal().set_value( true ); property_modal().set_value( true );
@ -222,7 +223,8 @@ void DatabaseWindow::save() {
pw->show(); pw->show();
std::thread t = std::thread( refreshSelectDB, changed_rows, linux, pw ); std::thread t =
std::thread( refreshSelectDB, changed_rows, unix_names, pw );
t.detach(); t.detach();
changed_rows.clear(); changed_rows.clear();

View File

@ -12,7 +12,7 @@
class DatabaseWindow : public Gtk::Window { class DatabaseWindow : public Gtk::Window {
public: public:
DatabaseWindow() = delete; DatabaseWindow() = delete;
DatabaseWindow( bool _linux, DatabaseWindow( bool _unix_names,
std::map< std::string, std::string > &_language_map, std::map< std::string, std::string > &_language_map,
Glib::RefPtr< Gtk::Application > _app ); Glib::RefPtr< Gtk::Application > _app );
virtual ~DatabaseWindow(); virtual ~DatabaseWindow();
@ -72,7 +72,7 @@ protected:
Glib::RefPtr< Gtk::TreeStore > m_model; Glib::RefPtr< Gtk::TreeStore > m_model;
Gtk::CellRendererCombo m_combo_language; Gtk::CellRendererCombo m_combo_language;
bool linux; bool unix_names;
std::map< std::string, std::string > &language_map; std::map< std::string, std::string > &language_map;
Glib::RefPtr< Gtk::Application > app; Glib::RefPtr< Gtk::Application > app;
std::unique_ptr< SearchWindow > sw{ nullptr }; std::unique_ptr< SearchWindow > sw{ nullptr };

View File

@ -186,7 +186,7 @@ std::vector< string > getEpisodeNames( const string &id, const string &season,
std::vector< std::tuple< int, string, string, string > > std::vector< std::tuple< int, string, string, string > >
getRenamedFiles( const string &show, int season, const string &id, getRenamedFiles( const string &show, int season, const string &id,
const string &language, const string &pattern, const string &language, const string &pattern,
const bool &linux, const std::map< int, string > &files, const bool &unix_names, const std::map< int, string > &files,
bool dvd ) { bool dvd ) {
auto season_num = toString( std::to_string( season ) ); auto season_num = toString( std::to_string( season ) );
auto episodes = getEpisodeNames( id, season_num, language, dvd ); auto episodes = getEpisodeNames( id, season_num, language, dvd );
@ -227,7 +227,7 @@ getRenamedFiles( const string &show, int season, const string &id,
} }
} }
// replace characters illegal in windows if desired // replace characters illegal in windows if desired
if ( !linux ) { if ( !unix_names ) {
name.erase( std::remove_if( name.begin(), name.end(), name.erase( std::remove_if( name.begin(), name.end(),
[]( char_t x ) { []( char_t x ) {
return x == '?' || x == '"' || return x == '?' || x == '"' ||
@ -318,7 +318,7 @@ bool authenticate( const std::string &api_key ) {
void singleSeason( const string &path, const string &show, int season, void singleSeason( const string &path, const string &show, int season,
string id, const string &language, const string &pattern, string id, const string &language, const string &pattern,
const bool &linux, const bool &trust, const bool &unix_names, const bool &trust,
std::map< int, string > *files_ptr, bool print, bool dvd ) { std::map< int, string > *files_ptr, bool print, bool dvd ) {
#ifndef GUI #ifndef GUI
if ( id.empty() ) if ( id.empty() )
@ -340,7 +340,7 @@ void singleSeason( const string &path, const string &show, int season,
} }
auto renamed_files = getRenamedFiles( show, season, id, language, pattern, auto renamed_files = getRenamedFiles( show, season, id, language, pattern,
linux, *files_ptr, dvd ); unix_names, *files_ptr, dvd );
if ( renamed_files.empty() ) if ( renamed_files.empty() )
goto end; goto end;

View File

@ -28,7 +28,7 @@ using char_t = char;
void singleSeason( const string &path, const string &show, int season, void singleSeason( const string &path, const string &show, int season,
string id, const string &language, const string &pattern, string id, const string &language, const string &pattern,
const bool &linux, const bool &trust, const bool &unix_names, const bool &trust,
std::map< int, string > *files_ptr = nullptr, std::map< int, string > *files_ptr = nullptr,
bool print = true, bool dvd = false ); bool print = true, bool dvd = false );
@ -43,7 +43,7 @@ void singleSeason( const string &path, const string &show, int season,
std::vector< std::tuple< int, string, string, string > > std::vector< std::tuple< int, string, string, string > >
getRenamedFiles( const string &show, int season, const string &id, getRenamedFiles( const string &show, int season, const string &id,
const string &language, const string &pattern, const string &language, const string &pattern,
const bool &linux, const std::map< int, string > &files, const bool &unix_names, const std::map< int, string > &files,
bool dvd = false ); bool dvd = false );
#ifndef _WIN32 #ifndef _WIN32