blob: c47a84b5703715f7576cc01d6886b29ac73fc503 (
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
|
/***************************************************************************************************
Copyright (C) 2024 The Qt Company Ltd.
SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
***************************************************************************************************/
#region Task TaskName="ListQrc"
#region Reference
//System.Xml
//System.Xml.Linq
#endregion
#region Using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
#endregion
#region Comment
/////////////////////////////////////////////////////////////////////////////////////////////////
/// TASK ListQrc
/////////////////////////////////////////////////////////////////////////////////////////////////
// List resource paths in a QRC file.
// Parameters:
// in string QrcFilePath: path to QRC file
// out string[] Result: paths to files referenced in QRC
#endregion
namespace QtVsTools.QtMsBuild.Tasks
{
public static class ListQrc
{
public static bool Execute(
#region Parameters
System.String QrcFilePath,
out System.String[] Result)
#endregion
{
#region Code
Result = null;
if (!File.Exists(QrcFilePath))
return false;
XDocument qrc = XDocument.Load(QrcFilePath, LoadOptions.SetLineInfo);
IEnumerable<XElement> files = qrc
.Element("RCC")
.Elements("qresource")
.Elements("file");
Uri QrcPath = new Uri(QrcFilePath);
Result = files
.Select(x => new Uri(QrcPath, x.Value).LocalPath)
.ToArray();
#endregion
return true;
}
}
}
#endregion
|