Formatting

This commit is contained in:
zvon 2019-06-01 21:54:45 +02:00
parent d2ae8ab94c
commit d36d7a385d
10 changed files with 51 additions and 25 deletions

24
.clang-format Normal file
View File

@ -0,0 +1,24 @@
---
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Empty
BasedOnStyle: LLVM
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
ConstructorInitializerIndentWidth: 8
Cpp11BracedListStyle: 'false'
IndentWidth: '4'
Language: Cpp
PointerAlignment: Right
SortIncludes: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'true'
SpacesInCStyleCastParentheses: 'true'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'true'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never
...

View File

@ -118,7 +118,6 @@ public:
return dir_path.c_str(); return dir_path.c_str();
} }
private: private:
string dir_path; string dir_path;
}; };

View File

@ -193,8 +193,8 @@ void iterateFS( std::map< int, std::set< string > > &seasons,
// if file is a correct format, add it to file list // if file is a correct format, add it to file list
// for its season // for its season
if ( searchSeason( p, season_pos ) ) if ( searchSeason( p, season_pos ) )
seasons[std::stoi( p + season_pos )].insert( seasons[std::stoi( p + season_pos )].insert( path + dir_divider +
path + dir_divider + p ); p );
} }
} }
@ -286,11 +286,13 @@ void printHelp() {
cout << "Usage:" << std::endl; cout << "Usage:" << std::endl;
cout << " tv_rename [options] [path]" << std::endl << std::endl; cout << " tv_rename [options] [path]" << std::endl << std::endl;
cout << " -h, --help show this help message and exit" cout << " -h, --help show this help message and exit"
<< std::endl << std::endl; << std::endl
<< std::endl;
cout << " path can be either a file or a directory, if it's a directory" cout << " path can be either a file or a directory, if it's a directory"
<< std::endl; << std::endl;
cout << " all files in it and its subdirectories will be renamed" cout << " all files in it and its subdirectories will be renamed"
<< std::endl << std::endl; << std::endl
<< std::endl;
cout << "OPTIONS" << std::endl; cout << "OPTIONS" << std::endl;
cout << " -s, --show <string> TV show from which you want the"; cout << " -s, --show <string> TV show from which you want the";
cout << " episode names" << std::endl; cout << " episode names" << std::endl;
@ -394,11 +396,10 @@ getPossibleShows( string show, const string &language, Curl &c ) {
show = encodeUrl( show ); show = encodeUrl( show );
#ifdef _WIN32 #ifdef _WIN32
auto source_code = utf8_to_wstring( auto source_code = utf8_to_wstring(
c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) + c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) + show +
show + TEXT( "&l=" ) + language ) ); TEXT( "&l=" ) + language ) );
#else #else
auto source_code = auto source_code = c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) +
c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) +
show + TEXT( "&l=" ) + language ); show + TEXT( "&l=" ) + language );
#endif #endif
size_t pos{}; size_t pos{};

View File

@ -1,5 +1,5 @@
#include <iostream>
#include "network.hpp" #include "network.hpp"
#include <iostream>
#ifdef _WIN32 #ifdef _WIN32

View File

@ -3,8 +3,8 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h>
#include <WinInet.h> #include <WinInet.h>
#include <Windows.h>
using string = std::wstring; using string = std::wstring;

View File

@ -1,5 +1,5 @@
#include <string>
#include "seasonwindow.hpp" #include "seasonwindow.hpp"
#include <string>
void SeasonWindow::confirm() { void SeasonWindow::confirm() {
// go through all checkbuttons and save numbers // go through all checkbuttons and save numbers

View File

@ -13,10 +13,10 @@
#ifndef GUI #ifndef GUI
#include "filesystem.hpp"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include "filesystem.hpp"
#endif #endif

View File

@ -1,9 +1,10 @@
#include <sys/stat.h>
#include "../filesystem.hpp" #include "../filesystem.hpp"
#include <sys/stat.h>
FSLib::Directory::Directory( const string &path_ ) : dir_path( path_ ) {} FSLib::Directory::Directory( const string &path_ ) : dir_path( path_ ) {}
FSLib::Directory::Iterator::Iterator( const Directory &d_ ) : d( opendir( d_.path() ) ) { FSLib::Directory::Iterator::Iterator( const Directory &d_ )
: d( opendir( d_.path() ) ) {
current_entry = readdir( d ); current_entry = readdir( d );
if ( current_entry != nullptr && if ( current_entry != nullptr &&
( !strcmp( current_entry->d_name, "." ) || ( !strcmp( current_entry->d_name, "." ) ||
@ -11,7 +12,8 @@ FSLib::Directory::Iterator::Iterator( const Directory &d_ ) : d( opendir( d_.pat
++( *this ); ++( *this );
} }
FSLib::Directory::Iterator::Iterator( const Directory &d_, const struct dirent *current_entry_ ) FSLib::Directory::Iterator::Iterator( const Directory &d_,
const struct dirent *current_entry_ )
: d( opendir( d_.path() ) ), current_entry( current_entry_ ) {} : d( opendir( d_.path() ) ), current_entry( current_entry_ ) {}
FSLib::Directory::Iterator::~Iterator() { FSLib::Directory::Iterator::~Iterator() {

View File

@ -1,6 +1,6 @@
#include "../filesystem.hpp"
#include <Shlwapi.h> #include <Shlwapi.h>
#include <windows.h> #include <windows.h>
#include "../filesystem.hpp"
FSLib::Directory::Directory( const string &path_ ) : dir_path( path_ ) { FSLib::Directory::Directory( const string &path_ ) : dir_path( path_ ) {
// need to append \\* for windows to search files in directory // need to append \\* for windows to search files in directory