forked from YeeYoungHan/cpphttpstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetFileName.cpp
More file actions
44 lines (33 loc) · 973 Bytes
/
Copy pathGetFileName.cpp
File metadata and controls
44 lines (33 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "TestGoogleDownload.h"
bool GetFileName( std::string & strUrl, std::string & strFileName )
{
strFileName.clear();
std::string strDecode;
DecodeUri( strUrl, strDecode );
int iLen = (int)strDecode.length();
for( int i = iLen - 1; i >= 0; --i )
{
if( strDecode.at(i) == '/' )
{
strFileName = strDecode.c_str() + i + 1;
break;
}
}
if( strFileName.empty() ) return false;
ReplaceString( strFileName, "\\", "" );
ReplaceString( strFileName, "/", "" );
ReplaceString( strFileName, ":", "" );
ReplaceString( strFileName, "*", "" );
ReplaceString( strFileName, "?", "" );
ReplaceString( strFileName, "\"", "" );
ReplaceString( strFileName, "<", "" );
ReplaceString( strFileName, ">", "" );
ReplaceString( strFileName, "|", "" );
std::string strAnsi;
Utf8ToAnsi( strFileName.c_str(), strAnsi );
if( strstr( strAnsi.c_str(), "?" ) == NULL )
{
strFileName = strAnsi;
}
return true;
}