/[AnywhereTS-MSSQL]/trunk/Tools/ATSClientManager/ATSClientManager/ATSClientFilesCollection.cs
ViewVC logotype

Annotation of /trunk/Tools/ATSClientManager/ATSClientManager/ATSClientFilesCollection.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 350 - (hide annotations) (download)
Tue Aug 28 01:02:00 2012 UTC (7 years, 11 months ago) by william
File size: 2978 byte(s)

1 william 335 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5 william 341 using System.IO;
6 william 335 namespace AnywhereTS.ATSClientManager
7     {
8     public static class ATSClientFilesCollection
9     {
10     private static Dictionary<ATSClientFileTypes, string> collection;
11    
12     static ATSClientFilesCollection()
13     {
14     collection = new Dictionary<ATSClientFileTypes, string>
15     {
16 william 349 {ATSClientFileTypes.ClientFileSystem, @"\initrd"},
17     {ATSClientFileTypes.ClientConfig, @"\squashfs-root\defaults"},
18 william 350 {ATSClientFileTypes.DefaultClientConfig, @"\network"},
19 william 349 {ATSClientFileTypes.ClientBootKernel, @"\vmlinuz"},
20 william 335 };
21     }
22    
23     public static string GetClientFileByType(ATSClientFileTypes type)
24     {
25     string file = string.Empty;
26     if (type == ATSClientFileTypes.ClientUnknown)
27     {
28     Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection::detected a request for type: {0}", type.ToString());
29     return string.Empty;
30     }
31     if (collection.ContainsKey(type)) { file = collection[type]; }
32     else
33     {
34     Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection does not contain a client file for type: {0}", type.ToString());
35     file = string.Empty;
36     }
37     return file;
38     }
39     public static ATSClientFileTypes GetClientFileTypeByName(string name)
40     {
41     ATSClientFileTypes found = ATSClientFileTypes.ClientUnknown;
42     foreach (KeyValuePair<ATSClientFileTypes, string> t in collection) { if (t.Value.ToLower() == name.ToLower()) { found = t.Key; break; } }
43     if (found == ATSClientFileTypes.ClientUnknown) { Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection does not contain a client type for file: {0}", name); }
44     return found;
45     }
46 william 341
47     public static ATSClientFileList GetClientFilesInPath(DirectoryInfo path)
48     {
49     ATSClientFileList list = new ATSClientFileList();
50     List<IATSClientFile> client_files = new List<IATSClientFile>();
51 william 349 List<FileInfo> files = new List<FileInfo>(path.GetFiles("*.*",SearchOption.AllDirectories));
52 william 341 foreach (var file in files)
53     {
54 william 349 ATSClientFileTypes type = GetClientFileTypeByName(file.FullName.Replace(path.FullName, ""));
55     if(type != ATSClientFileTypes.ClientUnknown)
56 william 341 client_files.Add(ATSClientFile.Create(type, file.FullName));
57     }
58 william 350 list = new ATSClientFileList(path.FullName, client_files);
59 william 341 return list;
60     }
61     public static ATSClientFileList GetClientFilesInPath(string path)
62     {
63     return GetClientFilesInPath(new DirectoryInfo(path));
64     }
65 william 335 }
66     }

  ViewVC Help
Powered by ViewVC 1.1.22