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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
//
// ====================================================================
// Copyright (c) 2003-2009 Barry A Scott. All rights reserved.
//
// This software is licensed as described in the file LICENSE.txt,
// which you should have received as part of this distribution.
//
// ====================================================================
//
#if defined( _MSC_VER )
// disable warning C4786: symbol greater than 255 character,
// nessesary to ignore as <map> causes lots of warning
#pragma warning(disable: 4786)
#endif
#include "pysvn.hpp"
#include <algorithm>
#include "svn_path.h"
#include <sys/types.h>
#include <sys/stat.h>
// SVN lives in a world of its own for URL and path syntax
// here are routines to convert from OS conventions to SVN's
// is this a path of a url svn?
bool is_svn_url( const std::string &path_or_url )
{
return svn_path_is_url( path_or_url.c_str() ) != 0;
}
// convert a path or URL to what SVN likes
std::string svnNormalisedIfPath( const std::string &unnormalised, SvnPool &pool )
{
if( is_svn_url( unnormalised ) )
{
return svnNormalisedUrl( unnormalised, pool );
}
else
{
return svnNormalisedPath( unnormalised, pool );
}
}
#if defined(PYSVN_HAS_SVN_1_7)
std::string svnNormalisedUrl( const std::string &unnormalised, SvnPool &pool )
{
const char *normalised_path = svn_uri_canonicalize( unnormalised.c_str(), pool );
return std::string( normalised_path );
}
std::string svnNormalisedPath( const std::string &unnormalised, SvnPool &pool )
{
const char *normalised_path = svn_dirent_internal_style( unnormalised.c_str(), pool );
return std::string( normalised_path );
}
// convert a path to what the native OS likes
std::string osNormalisedPath( const std::string &unnormalised, SvnPool &pool )
{
const char *local_path = svn_dirent_local_style( unnormalised.c_str(), pool );
return std::string( local_path );
}
#else
std::string svnNormalisedUrl( const std::string &unnormalised, SvnPool &pool )
{
const char *normalised_path = svn_path_canonicalize( unnormalised.c_str(), pool );
return std::string( normalised_path );
}
std::string svnNormalisedPath( const std::string &unnormalised, SvnPool &pool )
{
const char *normalised_path = svn_path_internal_style( unnormalised.c_str(), pool );
return std::string( normalised_path );
}
// convert a path to what the native OS likes
std::string osNormalisedPath( const std::string &unnormalised, SvnPool &pool )
{
const char *local_path = svn_path_local_style( unnormalised.c_str(), pool );
return std::string( local_path );
}
#endif
|