File: pysvn_path.cpp

package info (click to toggle)
pysvn 1.5.0dfsg-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,524 kB
  • ctags: 2,281
  • sloc: cpp: 9,846; python: 2,662; sh: 430; makefile: 101; ansic: 9
file content (53 lines) | stat: -rw-r--r-- 1,624 bytes parent folder | download
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
//
// ====================================================================
// Copyright (c) 2003-2006 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.
//
// ====================================================================
//
#ifdef _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 ) )
    {
        const char *normalised_path = svn_path_canonicalize( unnormalised.c_str(), pool );
        return std::string( normalised_path );
    }
    else
    {
        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 );
}