Skip to content

Commit b7899b1

Browse files
author
Clement Champetier
committed
Move functions from common to ProfileLoader
1 parent 4bb9a5f commit b7899b1

File tree

4 files changed

+36
-40
lines changed

4 files changed

+36
-40
lines changed

src/AvTranscoder/ProfileLoader.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <fstream>
77
#include <cstdlib>
88
#include <stdexcept>
9+
#include <dirent.h>
910

1011
namespace avtranscoder
1112
{
@@ -200,5 +201,35 @@ bool ProfileLoader::checkAudioProfile( const Profile& profileToCheck )
200201
return isValid;
201202
}
202203

204+
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars )
205+
{
206+
char* part = strtok( const_cast<char*>( inputString.c_str() ), splitChars.c_str() );
207+
while( part != NULL )
208+
{
209+
splitedString.push_back( std::string( part ) );
210+
part = strtok( NULL, splitChars.c_str() );
211+
}
212+
}
213+
214+
int getFilesInDir( const std::string& dir, std::vector< std::string >& files )
215+
{
216+
DIR *dp;
217+
struct dirent *dirp;
218+
if( ( dp = opendir( dir.c_str() ) ) == NULL )
219+
{
220+
std::cerr << "Error(" << errno << ") opening " << dir << std::endl;
221+
return errno;
222+
}
223+
224+
while( ( dirp = readdir( dp ) ) != NULL )
225+
{
226+
std::string filename( dirp->d_name );
227+
if( filename == "." || filename == ".." )
228+
continue;
229+
files.push_back( filename );
230+
}
231+
closedir( dp );
232+
return 0;
233+
}
203234

204235
}

src/AvTranscoder/ProfileLoader.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,10 @@ class AvExport ProfileLoader
7373
Profiles _profiles;
7474
};
7575

76+
#ifndef SWIG
77+
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars = ";" );
78+
int getFilesInDir( const std::string& dir, std::vector< std::string >& files );
79+
#endif
80+
7681
}
7782
#endif

src/AvTranscoder/common.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ extern "C" {
66
#include <libavutil/error.h>
77
}
88

9-
#include <dirent.h>
10-
#include <iostream>
11-
129
namespace avtranscoder
1310
{
1411

@@ -22,37 +19,6 @@ void setLogLevel( const int level )
2219
av_log_set_level( level );
2320
}
2421

25-
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars )
26-
{
27-
char* part = strtok( const_cast<char*>( inputString.c_str() ), splitChars.c_str() );
28-
while( part != NULL )
29-
{
30-
splitedString.push_back( std::string( part ) );
31-
part = strtok( NULL, splitChars.c_str() );
32-
}
33-
}
34-
35-
int getFilesInDir( const std::string& dir, std::vector< std::string >& files )
36-
{
37-
DIR *dp;
38-
struct dirent *dirp;
39-
if( ( dp = opendir( dir.c_str() ) ) == NULL )
40-
{
41-
std::cerr << "Error(" << errno << ") opening " << dir << std::endl;
42-
return errno;
43-
}
44-
45-
while( ( dirp = readdir( dp ) ) != NULL )
46-
{
47-
std::string filename( dirp->d_name );
48-
if( filename == "." || filename == ".." )
49-
continue;
50-
files.push_back( filename );
51-
}
52-
closedir( dp );
53-
return 0;
54-
}
55-
5622
std::string getFormat( const std::string& filename )
5723
{
5824
std::string format( "" );

src/AvTranscoder/common.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern "C" {
1818

1919
#include <string>
2020
#include <cstring>
21-
#include <vector>
2221

2322
#ifdef SWIG
2423
#define AvExport
@@ -66,11 +65,6 @@ void AvExport preloadCodecsAndFormats();
6665
*/
6766
void AvExport setLogLevel( const int level );
6867

69-
#ifndef SWIG
70-
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars = ";" );
71-
int getFilesInDir( const std::string& dir, std::vector< std::string >& files );
72-
#endif
73-
7468
std::string AvExport getFormat( const std::string& filename );
7569
bool AvExport matchFormat( const std::string& format, const std::string& filename );
7670

0 commit comments

Comments
 (0)