forked from mcneel/rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLBPFileMgr2.cpp
47 lines (36 loc) · 847 Bytes
/
LBPFileMgr2.cpp
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
45
46
47
#include "stdafx.h"
#include "LBPFileMgr2.h"
#include "LBPString.h"
#define LBP_DIRECTORY_SLASH L'\\'
CLBPString CLBPFileMgr2::GetPathOnly(const CLBPString& sPath)
{
return CLBPFileMgr2::Truncate(sPath);
}
CLBPString CLBPFileMgr2::Truncate(const CLBPString& sPath)
{
if(sPath.IsEmpty())
return L"";
int iPos = GetWithTrailingSlashRemoved(sPath).ReverseFind(LBP_DIRECTORY_SLASH);
if(-1 == iPos)
{
//Not a path - just a name
return L"";
}
return sPath.Left(iPos);
}
CLBPString CLBPFileMgr2::GetWithTrailingSlashRemoved(const CLBPString& s)
{
CLBPString sPath(s);
RemoveTrailingSlash(sPath);
return sPath;
}
void CLBPFileMgr2::RemoveTrailingSlash(CLBPString& sPath)
{
if (sPath.IsEmpty())
return;
int iLast = sPath.GetLength()-1;
if(LBP_DIRECTORY_SLASH == sPath.GetAtWide(iLast))
{
sPath = sPath.Left(iLast);
}
}