Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(670)

Side by Side Diff: Tools/Google.Build.Tester/Utils.cs

Issue 12767046: Issue 377: New build for releasing a new version (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Patch Set: david comments Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Tools/Google.Build.Tester/UnitTester.cs ('k') | Tools/Google.Build.Tester/app.config » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Copyright 2011 Google Inc
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 using System.IO;
18
19 namespace Google.Build.Tester
20 {
21 /// <summary>
22 /// Utility class.
23 /// </summary>
24 internal class Utils
25 {
26 /// <summary>
27 /// Copies all files and directories from the source to the destination.
28 /// </summary>
29 public static void CopyFiles(string source, string dest)
30 {
31 foreach (var file in Directory.GetFiles(source, "*", SearchOption.Al lDirectories))
32 {
33 string fileDest = Path.Combine(dest, GetRelativePath(file, sourc e));
34 string dir = Path.GetDirectoryName(fileDest);
35
36 if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
37 {
38 Directory.CreateDirectory(dir);
39 }
40
41 File.Copy(file, fileDest, true);
42 }
43 }
44
45 /// <summary>
46 /// Retrieves the relative path from the parent to the child.
47 /// </summary>
48 public static string GetRelativePath(string child, string parent)
49 {
50 string absoluteChild = Path.GetFullPath(child);
51 string absoluteParent = Path.GetFullPath(parent);
52
53 if (!absoluteChild.StartsWith(absoluteParent Path.DirectorySeparat orChar))
54 {
55 return absoluteChild; // Nothing in common.
56 }
57
58 return absoluteChild.Substring(absoluteParent.Length 1);
59 }
60 }
61 }
OLDNEW
« no previous file with comments | « Tools/Google.Build.Tester/UnitTester.cs ('k') | Tools/Google.Build.Tester/app.config » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b