summaryrefslogtreecommitdiff
path: root/cpp/include/IcePatch/Util.h
blob: ebce9655c50ca6aacd9c183fee7593c51f67920f (plain)
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
// **********************************************************************
//
// Copyright (c) 2003
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************

#ifndef ICE_PATCH_UTIL_H
#define ICE_PATCH_UTIL_H

#include <Ice/Ice.h>
#include <IcePatch/IcePatch.h>

namespace IcePatch
{

ICE_PATCH_API std::string identityToPath(const Ice::Identity&);
ICE_PATCH_API Ice::Identity pathToIdentity(const std::string&);

ICE_PATCH_API std::string getSuffix(const std::string&);
ICE_PATCH_API bool ignoreSuffix(const std::string&);
ICE_PATCH_API std::string removeSuffix(const std::string&);

enum FileType
{
    FileTypeNotExist,
    FileTypeDirectory,
    FileTypeRegular
};

struct FileInfo
{
    FileType type;
    off_t size;
    time_t time;
};

ICE_PATCH_API FileInfo getFileInfo(const std::string&, bool, const Ice::LoggerPtr& = 0);

ICE_PATCH_API void removeRecursive(const std::string&, const Ice::LoggerPtr& = 0);

ICE_PATCH_API Ice::StringSeq readDirectory(const std::string&);
ICE_PATCH_API Ice::StringSeq readDirectory(const std::string&, const std::string&);
ICE_PATCH_API void createDirectory(const std::string&);

ICE_PATCH_API Ice::ByteSeq getMD5(const std::string&);
ICE_PATCH_API void putMD5(const std::string&, const Ice::ByteSeq&);
ICE_PATCH_API void createMD5(const std::string&, const Ice::LoggerPtr& = 0);
ICE_PATCH_API Ice::ByteSeq calcMD5(const std::string&, const Ice::LoggerPtr& = 0);
ICE_PATCH_API Ice::ByteSeq calcPartialMD5(const std::string&, Ice::Int, const Ice::LoggerPtr& = 0);

ICE_PATCH_API Ice::ByteSeq getBZ2(const std::string&, Ice::Int, Ice::Int);
ICE_PATCH_API void createBZ2(const std::string&, const Ice::LoggerPtr&);

typedef std::map<Ice::ByteSeq, Ice::Long> TotalMap;

ICE_PATCH_API TotalMap getTotalMap(const Ice::CommunicatorPtr&, const std::string&);
ICE_PATCH_API void putTotalMap(const Ice::CommunicatorPtr&, const std::string&, const TotalMap&);

#ifdef _WIN32

//
// Function object to do case-insensitive string comparison.
//
class ICE_PATCH_API CICompare : public std::binary_function<std::string, std::string, bool>
{
public:

    bool operator()(const std::string&, const std::string&) const;
};

#endif

}

#endif