Terrasync: make whitespace in pathnames work under windows
This commit is contained in:
@@ -366,3 +366,20 @@ bool SGPath::isNull() const
|
|||||||
{
|
{
|
||||||
return path.empty() || (path == "");
|
return path.empty() || (path == "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SGPath::str_native() const
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string s = str();
|
||||||
|
std::string::size_type pos;
|
||||||
|
std::string nativeSeparator;
|
||||||
|
nativeSeparator = sgDirPathSepBad;
|
||||||
|
|
||||||
|
while( (pos=s.find( sgDirPathSep )) != std::string::npos ) {
|
||||||
|
s.replace( pos, 1, nativeSeparator );
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
#else
|
||||||
|
return str();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -141,6 +141,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
const char* c_str() const { return path.c_str(); }
|
const char* c_str() const { return path.c_str(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path string in OS native form
|
||||||
|
*/
|
||||||
|
std::string str_native() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if file exists by attempting to fopen it.
|
* Determine if file exists by attempting to fopen it.
|
||||||
* @return true if file exists, otherwise returns false.
|
* @return true if file exists, otherwise returns false.
|
||||||
|
|||||||
@@ -312,7 +312,9 @@ bool SGTerraSync::SvnThread::start()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SG_WINDOWS
|
#if 0
|
||||||
|
// whitespace support should work now
|
||||||
|
//#ifdef SG_WINDOWS
|
||||||
if ((_use_svn)&&(!use_int_svn))
|
if ((_use_svn)&&(!use_int_svn))
|
||||||
{
|
{
|
||||||
// external SVN support is used
|
// external SVN support is used
|
||||||
@@ -492,11 +494,20 @@ bool SGTerraSync::SvnThread::syncTreeExternal(const char* dir)
|
|||||||
if (_use_svn)
|
if (_use_svn)
|
||||||
{
|
{
|
||||||
#ifdef SG_WINDOWS
|
#ifdef SG_WINDOWS
|
||||||
// no support for white-space paths
|
SGPath localPath( _local_dir );
|
||||||
|
localPath.append( dir );
|
||||||
|
|
||||||
|
// windows command line parsing is just lovely...
|
||||||
|
// to allow white spaces, the system call needs this:
|
||||||
|
// ""C:\Program Files\something.exe" somearg "some other arg""
|
||||||
|
// Note: whitespace strings quoted by a pair of "" _and_ the
|
||||||
|
// entire string needs to be wrapped by "" too.
|
||||||
|
// The svn url needs forward slashes (/) as a path separator while
|
||||||
|
// the local path needs windows-native backslash as a path separator.
|
||||||
snprintf( command, 512,
|
snprintf( command, 512,
|
||||||
"%s %s %s/%s %s/%s", _svn_command.c_str(), svn_options,
|
"\"\"%s\" %s %s/%s \"%s\"\"", _svn_command.c_str(), svn_options,
|
||||||
_svn_server.c_str(), dir,
|
_svn_server.c_str(), dir,
|
||||||
_local_dir.c_str(), dir );
|
localPath.str_native().c_str() );
|
||||||
#else
|
#else
|
||||||
// support white-space paths (use '"')
|
// support white-space paths (use '"')
|
||||||
snprintf( command, 512,
|
snprintf( command, 512,
|
||||||
|
|||||||
Reference in New Issue
Block a user