summaryrefslogtreecommitdiff
path: root/src/binder/inc/utils.hpp
blob: 8b65fd8c120b1204af15e62032243338803e52e3 (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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ============================================================
//
// Utils.hpp
//


//
// Declares a bunch of binder auxilary functions
//
// ============================================================

#ifndef __BINDER_UTILS_HPP__
#define __BINDER_UTILS_HPP__

#include "bindertypes.hpp"

extern LocaleID g_lcid;

namespace BINDER_SPACE
{
    inline BOOL EqualsCaseInsensitive(SString &a, SString &b)
    {
        return a.EqualsCaseInsensitive(b, g_lcid);
    }

    inline ULONG HashCaseInsensitive(SString &string)
    {
        return string.HashCaseInsensitive(g_lcid);
    }

    HRESULT FileOrDirectoryExists(PathString &path);
    HRESULT FileOrDirectoryExistsLog(PathString &path);

    BOOL IsURL(SString &urlOrPath);

    void MutateUrlToPath(SString &urlOrPath);
    void MutatePathToUrl(SString &pathOrUrl);

    // Mutates path
    void PlatformPath(SString &path);
    void CanonicalizePath(SString &path, BOOL fAppendPathSeparator = FALSE);

    // It is safe to use either A or B as CombinedPath.
    void CombinePath(SString &pathA,
                     SString &pathB,
                     SString &combinedPath);

    HRESULT GetTokenFromPublicKey(SBuffer &publicKeyBLOB,
                                  SBuffer &publicKeyTokenBLOB);

    BOOL IsFileNotFound(HRESULT hr);
};

#endif