Move file_name_utils into coding.

This commit is contained in:
vng 2013-01-28 02:18:48 +03:00 committed by Alex Zolotarev
parent 4b105bb8a6
commit 6f1dcdd9ed
8 changed files with 45 additions and 18 deletions

View file

@ -32,6 +32,7 @@ SOURCES += \
blob_storage.cpp \
uri.cpp \
zip_creator.cpp \
file_name_utils.cpp \
HEADERS += \
internal/xmlparser.h \
@ -91,3 +92,4 @@ HEADERS += \
blob_storage.hpp \
uri.hpp \
zip_creator.hpp \
file_name_utils.hpp \

View file

@ -44,6 +44,7 @@ SOURCES += ../../testing/testingmain.cpp \
blob_storage_test.cpp \
uri_test.cpp \
zip_creator_test.cpp \
file_utils_test.cpp \
HEADERS += \
reader_test.hpp \

View file

@ -0,0 +1,35 @@
#include "../../testing/testing.hpp"
#include "../file_name_utils.hpp"
UNIT_TEST(FileName_Smoke)
{
string name = "/Users/xxx/Documents/test.test";
my::GetNameFromFullPath(name);
TEST_EQUAL(name, "test.test", ());
my::GetNameFromFullPath(name);
TEST_EQUAL(name, "test.test", ());
my::GetNameWithoutExt(name);
TEST_EQUAL(name, "test", ());
name = "C:\\My Documents\\test.test";
my::GetNameFromFullPath(name);
TEST_EQUAL(name, "test.test", ());
my::GetNameWithoutExt(name);
TEST_EQUAL(name, "test", ());
name = "/";
my::GetNameFromFullPath(name);
TEST(name.empty(), ());
name = "C:\\";
my::GetNameFromFullPath(name);
TEST(name.empty(), ());
name = "../test";
my::GetNameFromFullPath(name);
TEST_EQUAL(name, "test", ());
my::GetNameWithoutExt(name);
TEST_EQUAL(name, "test", ());
}

View file

@ -1,7 +1,7 @@
#include "file_name_utils.hpp"
namespace pl
namespace my
{
void GetNameWithoutExt(string & name)
@ -11,16 +11,11 @@ void GetNameWithoutExt(string & name)
name.erase(i);
}
void GetNameFromURLRequest(string & name)
void GetNameFromFullPath(string & name)
{
string::size_type const i = name.find_last_of("/\\");
if (i != string::npos)
name = name.substr(i+1);
}
void GetNameFromPath(string & name)
{
GetNameFromURLRequest(name);
}
}

View file

@ -2,14 +2,11 @@
#include "../std/string.hpp"
namespace pl
namespace my
{
/// Remove extension from file name.
void GetNameWithoutExt(string & name);
/// Get file name from download url.
void GetNameFromURLRequest(string & name);
/// Get file name from full path.
void GetNameFromPath(string & name);
void GetNameFromFullPath(string & name);
}

View file

@ -2,8 +2,8 @@
#include "data_header.hpp"
#include "../platform/platform.hpp"
#include "../platform/file_name_utils.hpp"
#include "../coding/file_name_utils.hpp"
#include "../coding/internal/file_data.hpp"
@ -20,8 +20,8 @@ MwmValue::MwmValue(string const & name)
string MwmValue::GetFileName() const
{
string s = m_cont.GetFileName();
pl::GetNameFromPath(s);
pl::GetNameWithoutExt(s);
my::GetNameFromFullPath(s);
my::GetNameWithoutExt(s);
return s;
}

View file

@ -67,7 +67,6 @@ HEADERS += \
chunks_download_strategy.hpp \
servers_list.hpp \
constants.hpp \
file_name_utils.hpp \
SOURCES += \
preferred_languages.cpp \
@ -77,4 +76,3 @@ SOURCES += \
chunks_download_strategy.cpp \
platform.cpp \
servers_list.cpp \
file_name_utils.cpp \

View file

@ -7,7 +7,6 @@
#include "../platform/platform.hpp"
#include "../platform/servers_list.hpp"
#include "../platform/file_name_utils.hpp"
#include "../platform/settings.hpp"
#include "../coding/file_writer.hpp"