Skip to content

Commit 2020627

Browse files
author
Clement Champetier
committed
profile: add util header to separate functions to browse profiles
1 parent ecb2ffb commit 2020627

File tree

3 files changed

+46
-38
lines changed

3 files changed

+46
-38
lines changed

src/AvTranscoder/profile/ProfileLoader.cpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include "ProfileLoader.hpp"
22

3+
#include "util.hpp"
4+
35
#include <iostream>
46
#include <fstream>
57
#include <cstdlib>
68
#include <stdexcept>
7-
#include <dirent.h>
89

910
namespace avtranscoder
1011
{
@@ -201,35 +202,4 @@ bool ProfileLoader::checkAudioProfile( const Profile& profileToCheck )
201202
return isValid;
202203
}
203204

204-
void split( std::vector< std::string >& splitString, 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-
splitString.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-
}
234-
235205
}

src/AvTranscoder/profile/ProfileLoader.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <AvTranscoder/common.hpp>
55

66
#include <string>
7-
#include <cstring>
87
#include <vector>
98
#include <map>
109

@@ -73,10 +72,5 @@ class AvExport ProfileLoader
7372
Profiles _profiles;
7473
};
7574

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

src/AvTranscoder/profile/util.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef _AV_TRANSCODER_PROFILE_UTIL_HPP_
2+
#define _AV_TRANSCODER_PROFILE_UTIL_HPP_
3+
4+
#include <string>
5+
#include <dirent.h>
6+
#include <iostream>
7+
8+
namespace avtranscoder
9+
{
10+
11+
void split( std::vector< std::string >& splitString, const std::string& inputString, const std::string& splitChars )
12+
{
13+
char* part = strtok( const_cast<char*>( inputString.c_str() ), splitChars.c_str() );
14+
while( part != NULL )
15+
{
16+
splitString.push_back( std::string( part ) );
17+
part = strtok( NULL, splitChars.c_str() );
18+
}
19+
}
20+
21+
int getFilesInDir( const std::string& dir, std::vector< std::string >& files )
22+
{
23+
DIR *dp;
24+
struct dirent *dirp;
25+
if( ( dp = opendir( dir.c_str() ) ) == NULL )
26+
{
27+
std::cerr << "Error(" << errno << ") opening " << dir << std::endl;
28+
return errno;
29+
}
30+
31+
while( ( dirp = readdir( dp ) ) != NULL )
32+
{
33+
std::string filename( dirp->d_name );
34+
if( filename == "." || filename == ".." )
35+
continue;
36+
files.push_back( filename );
37+
}
38+
closedir( dp );
39+
return 0;
40+
}
41+
42+
}
43+
44+
#endif

0 commit comments

Comments
 (0)