Commit b07b5fc1 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

SystemTools: Take a string in GetShortPath

It's assumed to be non-null anyways, so just take a string which is done
on non-Windows unconditionally anyways.

Change-Id: I97219d644867287d9f5c789c3d1338a65286554f
parent 5eb3a65c
......@@ -4008,22 +4008,22 @@ bool SystemTools::FileIsFullPath(const char* in_name)
return false;
}
bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& shortPath)
{
#if defined(WIN32) && !defined(__CYGWIN__)
const int size = int(strlen(path)) +1; // size of return
const int size = int(path.size()) +1; // size of return
char *tempPath = new char[size]; // create a buffer
DWORD ret;
// if the path passed in has quotes around it, first remove the quotes
if (path[0] == '"' && path[strlen(path)-1] == '"')
if (!path.empty() && path[0] == '"' && *path.rbegin() == '"')
{
strcpy(tempPath,path+1);
tempPath[strlen(tempPath)-1] = '\0';
strcpy(tempPath,path.c_str()+1);
tempPath[size-2] = '\0';
}
else
{
strcpy(tempPath,path);
strcpy(tempPath,path.c_str());
}
kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath);
......
......@@ -465,7 +465,7 @@ public:
* For windows return the short path for the given path,
* Unix just a pass through
*/
static bool GetShortPath(const char* path, kwsys_stl::string& result);
static bool GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& result);
/**
* Read line from file. Make sure to get everything. Due to a buggy stream
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment