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();
}
private:
string dir_path;
};

View File

@ -129,7 +129,7 @@ bool searchSpecificSeason( const char_t *const path, size_t &ep_pos,
while ( path[cur_pos] == '0' )
cur_pos++;
// if season number is 0, move back because previous loop skipped it
if( number == TEXT("0") )
if ( number == TEXT( "0" ) )
cur_pos--;
// make sure season's number is the same as provided in argument
// `number`
@ -193,8 +193,8 @@ void iterateFS( std::map< int, std::set< string > > &seasons,
// if file is a correct format, add it to file list
// for its season
if ( searchSeason( p, season_pos ) )
seasons[std::stoi( p + season_pos )].insert(
path + dir_divider + p );
seasons[std::stoi( p + season_pos )].insert( path + dir_divider +
p );
}
}
@ -286,11 +286,13 @@ void printHelp() {
cout << "Usage:" << std::endl;
cout << " tv_rename [options] [path]" << std::endl << std::endl;
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"
<< std::endl;
cout << " all files in it and its subdirectories will be renamed"
<< std::endl << std::endl;
<< std::endl
<< std::endl;
cout << "OPTIONS" << std::endl;
cout << " -s, --show <string> TV show from which you want the";
cout << " episode names" << std::endl;
@ -394,12 +396,11 @@ getPossibleShows( string show, const string &language, Curl &c ) {
show = encodeUrl( show );
#ifdef _WIN32
auto source_code = utf8_to_wstring(
c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) +
show + TEXT( "&l=" ) + language ) );
c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) + show +
TEXT( "&l=" ) + language ) );
#else
auto source_code =
c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) +
show + TEXT( "&l=" ) + language );
auto source_code = c.execute( TEXT( "https://www.thetvdb.com/search?q=" ) +
show + TEXT( "&l=" ) + language );
#endif
size_t pos{};
std::vector< std::pair< string, string > > urls;

View File

@ -163,7 +163,7 @@ int parseCommandLine( string &show, std::set< int > &seasons_num, string &path,
{ "print-langs", no_argument, 0, '0' },
{ "name-pattern", required_argument, 0, '1' },
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0}
{ 0, 0, 0, 0 }
};
int i{}; // this is useless, but needed for handleArgument
@ -224,7 +224,7 @@ int main
if ( !FSLib::isDirectory( path ) && FSLib::exists( path ) ) {
// specified file, not directory
auto *file_set = new std::set<string>;
auto *file_set = new std::set< string >;
file_set->insert( path );
size_t season_pos{};
if ( !searchSeason( path.c_str(), season_pos ) ) {
@ -233,8 +233,8 @@ int main
return 1;
} else {
auto season = std::stoi( path.c_str() + season_pos );
singleSeason( path, show, season, TEXT(""), language, pattern,
linux, trust, c, file_set );
singleSeason( path, show, season, TEXT( "" ), language, pattern,
linux, trust, c, file_set );
return 0;
}
} else if ( !FSLib::isDirectory( path ) ) {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
#include <sys/stat.h>
#include "../filesystem.hpp"
#include <sys/stat.h>
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 );
if ( current_entry != nullptr &&
( !strcmp( current_entry->d_name, "." ) ||
@ -11,7 +12,8 @@ FSLib::Directory::Iterator::Iterator( const Directory &d_ ) : d( opendir( d_.pat
++( *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_ ) {}
FSLib::Directory::Iterator::~Iterator() {

View File

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