mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 00:18:43 +00:00
Changed: Reverted another previous fix (sorry again)
This commit is contained in:
parent
32c376fefa
commit
e2237d3971
2 changed files with 0 additions and 89 deletions
|
@ -45,74 +45,6 @@ using namespace NLNET;
|
||||||
|
|
||||||
namespace GUS
|
namespace GUS
|
||||||
{
|
{
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// cleanPath - convert a path to standardised format
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CSString cleanPath(const CSString& path,bool addTrailingSlash)
|
|
||||||
{
|
|
||||||
CSString result;
|
|
||||||
|
|
||||||
// split the path up into its component elements
|
|
||||||
CVectorSString pathComponents;
|
|
||||||
path.unquoteIfQuoted().splitByOneOfSeparators("/\\",pathComponents,false,false,true,false,true);
|
|
||||||
|
|
||||||
// iterate over path components collapsing '.' and '..' entries
|
|
||||||
for (uint32 i=0;i<pathComponents.size();++i)
|
|
||||||
{
|
|
||||||
// skip "." entries
|
|
||||||
if (pathComponents[i]==".")
|
|
||||||
{
|
|
||||||
pathComponents[i].clear();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with ".."
|
|
||||||
if (pathComponents[i]=="..")
|
|
||||||
{
|
|
||||||
// run back through our component list looking for an element to remove
|
|
||||||
uint32 j;
|
|
||||||
for (j=i;j--;)
|
|
||||||
{
|
|
||||||
if (!pathComponents[j].empty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// if we found an element then remove it and the '..' as well
|
|
||||||
if (j!=~0u)
|
|
||||||
{
|
|
||||||
pathComponents[j].clear();
|
|
||||||
pathComponents[i].clear();
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// treat the special case where oriinal path started with a '/' or '//'
|
|
||||||
if (path.left(1)=="/" || path.left(1)=="\\")
|
|
||||||
{
|
|
||||||
result= (path.left(2).right(1)=="/" || path.left(2).right(1)=="\\")? "//": "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
// concatenate the path bits
|
|
||||||
for (uint32 i=0;i<pathComponents.size();++i)
|
|
||||||
{
|
|
||||||
if (!pathComponents[i].empty())
|
|
||||||
{
|
|
||||||
result+= pathComponents[i];
|
|
||||||
result+= '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we're not supposed to have a trailing slash then get rid of the one that's added by default
|
|
||||||
if (addTrailingSlash==false && path.right(1)!='/' && path.right(1)!='\\')
|
|
||||||
{
|
|
||||||
result.resize(result.size()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// private routines for layer 5 service tracking
|
// private routines for layer 5 service tracking
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -39,27 +39,6 @@ namespace GUS
|
||||||
// handy utilities
|
// handy utilities
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Clean a path performing the following operations:
|
|
||||||
// - convert '\\' characters to '/'
|
|
||||||
// - replace '//' strings in the middle of the path with '/'
|
|
||||||
// - remove '.' directory entries
|
|
||||||
// - colapse '..' directory entries (removing parent entries)
|
|
||||||
// - append a final '/' (optionally)
|
|
||||||
//
|
|
||||||
// examples:
|
|
||||||
// - a:/bcd/efg/ => a:/bcd/efg/ (no change)
|
|
||||||
// - a:\bcd\efg => a:/bcd/efg/
|
|
||||||
// - \bcd\\efg => /bcd/efg/
|
|
||||||
// - \\bcd\efg => //bcd/efg/
|
|
||||||
// - \bcd\.\efg => /bcd/efg/
|
|
||||||
// - \bcd\..\efg => /efg/
|
|
||||||
// - bcd\..\efg => efg/
|
|
||||||
// - bcd\..\..\efg => ../efg/
|
|
||||||
// - \bcd\..\..\efg => /efg/ (NOTE: the redundant '..' entry is lost due to leading '\')
|
|
||||||
//
|
|
||||||
NLMISC::CSString cleanPath(const NLMISC::CSString& path,bool addTrailingSlash);
|
|
||||||
|
|
||||||
|
|
||||||
// execute a command on a remote service
|
// execute a command on a remote service
|
||||||
void executeRemoteCommand(NLNET::TServiceId sid,const NLMISC::CSString& cmdLine);
|
void executeRemoteCommand(NLNET::TServiceId sid,const NLMISC::CSString& cmdLine);
|
||||||
void executeRemoteCommand(const char* serviceName,const NLMISC::CSString& cmdLine);
|
void executeRemoteCommand(const char* serviceName,const NLMISC::CSString& cmdLine);
|
||||||
|
|
Loading…
Reference in a new issue